https://kotlinlang.org logo
#reflect
Title
# reflect
s

snowe

07/17/2018, 5:02 PM
How do I check if a member is of a nullable class
s

snowe

07/17/2018, 7:16 PM
you seem to have missed the code I posted. I can't use
isMarkedNullable
because I have to check the class type.
Though I figured it out. You have to use
.starProjectedType
and then
withNullability(true)
d

diesieben07

07/17/2018, 7:17 PM
I did not miss your code.
it.returnType
is of type
KType
. Just call
isMarkedNullable
on that.
s

snowe

07/17/2018, 8:43 PM
isMarkedNullable returns Boolean, not the KType. I cannot compare the type then.
d

diesieben07

07/18/2018, 8:49 AM
it.isMarkedNullabe && it.classifier == YourClass::class
checks for
YourClass?
.
3 Views