From 99ff36c77a7a430cee82b3f29570256cadd2519a Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Wed, 10 May 2023 14:58:36 +0300 Subject: [PATCH] [FIR] KT-58523: Ensure the compiler resolves to the typealias --- ...cCompilerTestFE10TestdataTestGenerated.java | 6 ++++++ ...osticCompilerFE10TestDataTestGenerated.java | 6 ++++++ ...reeOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ ...PsiOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ ...solutionToTypealiasInsteadOfProperty.fir.kt | 18 ++++++++++++++++++ .../resolutionToTypealiasInsteadOfProperty.kt | 18 ++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++++++ 7 files changed, 66 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.fir.kt create mode 100644 compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index c6568d4cdce..2de9193015d 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -909,6 +909,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/ReserveYieldNoMore2.kt"); } + @Test + @TestMetadata("resolutionToTypealiasInsteadOfProperty.kt") + public void testResolutionToTypealiasInsteadOfProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt"); + } + @Test @TestMetadata("ResolveOfJavaGenerics.kt") public void testResolveOfJavaGenerics() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index 822391b2a39..5f06351a449 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -909,6 +909,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/ReserveYieldNoMore2.kt"); } + @Test + @TestMetadata("resolutionToTypealiasInsteadOfProperty.kt") + public void testResolutionToTypealiasInsteadOfProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt"); + } + @Test @TestMetadata("ResolveOfJavaGenerics.kt") public void testResolveOfJavaGenerics() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 6d73e430e77..53f5d868872 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -909,6 +909,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/ReserveYieldNoMore2.kt"); } + @Test + @TestMetadata("resolutionToTypealiasInsteadOfProperty.kt") + public void testResolutionToTypealiasInsteadOfProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt"); + } + @Test @TestMetadata("ResolveOfJavaGenerics.kt") public void testResolveOfJavaGenerics() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 953fd5c7731..4b014f0d10d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -909,6 +909,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/ReserveYieldNoMore2.kt"); } + @Test + @TestMetadata("resolutionToTypealiasInsteadOfProperty.kt") + public void testResolutionToTypealiasInsteadOfProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt"); + } + @Test @TestMetadata("ResolveOfJavaGenerics.kt") public void testResolveOfJavaGenerics() throws Exception { diff --git a/compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.fir.kt b/compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.fir.kt new file mode 100644 index 00000000000..c2040427ce4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.fir.kt @@ -0,0 +1,18 @@ +// ISSUE: KT-58523 + +// FILE: pkg.kt + +package pkg + +class Klass +typealias ItemKey = Klass + +// FILE: main.kt + +import pkg.ItemKey + +val ItemKey = 42 + +fun main() { + ItemKey // K1: ok, K2: NO_COMPANION_OBJECT +} diff --git a/compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt b/compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt new file mode 100644 index 00000000000..c0563cc0dbc --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt @@ -0,0 +1,18 @@ +// ISSUE: KT-58523 + +// FILE: pkg.kt + +package pkg + +class Klass +typealias ItemKey = Klass + +// FILE: main.kt + +import pkg.ItemKey + +val ItemKey = 42 + +fun main() { + ItemKey // K1: ok, K2: NO_COMPANION_OBJECT +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index d0b27c0197f..38324240fa6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -909,6 +909,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/ReserveYieldNoMore2.kt"); } + @Test + @TestMetadata("resolutionToTypealiasInsteadOfProperty.kt") + public void testResolutionToTypealiasInsteadOfProperty() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolutionToTypealiasInsteadOfProperty.kt"); + } + @Test @TestMetadata("ResolveOfJavaGenerics.kt") public void testResolveOfJavaGenerics() throws Exception {