diff --git a/compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.kt b/compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.kt new file mode 100644 index 00000000000..797f42d4a2e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.kt @@ -0,0 +1,21 @@ +class Outer { + inner class Inner +} + +class Boxed { + fun substitute() = Outer().Inner() +} + +fun accept(p: Outer.Inner) {} + +val rr = Outer().Inner() +val rrq = Boxed().substitute() + +fun check() { + accept(Outer().Inner()) // illegal + accept(Outer().Inner()) // illegal + accept(Outer().Inner()) // ok + + accept(Boxed().substitute()) // illegal + accept(Boxed().substitute()) // ok +} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.txt b/compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.txt new file mode 100644 index 00000000000..829076c5c13 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.txt @@ -0,0 +1,37 @@ +FILE: innerTypes.kt + public final class Outer : R|kotlin/Any| { + public constructor(): R|Outer| { + super() + } + + public final inner class Inner : R|kotlin/Any| { + public constructor(): R|Outer.Inner| { + super() + } + + } + + } + public final class Boxed : R|kotlin/Any| { + public constructor(): R|Boxed| { + super() + } + + public final fun substitute(): R|Outer.Inner| { + ^substitute R|/Outer.Outer|().R|/Outer.Inner.Inner|() + } + + } + public final fun accept(p: R|Outer.Inner|): R|kotlin/Unit| { + } + public final val rr: R|Outer.Inner| = R|/Outer.Outer|().R|/Outer.Inner.Inner|() + public get(): R|Outer.Inner| + public final val rrq: R|Outer.Inner| = R|/Boxed.Boxed|().R|FakeOverride|>|() + public get(): R|Outer.Inner| + public final fun check(): R|kotlin/Unit| { + #(R|/Outer.Outer|().R|/Outer.Inner.Inner|()) + #(R|/Outer.Outer|().R|/Outer.Inner.Inner|()) + R|/accept|(R|/Outer.Outer|().R|/Outer.Inner.Inner|()) + #(R|/Boxed.Boxed|().R|FakeOverride|>|()) + R|/accept|(R|/Boxed.Boxed|().R|FakeOverride|>|()) + } 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 de6184350ae..c40884f1de5 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 @@ -1495,6 +1495,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/nested/inner.kt"); } + @TestMetadata("innerTypes.kt") + public void testInnerTypes() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/nested/simple.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 f0825c9ee42..209ca256894 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 @@ -1495,6 +1495,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/nested/inner.kt"); } + @TestMetadata("innerTypes.kt") + public void testInnerTypes() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/nested/innerTypes.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/nested/simple.kt");