ensureType

inline fun <T : Any> ensureType(obj: Any?, functionName: String): T

Checks that obj is a T, and says which function complained if it is not.