class Abc
class Obj{
private val props = HashMap<String, Any>()inline fun <reified T> invoke():T = props.values().first { it is T } as T
}
fun main(args: Array<String>) {
val obj = Obj()
println(obj<Abc>())
}
Output:
Exception in thread “main” java.lang.IllegalAccessError: tried to access field rule2.Obj.props from class rule2.Rule2Package$Main$c9203aaa
This is runtime err. I suggest compiletime err.