I was looking into the problem of SingletonList.
problem of SingletonList
val a = listOf("")
if(a is MutableList){
a.add("ded")
}
throws UnSupportedOperationException
.
The SingletonList is immutable, so it should not implement MutableList
.
When I did this, i came across the following quote on https://youtrack.jetbrains.com/issue/KT-15126#tab=Comments:
The distinction between List and MutableList exists only at compile time. At runtime they become the same type.
Is it possible to add a interface in Java which a collection can implement at runtime to keep this information or can be added in a Java project to support this?