You can actually do this in Kotlin: ``` fun <T&...
# announcements
d
You can actually do this in Kotlin:
Copy code
fun <T> castUnsafe(input: Any?) = input as T
// later:
thisMethodHasNonNullParameter(castUnsafe(null))
Will compile and fail at runtime with
IllegalArgumentException
thrown from
thisMethodHasNonNullParameter
.
i
I wouldn't count on that. At some point it might become throwing right after returning from castUnsafe, see https://youtrack.jetbrains.com/issue/KT-8135
d
That makes sense, actually. Now that you mention it this sounds more and more like a bug