Determine if KCallable returnType is Boolean without calling?


#1

(e is KCallable)

when (element.returnType) {
    is kotlin.Number -> Unit
    is kotlin.Boolean -> Unit
}

This doesn’t compile (“Incompatible types: KType and Boolean”). How can I determine at runtime if element returns a Boolean without calling it?


#2

Figured it out:

e.returnType.classifier == Boolean::class