vmironov
11/28/2015, 1:55 PMpublic class Magic {
private val foo: String? = null
private val bar: String = "not"
}
public fun main(args: Array<String>) {
Magic::class.members.forEach {
println("${it.name}, nullable = ${it.returnType.isMarkedNullable}")
}
}
prints:
bar, nullable = false
foo, nullable = true
equals, nullable = false
hashCode, nullable = false
toString, nullable = false
The question is, how is KType.isMarkedNullable
implemented? I don't see any nullability information in generated bytecode. Public properties are annotated with NotNull
and Nullable
annotations, but private ones don't have such annotations.
(I'm doing some bytecode instrumentation and want to know if field is nullable or not)