https://kotlinlang.org logo
#announcements
Title
# announcements
d

diesieben07

09/22/2017, 8:46 PM
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

ilya.gorbunov

09/22/2017, 8:49 PM
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

diesieben07

09/22/2017, 8:50 PM
That makes sense, actually. Now that you mention it this sounds more and more like a bug