[NI] Resolve receiver of provideDelegate independently

#KT-38259 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-04-28 03:28:08 +03:00
parent 59f027e3e9
commit 2cee82a348
25 changed files with 211 additions and 53 deletions
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
import kotlin.reflect.KProperty
interface DelegateProvider<out T> {
operator fun provideDelegate(receiver: Any?, prop: kotlin.reflect.KProperty<*>): Lazy<T>
}
fun <Value : Any> delegate(): DelegateProvider<Value> = object : DelegateProvider<Value> {
override fun provideDelegate(receiver: Any?, prop: KProperty<*>): Lazy<Value> {
return lazy { "OK" } as Lazy<Value>
}
}
fun box(): String {
val value: String by delegate()
return value
}