Kotlin reference states:
“Java types which have nullability annotations are represented not as platform types, but as actual nullable or non-null Kotlin types.”
I am wondering how to annotate a parameter/result/field of type List in Java such that when imported into Kotlin, it is treated as definitely nullable or non-null.
So:
var x = someJavaObject.someJavaMethod() // returning List<String> in Java
var y = x[0] // I want this to have Kotlin type String, not String!
None of the existing nullness annotations for Java seem to be able to express the nullability of generic type parameters. This could result in imported Java APIs not having as much null-safety in Kotlin as we might hope for.
Comments appreciated.