? I understand why it can't be set to any list but don't get why
null
shouldn't be allowed.
Copy code
abstract class Base<T> {
// foo is nullable
final var foo: MutableList<T>? = mutableListOf()
}
class Inherit : Base<String>()
val a = Inherit()
a.foo = null // works
a.foo = mutableListOf() // works
val b: Any = if (Random.nextBoolean()) a else Any()
if (b is Base<*>) {
// error: 'Setter for 'foo' is removed by type projection'
// I understand why it can't be set to any list but `null` should always be ok
b.foo = null
}
d
dmitriy.novozhilov
01/30/2022, 6:05 PM
Actually, it looks like a bug or new minor feature
Please report it to kotl.in/issue