diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.fir.txt new file mode 100644 index 00000000000..5ec004ee783 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.fir.txt @@ -0,0 +1,50 @@ +FILE: kt41917.kt + public final class DummyDelegate : R|kotlin/Any| { + public constructor(s: R|V|): R|DummyDelegate| { + super() + } + + public final val s: R|V| = R|/s| + public get(): R|V| + + public final operator fun getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V| { + ^getValue this@R|/DummyDelegate|.R|/DummyDelegate.s| + } + + } + public final fun testImplicit(c: R|C|): R|kotlin/Int| { + ^testImplicit R|/c|.R|/A.implicit|.R|kotlin/String.length| + } + public final fun testExplicit(c: R|C|): R|kotlin/Int| { + ^testExplicit R|/c|.R|/A.explicit|.R|kotlin/String.length| + } + public open class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public final val implicit: R|kotlin/String|by R|/DummyDelegate.DummyDelegate|(String(hello)) + public get(): R|kotlin/String| { + ^ this@R|/A|.D|/A.implicit|.R|SubstitutionOverride|(this@R|/A|, ::R|/A.implicit|) + } + + public final val explicit: R|kotlin/String|by R|/DummyDelegate.DummyDelegate|(String(hello)) + public get(): R|kotlin/String| { + ^ this@R|/A|.D|/A.explicit|.R|SubstitutionOverride|(this@R|/A|, ::R|/A.explicit|) + } + + } + public abstract interface B : R|kotlin/Any| { + public abstract val implicit: R|kotlin/String| + public get(): R|kotlin/String| + + public abstract val explicit: R|kotlin/String| + public get(): R|kotlin/String| + + } + public final class C : R|A|, R|B| { + public constructor(): R|C| { + super() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt new file mode 100644 index 00000000000..4c5e43101f1 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt @@ -0,0 +1,23 @@ +import kotlin.reflect.KProperty + +class DummyDelegate(val s: V) { + operator fun getValue(thisRef: Any?, property: KProperty<*>): V { + return s + } +} + +fun testImplicit(c: C) = c.implicit.length // (1) +fun testExplicit(c: C) = c.explicit.length + +open class A { + val implicit by DummyDelegate("hello") + + val explicit: String by DummyDelegate("hello") +} + +interface B { + val implicit: String + val explicit: String +} + +class C : A(), B diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index d37a0c193b4..26d06adcd89 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -4613,6 +4613,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.kt"); } + @Test + @TestMetadata("kt41917.kt") + public void testKt41917() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt"); + } + @Test @TestMetadata("propertyWithFunctionalType.kt") public void testPropertyWithFunctionalType() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 833c3109e8f..739203e8fc7 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -4680,6 +4680,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.kt"); } + @Test + @TestMetadata("kt41917.kt") + public void testKt41917() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt"); + } + @Test @TestMetadata("propertyWithFunctionalType.kt") public void testPropertyWithFunctionalType() throws Exception {