From c4d65544932b214f8f50eefa9de8b2d442a57438 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 1 Feb 2024 09:38:45 +0100 Subject: [PATCH] K2: reproduce KT-65057 --- ...CompilerTestFE10TestdataTestGenerated.java | 6 ++++ ...sticCompilerFE10TestDataTestGenerated.java | 6 ++++ ...eeOldFrontendDiagnosticsTestGenerated.java | 6 ++++ ...siOldFrontendDiagnosticsTestGenerated.java | 6 ++++ .../complexTypeUnwrapping.fir.txt | 29 ++++++++++++++++ .../recursiveTypes/complexTypeUnwrapping.kt | 19 +++++++++++ .../recursiveTypes/complexTypeUnwrapping.txt | 33 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++++ 8 files changed, 111 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.fir.txt create mode 100644 compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt create mode 100644 compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.txt 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 06c54703b23..7be124c467a 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 @@ -19641,6 +19641,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/recursiveTypes"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("complexTypeUnwrapping.kt") + public void testComplexTypeUnwrapping() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt"); + } + @Test @TestMetadata("kt61717.kt") public void testKt61717() 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 9ae9cfdf357..81ee01406e2 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 @@ -19641,6 +19641,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/recursiveTypes"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("complexTypeUnwrapping.kt") + public void testComplexTypeUnwrapping() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt"); + } + @Test @TestMetadata("kt61717.kt") public void testKt61717() 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 b0741c9a713..e646045f8c0 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 @@ -19635,6 +19635,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/recursiveTypes"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("complexTypeUnwrapping.kt") + public void testComplexTypeUnwrapping() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt"); + } + @Test @TestMetadata("kt61717.kt") public void testKt61717() 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 327bb019fda..055f6576689 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 @@ -19641,6 +19641,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/recursiveTypes"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("complexTypeUnwrapping.kt") + public void testComplexTypeUnwrapping() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt"); + } + @Test @TestMetadata("kt61717.kt") public void testKt61717() throws Exception { diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.fir.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.fir.txt new file mode 100644 index 00000000000..9dc69b8f4bf --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.fir.txt @@ -0,0 +1,29 @@ +FILE: complexTypeUnwrapping.kt + public abstract class AbstractField|> : R|kotlin/Any| { + public constructor|>(): R|AbstractField| { + super() + } + + } + public abstract class AbstractElement|, EF : R|AbstractField|> : R|kotlin/Any| { + public constructor|, EF : R|AbstractField|>(): R|AbstractElement| { + super() + } + + } + public abstract interface ElementOrRef|, RF : R|AbstractField|> : R|kotlin/Any| { + public abstract val element: R|RE| + public get(): R|RE| + + } + public final fun foo(x: R|ElementOrRef<*, *>|): R|AbstractElement, out AbstractField>, out AbstractField>>, out AbstractField>>>, out AbstractField>>>>| { + ^foo R|/x|.R|SubstitutionOverride| + } + public abstract interface FieldOrRef|> : R|kotlin/Any| { + public abstract val field: R|FF| + public get(): R|FF| + + } + public final fun bar(y: R|FieldOrRef<*>|): R|AbstractField>>>>| { + ^bar R|/y|.R|SubstitutionOverride| + } diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt new file mode 100644 index 00000000000..71b662d7209 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt @@ -0,0 +1,19 @@ +// FIR_IDENTICAL +// ISSUE: KT-65057 +// FIR_DUMP + +abstract class AbstractField> + +abstract class AbstractElement, EF : AbstractField> + +interface ElementOrRef, RF : AbstractField> { + val element: RE +} + +fun foo(x: ElementOrRef<*, *>) = x.element + +interface FieldOrRef> { + val field: FF +} + +fun bar(y: FieldOrRef<*>) = y.field diff --git a/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.txt b/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.txt new file mode 100644 index 00000000000..27bc3e9b903 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.txt @@ -0,0 +1,33 @@ +package + +public fun bar(/*0*/ y: FieldOrRef<*>): AbstractField<*> +public fun foo(/*0*/ x: ElementOrRef<*, *>): AbstractElement<*, *> + +public abstract class AbstractElement, /*1*/ EF : AbstractField> { + public constructor AbstractElement, /*1*/ EF : AbstractField>() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public abstract class AbstractField> { + public constructor AbstractField>() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface ElementOrRef, /*1*/ RF : AbstractField> { + public abstract val element: RE + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface FieldOrRef> { + public abstract val field: FF + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + 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 f09f87d6a51..bb1433acff6 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 @@ -19641,6 +19641,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/recursiveTypes"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("complexTypeUnwrapping.kt") + public void testComplexTypeUnwrapping() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes/complexTypeUnwrapping.kt"); + } + @Test @TestMetadata("kt61717.kt") public void testKt61717() throws Exception {