svenjacobs
01/23/2023, 10:16 AMBoolean
type. I’m using a Java API which defines two functions: void setSomething(boolean enabled)
and void setSomething(Boolean enabled)
, where Boolean
is java.lang.Boolean
here. The first function with the primitive Java type is marked deprecated. I’m trying to call the second function from Kotlin code but every time Kotlin tries to unbox the boolean into the primitive type, so it calls the deprecated function. How can I force Kotlin to use the boxed object type?
For example I tried
api.setSomething(Boolean.valueOf(true))
but it’s still complaining.Vampire
01/23/2023, 10:19 AMtrue as java.lang.Boolean
?svenjacobs
01/23/2023, 10:20 AMRequired: kotlin.Boolean
Found: java.lang.Boolean
true as Boolean
is just marked as an obsolete cast, still tries to call the deprecated function.Vampire
01/23/2023, 10:22 AMtrue as Boolean?
?svenjacobs
01/23/2023, 10:23 AM