This is a smart-cast that is occurring because you have asserted that event is not null. The event property of the message class must be immutable, meaning it is both a val and has no custom getter. (Or it might be a final field defined in a Java class.)
Smart-casting only happens for local variables (not captured in an enclosure) and immutable properties (defined in the same module or marked private), because otherwise the compiler cannot guarantee that the value hasn’t changed since its type/nullability was last asserted.
2
Answers
This is a smart-cast that is occurring because you have asserted that
event
is not null. Theevent
property of the message class must be immutable, meaning it is both aval
and has no custom getter. (Or it might be a final field defined in a Java class.)Smart-casting only happens for local variables (not captured in an enclosure) and immutable properties (defined in the same module or marked
private
), because otherwise the compiler cannot guarantee that the value hasn’t changed since its type/nullability was last asserted.To disable this inspection, navigate to
Editor -> Color Scheme -> Kotlin -> Smart-casts
and uncheck background for each type