Files
kotlin-fork/compiler/testData/codegen/box/delegatedProperty/provideDelegate/provideDelegateByExtensionFunction.kt
T
Denis.Zharkov 78ec4b5248 FIR: Mute property-delegation-inference related tests
They started failing once we began reporting diagnostics from completion
The main reason is that we resolve `delegate()` call
from `delegate().getValue()` in the independent context, while in FE 1.0
it's being resolved within the same system as getValue

^KT-46420 Relates
2021-05-20 17:24:15 +03:00

30 lines
773 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
import kotlin.reflect.KProperty
class TypeInference {
val explicitTypes by providerFun<TypeInference, String>()
val withoutTypes: String by providerFun()
}
class Inv<T>(val x: T)
fun <T, R> T.providerFun() = object : DelegateProvider<T, R>() {
override fun provideDelegate(thisRef: T, property: KProperty<*>): Inv<R> {
return Inv("OK") as Inv<R>
}
}
operator fun <T> Inv<T>.getValue(thisRef: Any?, property: KProperty<*>): T = x
abstract class DelegateProvider<T, R> {
abstract operator fun provideDelegate(
thisRef: T,
property: KProperty<*>
): Inv<R>
}
fun box(): String {
val t = TypeInference()
if (t.explicitTypes != t.withoutTypes) return "fail 1"
return t.withoutTypes
}