spleenjack
08/13/2026, 10:07 AMsealed interface Foo {
data class Bar(val i: Int = 0) : Foo
companion object {
val Bar = Bar()
}
}
fun main() {
buildMap { put(Foo.Bar, 1) } // #1, put - ok
mapOf(Pair(Foo.Bar, 1)) // #2, Pair() - ok
mapOf(Foo.Bar as Foo to 1) // #3, to with cast - ok
mapOf<Foo, Int>(Foo.Bar to 1) // #4, to without cast - Unresolved reference 'to'
}Marat Akhin
08/13/2026, 10:31 AM