From f0f06ccf2ed1106d7134fd9b2bf603a2da514d8c Mon Sep 17 00:00:00 2001 From: "marat.akhin" Date: Tue, 21 Nov 2023 18:04:35 +0100 Subject: [PATCH] [tests] Add tests for conflicting overloads + hidden between open/final --- ...CompilerTestFE10TestdataTestGenerated.java | 12 ++++++++ ...sticCompilerFE10TestDataTestGenerated.java | 12 ++++++++ ...eeOldFrontendDiagnosticsTestGenerated.java | 12 ++++++++ ...siOldFrontendDiagnosticsTestGenerated.java | 12 ++++++++ ...OverloadsFunsDifferentReturnInClass.fir.kt | 20 +++++++++++++ ...tingOverloadsFunsDifferentReturnInClass.kt | 20 +++++++++++++ ...ingOverloadsFunsDifferentReturnInClass.txt | 29 +++++++++++++++++++ ...ictingOverloadsIdenticalFunsInClass.fir.kt | 23 +++++++++++++++ ...onflictingOverloadsIdenticalFunsInClass.kt | 23 +++++++++++++++ ...nflictingOverloadsIdenticalFunsInClass.txt | 29 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 12 ++++++++ 11 files changed, 204 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt create mode 100644 compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt create mode 100644 compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.txt create mode 100644 compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.fir.kt create mode 100644 compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt create mode 100644 compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.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 fe7a1bd9d3a..164000e13f3 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 @@ -27207,6 +27207,18 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + @Test @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") public void testConflictingOverloadsIdenticalValsInClass() 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 537c7d00f8b..fedabc15083 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 @@ -27207,6 +27207,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + @Test @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") public void testConflictingOverloadsIdenticalValsInClass() 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 48bd0428b4f..e84d91a5ea8 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 @@ -25141,6 +25141,18 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + @Test @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") public void testConflictingOverloadsIdenticalValsInClass() 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 a4bd86e5c9b..bf25341699a 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 @@ -25147,6 +25147,18 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + @Test @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") public void testConflictingOverloadsIdenticalValsInClass() throws Exception { diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt new file mode 100644 index 00000000000..fc41471847f --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt @@ -0,0 +1,20 @@ +class A { + fun a(a: Int): Int = 0 + + @Deprecated("a", level = DeprecationLevel.HIDDEN) fun a(a: Int) { + } +} + +open class B { + open fun a(a: Int): Int = 0 + + @Deprecated("a", level = DeprecationLevel.HIDDEN) fun a(a: Int) { + } +} + +open class C { + fun a(a: Int): Int = 0 + + @Deprecated("a", level = DeprecationLevel.HIDDEN) open fun a(a: Int) { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt new file mode 100644 index 00000000000..57002f0c088 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt @@ -0,0 +1,20 @@ +class A { + fun a(a: Int): Int = 0 + + @Deprecated("a", level = DeprecationLevel.HIDDEN) fun a(a: Int) { + } +} + +open class B { + open fun a(a: Int): Int = 0 + + @Deprecated("a", level = DeprecationLevel.HIDDEN) fun a(a: Int) { + } +} + +open class C { + fun a(a: Int): Int = 0 + + @Deprecated("a", level = DeprecationLevel.HIDDEN) open fun a(a: Int) { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.txt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.txt new file mode 100644 index 00000000000..8d372e6b1dd --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.txt @@ -0,0 +1,29 @@ +package + +public final class A { + public constructor A() + @kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "a") public final fun a(/*0*/ a: kotlin.Int): kotlin.Unit + public final fun a(/*0*/ a: kotlin.Int): kotlin.Int + 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 open class B { + public constructor B() + @kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "a") public final fun a(/*0*/ a: kotlin.Int): kotlin.Unit + public open fun a(/*0*/ a: kotlin.Int): kotlin.Int + 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 open class C { + public constructor C() + @kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "a") public open fun a(/*0*/ a: kotlin.Int): kotlin.Unit + public final fun a(/*0*/ a: kotlin.Int): kotlin.Int + 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/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.fir.kt new file mode 100644 index 00000000000..911a5c3d5b1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.fir.kt @@ -0,0 +1,23 @@ +class A() { + fun b() { + } + + @Deprecated("a", level = DeprecationLevel.HIDDEN) fun b() { + } +} + +open class B() { + open fun b() { + } + + @Deprecated("a", level = DeprecationLevel.HIDDEN) fun b() { + } +} + +open class C() { + fun b() { + } + + @Deprecated("a", level = DeprecationLevel.HIDDEN) open fun b() { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt new file mode 100644 index 00000000000..58bcdcbe9b3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt @@ -0,0 +1,23 @@ +class A() { + fun b() { + } + + @Deprecated("a", level = DeprecationLevel.HIDDEN) fun b() { + } +} + +open class B() { + open fun b() { + } + + @Deprecated("a", level = DeprecationLevel.HIDDEN) fun b() { + } +} + +open class C() { + fun b() { + } + + @Deprecated("a", level = DeprecationLevel.HIDDEN) open fun b() { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.txt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.txt new file mode 100644 index 00000000000..9d9dc558dab --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.txt @@ -0,0 +1,29 @@ +package + +public final class A { + public constructor A() + @kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "a") public final fun b(): kotlin.Unit + public final fun b(): kotlin.Unit + 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 open class B { + public constructor B() + @kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "a") public final fun b(): kotlin.Unit + public open fun b(): kotlin.Unit + 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 open class C { + public constructor C() + @kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "a") public open fun b(): kotlin.Unit + public final fun b(): kotlin.Unit + 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 ff4b7d15fe2..2fff4934c09 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 @@ -27207,6 +27207,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecatedHidden/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + @Test @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") public void testConflictingOverloadsIdenticalValsInClass() throws Exception {