From ede910065a1f59cb8e8e645e91bffd90cfe2b581 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 26 Aug 2020 15:08:21 +0300 Subject: [PATCH] [FIR] Add problematic resolve test case with delegated super call --- .../diagnostics/superCallWithDelegation.kt | 12 +++++++++ .../diagnostics/superCallWithDelegation.txt | 27 +++++++++++++++++++ .../fir/FirDiagnosticsTestGenerated.java | 5 ++++ ...DiagnosticsWithLightTreeTestGenerated.java | 5 ++++ 4 files changed, 49 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.txt diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.kt new file mode 100644 index 00000000000..738ae9e1bd5 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.kt @@ -0,0 +1,12 @@ +interface A { + fun foo() +} + +open class B(private val a: A) : A by a + +class C(a: A) : B(a) { + override fun foo() { + // Should be resolved to delegated B.foo (no error) + super.foo() + } +} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.txt new file mode 100644 index 00000000000..728990c69a9 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.txt @@ -0,0 +1,27 @@ +FILE: superCallWithDelegation.kt + public abstract interface A : R|kotlin/Any| { + public abstract fun foo(): R|kotlin/Unit| + + } + public open class B : R|A| { + local final field <$$delegate_0>: R|A| + + public constructor(a: R|A|): R|B| { + super() + this@R|/B|.R|/<$$delegate_0>| = R|/a| + } + + private final val a: R|A| = R|/a| + private get(): R|A| + + } + public final class C : R|B| { + public constructor(a: R|A|): R|C| { + super(R|/a|) + } + + public final override fun foo(): R|kotlin/Unit| { + this@R|/C|.super.R|/A.foo|() + } + + } diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 9c134186188..3d3cc0025db 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -1061,6 +1061,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/someOverridesTest.kt"); } + @TestMetadata("superCallWithDelegation.kt") + public void testSuperCallWithDelegation() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.kt"); + } + @TestMetadata("superIsNotAnExpression.kt") public void testSuperIsNotAnExpression() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt"); diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index c15d9e0fb55..6d0ca273b29 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -1061,6 +1061,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/someOverridesTest.kt"); } + @TestMetadata("superCallWithDelegation.kt") + public void testSuperCallWithDelegation() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/superCallWithDelegation.kt"); + } + @TestMetadata("superIsNotAnExpression.kt") public void testSuperIsNotAnExpression() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt");