I find curious that this code works ```fun <T&g...
# compiler
d
I find curious that this code works
Copy code
fun <T> getClass(type: T): Class<out T> {
    if (type != null) {
        return getClass(type)
    } else {
        error("Unexpected")
    }
}
private fun <T: Any> getClass(type: T) = type::class.java
but if I inline the second method
Copy code
fun <T> getClass(type: T): Class<out T> {
    if (type != null) {
        return type::class.java // Compilation error
    } else {
        error("Unexpected")
    }
}
the smart cast fails
Copy code
Expression in a class literal has a nullable type 'T', use !! to make the type non-nullable
s
d
indeed