I have a nullable string variable ab. If I call toUpperCase via safe call operator after I assign null to it, kotlin gives error.
fun m
I decompiled your function and I figured: after the moment you make ab = null the compiler will smartcast it, putting null (ACONST_NULL) in every ocurrence of ab. Then as null has no type. you can't infer the type for the receiver of toUpperCase().
This is the java equivalent code generated from the kotlin byte code:
public final void main(@NotNull String[] args) {
Intrinsics.checkParameterIsNotNull(args, "args");
String ab = "hello";
ab = (String)null;
Object var3 = null;
System.out.println(var3);
}
It looks as an issue that should be resolved by the kotlin team.