this == null

How can it happen that this keyword returns null?


Even ReSharper tells that this condition is always false and yet, it return true in play mode and after exiting play mode.


this is not null only after assembly reload.
This problem only occurs in Unity 5. In Unity 4.6 it does not occur.

[EDIT] Solution in comments.

It can happen in Unity because the equality operator is overloaded for scripts. Comparing to null does not check to see if the reference points to null, which would otherwise be the case in standard C#. Instead, it checks to see if the object is instantiated in the scene (technically, whether it exists in Unity’s native C++ code backend).

ReSharper has no idea Unity is built this way. It assumes the equality operator works the same as for standard C#.