From 1137e61fc8d95fcbe82e378cf3ac698d78305178 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 26 Jan 2022 15:48:34 +0300 Subject: [PATCH] FIR: add test for KT-50969 --- ...nosisCompilerFirTestdataTestGenerated.java | 6 ++++ .../problems/immutableName.fir.txt | 28 +++++++++++++++ .../problems/immutableName.kt | 36 +++++++++++++++++++ .../problems/immutableName.overrides.txt | 14 ++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 ++++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 ++++ 6 files changed, 96 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.kt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.overrides.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java index 1c63cfbac43..1fe9959c18e 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java @@ -5807,6 +5807,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/EnumMapGet.kt"); } + @Test + @TestMetadata("immutableName.kt") + public void testImmutableName() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.kt"); + } + @Test @TestMetadata("invokePriority.kt") public void testInvokePriority() throws Exception { diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.fir.txt new file mode 100644 index 00000000000..4bb67b4a8b5 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.fir.txt @@ -0,0 +1,28 @@ +FILE: Impl.kt + public abstract class Impl : R|Base| { + public constructor(): R|Impl| { + super() + } + + public open override fun foo(name: R|kotlin/String|): R|Base| { + ^foo this@R|/Impl| + } + + } +FILE: test.kt + public abstract class ImplDerived : R|Impl|, R|Derived| { + public constructor(): R|ImplDerived| { + super() + } + + public abstract override fun foo(name: R|kotlin/String?|): R|Derived| + + } + public abstract class DerivedImpl : R|Derived|, R|Impl| { + public constructor(): R|DerivedImpl| { + super() + } + + public abstract override fun foo(name: R|kotlin/String?|): R|Derived| + + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.kt new file mode 100644 index 00000000000..26321e60d20 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.kt @@ -0,0 +1,36 @@ +// SCOPE_DUMP: ImplDerived:foo, DerivedImpl:foo +// FILE: Base.java + +import org.jetbrains.annotations.NotNull; + +public interface Base { + Base foo(@NotNull String name); +} + +// FILE: Derived.java + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface Derived extends Base { + @Override + @NotNull Derived foo(@Nullable String name); +} + +// FILE: Impl.kt + +abstract class Impl : Base { + override fun foo(name: String): Base { + return this + } +} + +// FILE: test.kt + +abstract class ImplDerived : Impl(), Derived { + abstract override fun foo(name: String?): Derived +} + +abstract class DerivedImpl : Derived, Impl() { + abstract override fun foo(name: String?): Derived +} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.overrides.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.overrides.txt new file mode 100644 index 00000000000..9a453e0fd81 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.overrides.txt @@ -0,0 +1,14 @@ +ImplDerived: + [Source]: public abstract override fun foo(name: R|kotlin/String?|): R|Derived| from Use site scope of /ImplDerived [id: 0] + [IntersectionOverride]: public open fun foo(name: R|ft|): R|@EnhancedNullability Derived| from Use site scope of /ImplDerived [id: 0] + [Source]: public open override fun foo(name: R|kotlin/String|): R|Base| from Use site scope of /Impl [id: 1] + [Enhancement]: public abstract fun foo(name: R|@EnhancedNullability kotlin/String|): R|ft| from Java enhancement scope for /Base [id: 2] + [Enhancement]: public abstract fun foo(name: R|ft|): R|@EnhancedNullability Derived| from Java enhancement scope for /Derived [id: 3] + [Enhancement]: public abstract fun foo(name: R|@EnhancedNullability kotlin/String|): R|ft| from Java enhancement scope for /Base [id: 2] + +DerivedImpl: + [Source]: public abstract override fun foo(name: R|kotlin/String?|): R|Derived| from Use site scope of /DerivedImpl [id: 0] + [Enhancement]: public abstract fun foo(name: R|ft|): R|@EnhancedNullability Derived| from Java enhancement scope for /Derived [id: 1] + [Enhancement]: public abstract fun foo(name: R|@EnhancedNullability kotlin/String|): R|ft| from Java enhancement scope for /Base [id: 2] + [Source]: public open override fun foo(name: R|kotlin/String|): R|Base| from Use site scope of /Impl [id: 3] + [Enhancement]: public abstract fun foo(name: R|@EnhancedNullability kotlin/String|): R|ft| from Java enhancement scope for /Base [id: 2] 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 91e02166ccb..e07b4829ada 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 @@ -5807,6 +5807,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/EnumMapGet.kt"); } + @Test + @TestMetadata("immutableName.kt") + public void testImmutableName() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.kt"); + } + @Test @TestMetadata("invokePriority.kt") public void testInvokePriority() 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 52150be6bda..51cbe853ec9 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 @@ -5807,6 +5807,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/EnumMapGet.kt"); } + @Test + @TestMetadata("immutableName.kt") + public void testImmutableName() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/immutableName.kt"); + } + @Test @TestMetadata("invokePriority.kt") public void testInvokePriority() throws Exception {