'by lazy' for KClass missing delegate function


the following code:

private var _testClass: KClass<*>? by lazy { Foo::class }

gives me a compiler error:

[DELEGATE_SPECIAL_FUNCTION_MISSING] Missing setValue method on Lazy<KClass<Foo::class>>

i tried to create the delegate:

private operator fun <T> Lazy<T>.setValue(companion: Configuration.Companion, property: KProperty<T?>, kClass: KClass<Any>?) {}

but i get an error on the 2nd param:

[INAPPLICABLE_OPERATOR_MODIFIER] ... 2nd parameter must be of type KProperty<*> ...

does anyone happen to have the delegate function handy?


The property must be inmutable:

private val _testClass: KClass<*>? by lazy { Foo::class }



“the property must be immutable” would make a great error message Mr. Compiler!