Paul Griffith
09/28/2022, 5:20 PM@Nonnull
?Casey Brooks
09/28/2022, 5:55 PM@Nonnull
is basically declaring that it will throw an NPE if that variable is null. So you could just use !!
on what you’re passing in and get that same exception from Kotlin before passing it into the Java code, I guess.
You could also try casting the nullable Kotlin type into the non-null type. Since there’s no runtime distinction between the two types, and you’re passing the variable directly into a Java method, it might workephemient
09/28/2022, 5:57 PMephemient
09/28/2022, 5:59 PMfun <T> uncheckedNull(): T = null as T
as a hack, I think you can use this as an argument and Kotlin won't (currently) check itPaul Griffith
09/28/2022, 6:03 PMPaul Griffith
09/28/2022, 6:04 PMPaul Griffith
09/28/2022, 6:04 PMRoukanken
09/28/2022, 6:18 PMilya.gorbunov
09/30/2022, 12:00 PMuncheckedNull
will continue to work as it violates the Kotlin type system, see KT-8235 for details.