diesieben0709/10/2017, 10:54 PM
can never be null,
can. In Java
does not express any notion of whether or not it can be null.
mersan09/10/2017, 10:56 PM
diesieben0709/10/2017, 10:58 PM
method, if the compiler infers
, it assumes "hey this method cannot return null now!". And since
is written in Kotlin, the compiler "trusts" it (not sure of the exact rules here). Inside
, the compiler cannot insert any null checks after the Java method returns, since it does not know what
in Kotlin, which then means that it can be null, so a null check would not be correct. So there cannot be any checks here.
had a non-generic return type (or you did
T : Any
can never be a nullable type) then the compiler could insert the null check.
mersan09/10/2017, 11:07 PM