Isn't worth for you init in lazy block? ( I didn't...
# getting-started
b
Isn't worth for you init in lazy block? ( I didn't test this solution )
Copy code
class ExampleClass(private val targetClass: KClass<*>, private val solution: KCallable<*>) {

    private val studentMethod by lazy {
        var methodFinding: KCallable<*>? = null
        for (m: KCallable<*> in targetClass.declaredMembers) {
            if (m.name == solution.name && (methodFinding == null || validateParameterTypes(m))) {
                methodFinding = m
            }
        }
        methodFinding
    }

    private fun validateParameterTypes(m: KCallable<*>): Boolean { ... }
}
j
I tried
by lazy
, but got this error:
Copy code
Kotlin: Smart cast to 'KCallable<*>' is impossible, because 'studentMethod' is a property that has open or custom getter