As the title says, I’m able to return null from a non-nullable property that’s backed by a map, where the map has a default null value.
class MyItem {
val name: String = ""
}
class MyClass {
val map = mutableMapOf<String, Any?>().withDefault { null }
var item: MyItem by map
}
MyClass().item // returns null, but 'item' is non-nullable
MyClass()?.item // the IDE says '?' isn't necessary
I’m wondering if this is an expected behaviour in Kotlin.