hmm, is this the correct behavior of the compiler?...
# compiler
s
hmm, is this the correct behavior of the compiler? (playground)
Copy code
sealed 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'
}
m
Yes, that's precisely this
👍 1