From 8c475750b1cfb7f30f9cbfd2a19aeb4ece792cfe Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 14 Sep 2022 09:29:25 +0200 Subject: [PATCH] FE: add test for KT-47473 --- ...CompilerTestFE10TestdataTestGenerated.java | 6 +++++ ...irOldFrontendDiagnosticsTestGenerated.java | 6 +++++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 +++++ .../typealias/upperBoundViolated.fir.kt | 10 +++++++++ .../typealias/upperBoundViolated.kt | 10 +++++++++ .../typealias/upperBoundViolated.txt | 22 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 +++++ 7 files changed, 66 insertions(+) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 4ecd1ba591a..da3ee7dfa3e 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -39181,6 +39181,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag public void testTypeAliasSamAdapterConstructors2() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/typealias/typeAliasSamAdapterConstructors2.kt"); } + + @Test + @TestMetadata("upperBoundViolated.kt") + public void testUpperBoundViolated() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 4b147faa937..5ddba88c5ab 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -39245,6 +39245,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti public void testTypeAliasSamAdapterConstructors2() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/typealias/typeAliasSamAdapterConstructors2.kt"); } + + @Test + @TestMetadata("upperBoundViolated.kt") + public void testUpperBoundViolated() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 3a82f486943..5e5904e3b4f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -39245,6 +39245,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac public void testTypeAliasSamAdapterConstructors2() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/typealias/typeAliasSamAdapterConstructors2.kt"); } + + @Test + @TestMetadata("upperBoundViolated.kt") + public void testUpperBoundViolated() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.kt"); + } } @Nested diff --git a/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.fir.kt new file mode 100644 index 00000000000..1bb653be4b2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.fir.kt @@ -0,0 +1,10 @@ +class NumColl> +typealias NumList = NumColl> +typealias AliasOfNumList = NumList + +val falseUpperBoundViolation = AliasOfNumList() // Shouldn't be error +val missedUpperBoundViolation = NumList() // Should be error + +class Base> +typealias Alias = Base> +val a = Alias() // Also should be error diff --git a/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.kt b/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.kt new file mode 100644 index 00000000000..7ba80419c8b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.kt @@ -0,0 +1,10 @@ +class NumColl> +typealias NumList = NumColl> +typealias AliasOfNumList = NumList + +val falseUpperBoundViolation = AliasOfNumList<Int>() // Shouldn't be error +val missedUpperBoundViolation = NumList() // Should be error + +class Base> +typealias Alias = Base> +val a = Alias() // Also should be error \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.txt b/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.txt new file mode 100644 index 00000000000..2752d490a61 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.txt @@ -0,0 +1,22 @@ +package + +public val a: Alias /* = Base> */ +public val falseUpperBoundViolation: AliasOfNumList /* = NumColl> */ +public val missedUpperBoundViolation: NumList /* = NumColl> */ + +public final class Base> { + public constructor Base>() + 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 final class NumColl> { + public constructor NumColl>() + 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 typealias Alias = Base> +public typealias AliasOfNumList = NumList +public typealias NumList = NumColl> 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 45cff0dd534..625ff5964cd 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 @@ -39335,6 +39335,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testTypeAliasSamAdapterConstructors2() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/typealias/typeAliasSamAdapterConstructors2.kt"); } + + @Test + @TestMetadata("upperBoundViolated.kt") + public void testUpperBoundViolated() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/typealias/upperBoundViolated.kt"); + } } @Nested