From 55f9f74d5cf7e8bd304104b82e28e8ade89eee17 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 11 Mar 2024 22:22:03 +0100 Subject: [PATCH] Tests: do not report backend diagnostics if there's frontend error In most affected tests, the backend diagnostic such as "conflicting JVM signature" or "accidental override" is directly caused by some already existing error reported by frontend, so it doesn't make sense to check backend diagnostics there. Tests where that was not the case were moved/copied to `testsWithJvmBackend`. --- ...CompilerTestFE10TestdataTestGenerated.java | 6 -- ...sticCompilerFE10TestDataTestGenerated.java | 6 -- ...eeOldFrontendDiagnosticsTestGenerated.java | 6 -- ...siOldFrontendDiagnosticsTestGenerated.java | 6 -- ...gnosticsTestWithJvmIrBackendGenerated.java | 50 +++++++++++++ ...gnosticsTestWithJvmIrBackendGenerated.java | 50 +++++++++++++ .../tests/TraitOverrideObjectMethods.kt | 2 +- .../nonParenthesizedAnnotationsWithError.kt | 2 +- .../dataClasses/conflictingCopyOverloads.kt | 4 +- .../tests/dataClasses/conflictingOverloads.kt | 4 +- ...ClassExplicitlyOverridingCopyNoDefaults.kt | 4 +- ...assExplicitlyOverridingCopyWithDefaults.kt | 4 +- .../inlineClassDeclarationCheck.kt | 2 +- .../containsAndOverload.kt | 4 +- .../tests/j+k/kjkImplicitReturnType.fir.kt | 63 ---------------- .../tests/j+k/kjkImplicitReturnType.kt | 5 +- ...nflictingOlverloadsGenericFunctions.fir.kt | 34 --------- .../ConflictingOlverloadsGenericFunctions.kt | 27 +++---- .../diagnostics/tests/override/Generics.kt | 10 +-- ...JavaClassWithRawTypeInOverrideSignature.kt | 2 +- ...ertypeDifferentParameterNullability.fir.kt | 33 --------- .../supertypeDifferentParameterNullability.kt | 13 ++-- .../ambiguousSuperWithGenerics.kt | 6 +- .../valueClassDeclarationCheck.fir.kt | 53 -------------- .../valueClassDeclarationCheck.kt | 3 +- .../erasure/genericFunctions.kt | 26 +++++++ ...ricMethodsWithDifferentSubstitution.fir.kt | 29 ++++++++ ...GenericMethodsWithDifferentSubstitution.kt | 29 ++++++++ ...lectionSubclassWithContainsOverload.fir.kt | 11 +++ ...aCollectionSubclassWithContainsOverload.kt | 11 +++ .../supertypeDifferentParameterNullability.kt | 18 +++++ .../conflictsWIthJvmNameInClass.fir.kt} | 27 +++---- .../jvmName/conflictsWIthJvmNameInClass.kt | 54 ++++++++++++++ .../jvmNamesDuplicate.fir.kt | 53 -------------- .../jvmNamesDuplicate.txt | 72 ------------------- .../test/runners/DiagnosticTestGenerated.java | 6 -- ...gnosticsTestWithJvmIrBackendGenerated.java | 50 +++++++++++++ .../handlers/ClassicDiagnosticsHandler.kt | 8 ++- 38 files changed, 396 insertions(+), 397 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/j+k/kjkImplicitReturnType.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/overload/ConflictingOlverloadsGenericFunctions.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/genericFunctions.kt create mode 100644 compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.kt create mode 100644 compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.kt create mode 100644 compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/supertypeDifferentParameterNullability.kt rename compiler/testData/diagnostics/{testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt => testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.fir.kt} (52%) create mode 100644 compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.kt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.fir.kt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.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 6a6f0ae2fb3..d6ccd82ab21 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 @@ -44908,12 +44908,6 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNames.kt"); } - @Test - @TestMetadata("jvmNamesDuplicate.kt") - public void testJvmNamesDuplicate() { - runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt"); - } - @Test @TestMetadata("jvmOverloads.kt") public void testJvmOverloads() { 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 6162edb3d58..cd5f242ce1a 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 @@ -44908,12 +44908,6 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNames.kt"); } - @Test - @TestMetadata("jvmNamesDuplicate.kt") - public void testJvmNamesDuplicate() { - runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt"); - } - @Test @TestMetadata("jvmOverloads.kt") public void testJvmOverloads() { 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 954fc71eab1..202b439d226 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 @@ -42480,12 +42480,6 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNames.kt"); } - @Test - @TestMetadata("jvmNamesDuplicate.kt") - public void testJvmNamesDuplicate() { - runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt"); - } - @Test @TestMetadata("jvmOverloads.kt") public void testJvmOverloads() { 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 c7ce56e974f..d4a176ccdcd 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 @@ -42618,12 +42618,6 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNames.kt"); } - @Test - @TestMetadata("jvmNamesDuplicate.kt") - public void testJvmNamesDuplicate() { - runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt"); - } - @Test @TestMetadata("jvmOverloads.kt") public void testJvmOverloads() { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.java index 58284f41f78..3b75dd8840c 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.java @@ -294,6 +294,12 @@ public class FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated extends Abstra runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/extensionProperties.kt"); } + @Test + @TestMetadata("genericFunctions.kt") + public void testGenericFunctions() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/genericFunctions.kt"); + } + @Test @TestMetadata("genericType.kt") public void testGenericType() { @@ -306,6 +312,12 @@ public class FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated extends Abstra runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritFromTwoTraits.kt"); } + @Test + @TestMetadata("inheritGenericMethodsWithDifferentSubstitution.kt") + public void testInheritGenericMethodsWithDifferentSubstitution() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.kt"); + } + @Test @TestMetadata("kotlinAndJavaCollections.kt") public void testKotlinAndJavaCollections() { @@ -517,6 +529,44 @@ public class FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated extends Abstra } } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop") + @TestDataPath("$PROJECT_ROOT") + public class JavaInterop { + @Test + public void testAllFilesPresentInJavaInterop() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("inheritFromJavaCollectionSubclassWithContainsOverload.kt") + public void testInheritFromJavaCollectionSubclassWithContainsOverload() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.kt"); + } + + @Test + @TestMetadata("supertypeDifferentParameterNullability.kt") + public void testSupertypeDifferentParameterNullability() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/supertypeDifferentParameterNullability.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName") + @TestDataPath("$PROJECT_ROOT") + public class JvmName { + @Test + public void testAllFilesPresentInJvmName() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("conflictsWIthJvmNameInClass.kt") + public void testConflictsWIthJvmNameInClass() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/specialNames") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticsTestWithJvmIrBackendGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticsTestWithJvmIrBackendGenerated.java index 39ea49813d1..0a393a64336 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticsTestWithJvmIrBackendGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticsTestWithJvmIrBackendGenerated.java @@ -294,6 +294,12 @@ public class FirPsiDiagnosticsTestWithJvmIrBackendGenerated extends AbstractFirP runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/extensionProperties.kt"); } + @Test + @TestMetadata("genericFunctions.kt") + public void testGenericFunctions() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/genericFunctions.kt"); + } + @Test @TestMetadata("genericType.kt") public void testGenericType() { @@ -306,6 +312,12 @@ public class FirPsiDiagnosticsTestWithJvmIrBackendGenerated extends AbstractFirP runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritFromTwoTraits.kt"); } + @Test + @TestMetadata("inheritGenericMethodsWithDifferentSubstitution.kt") + public void testInheritGenericMethodsWithDifferentSubstitution() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.kt"); + } + @Test @TestMetadata("kotlinAndJavaCollections.kt") public void testKotlinAndJavaCollections() { @@ -517,6 +529,44 @@ public class FirPsiDiagnosticsTestWithJvmIrBackendGenerated extends AbstractFirP } } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop") + @TestDataPath("$PROJECT_ROOT") + public class JavaInterop { + @Test + public void testAllFilesPresentInJavaInterop() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("inheritFromJavaCollectionSubclassWithContainsOverload.kt") + public void testInheritFromJavaCollectionSubclassWithContainsOverload() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.kt"); + } + + @Test + @TestMetadata("supertypeDifferentParameterNullability.kt") + public void testSupertypeDifferentParameterNullability() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/supertypeDifferentParameterNullability.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName") + @TestDataPath("$PROJECT_ROOT") + public class JvmName { + @Test + public void testAllFilesPresentInJvmName() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("conflictsWIthJvmNameInClass.kt") + public void testConflictsWIthJvmNameInClass() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/specialNames") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/diagnostics/tests/TraitOverrideObjectMethods.kt b/compiler/testData/diagnostics/tests/TraitOverrideObjectMethods.kt index cb7995c1053..1c022c8700a 100644 --- a/compiler/testData/diagnostics/tests/TraitOverrideObjectMethods.kt +++ b/compiler/testData/diagnostics/tests/TraitOverrideObjectMethods.kt @@ -3,5 +3,5 @@ interface MyTrait: Object { override fun toString(): String public override fun finalize() - public override fun wait() + public override fun wait() } diff --git a/compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithError.kt b/compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithError.kt index 7c66e4bf424..1c254c8fd25 100644 --- a/compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithError.kt +++ b/compiler/testData/diagnostics/tests/annotations/functionalTypes/nonParenthesizedAnnotationsWithError.kt @@ -34,7 +34,7 @@ fun foo8(x: Any?) { val x: (@Foo () -> Unit)? = {} } -fun foo9(x: (@Foo () -> Unit)?) = x as Iterable<(@Foo () -> Unit?)?>? +fun foo9(x: (@Foo () -> Unit)?) = x as Iterable<(@Foo () -> Unit?)?>? fun foo10(x: @[Foo] () -> Unit) = x as Iterable<@Foo() () -> Unit>? diff --git a/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.kt b/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.kt index ec9a04b0632..f8d177efac6 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -data class A(val x: Int, val y: String) { +data class A(val x: Int, val y: String) { fun copy(x: Int, y: String) = x fun copy(x: Int, y: String) = A(x, y) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/dataClasses/conflictingOverloads.kt b/compiler/testData/diagnostics/tests/dataClasses/conflictingOverloads.kt index 0afcdaca95e..7f2d3ea85ad 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/conflictingOverloads.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/conflictingOverloads.kt @@ -1,4 +1,4 @@ -data class A(val x: Int, val y: String) { +data class A(val x: Int, val y: String) { fun component1() = 1 fun component2() = 2 -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyNoDefaults.kt b/compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyNoDefaults.kt index 79225b459bf..4f127608288 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyNoDefaults.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyNoDefaults.kt @@ -4,6 +4,6 @@ interface WithCopy { fun copy(str: T): WithCopy } -data class Test(val str: String) : WithCopy { +data class Test(val str: String) : WithCopy { override fun copy(str: String) = Test(str) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyWithDefaults.kt b/compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyWithDefaults.kt index 1935d97c2bc..6adf281fec6 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyWithDefaults.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyWithDefaults.kt @@ -4,6 +4,6 @@ interface WithCopy { fun copy(str: T): WithCopy } -data class Test(val str: String) : WithCopy { +data class Test(val str: String) : WithCopy { override fun copy(str: String = this.str) = Test(str) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.kt b/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.kt index 42ad38b8bf5..f537c08600a 100644 --- a/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.kt +++ b/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.kt @@ -37,4 +37,4 @@ final inline class D0(val x: Int) abstract inline class D2(val x: Int) sealed inline class D3(val x: Int) -inline data class D4(val x: String) +inline data class D4(val x: String) diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAndOverload.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAndOverload.kt index c66a3771b3a..a9284d13e02 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAndOverload.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAndOverload.kt @@ -9,8 +9,8 @@ abstract public class A implements java.util.Collection { } // FILE: main.kt -abstract class KA : A() { - override fun contains(x: String) = false +abstract class KA : A() { + override fun contains(x: String) = false } fun foo(a: A, ka: KA) { diff --git a/compiler/testData/diagnostics/tests/j+k/kjkImplicitReturnType.fir.kt b/compiler/testData/diagnostics/tests/j+k/kjkImplicitReturnType.fir.kt deleted file mode 100644 index ee98a98aa78..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/kjkImplicitReturnType.fir.kt +++ /dev/null @@ -1,63 +0,0 @@ -// ISSUE: KT-66048 -// IGNORE_REVERSED_RESOLVE -// ^KT-66392 - -// FILE: Java1.java -public class Java1 extends KotlinClass { - @Override - public String a() { - return "2"; - } - - @Override - public String getB() { - return "2"; - } - - @Override - public String getC() { - return "2"; - } - - @Override - public void setC(String value) { - } - - @Override - public String getD() { - return "2"; - } - - @Override - public void setD(String value) { - } - - @Override - public String getE() { - return "2"; - } - - @Override - public String getF() { - return "2"; - } -} - -// FILE: test.kt -open class KotlinClass { - open fun a() = "1" - open val b = "1" - open var c = "1" - open var d: String = "1" - open var e = "1" - open var f: String = "1" -} - -class B : Java1() { - override fun a(): String? = super.a() - override val b: String? = super.b - override var c: String? = super.c - override var d: String? = super.d - override var e: String? = super.e - override var f: String? = super.f -} diff --git a/compiler/testData/diagnostics/tests/j+k/kjkImplicitReturnType.kt b/compiler/testData/diagnostics/tests/j+k/kjkImplicitReturnType.kt index 8e7b9f79ffb..f6cf08a437f 100644 --- a/compiler/testData/diagnostics/tests/j+k/kjkImplicitReturnType.kt +++ b/compiler/testData/diagnostics/tests/j+k/kjkImplicitReturnType.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // ISSUE: KT-66048 // IGNORE_REVERSED_RESOLVE // ^KT-66392 @@ -58,6 +59,6 @@ class B : Java1() { override val b: String? = super.b override var c: String? = super.c override var d: String? = super.d - override var e: String? = super.e - override var f: String? = super.f + override var e: String? = super.e + override var f: String? = super.f } diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOlverloadsGenericFunctions.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOlverloadsGenericFunctions.fir.kt deleted file mode 100644 index 349e7859025..00000000000 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOlverloadsGenericFunctions.fir.kt +++ /dev/null @@ -1,34 +0,0 @@ -fun test1(x: List) = x -fun test1(x: List) = x - -fun List.test1a() {} -fun List.test1a() {} - -fun test2(x: List) = x -fun test2(x: List) = x - -fun List.test2a() {} -fun List.test2a() {} - -fun test3(x: List) = x -fun test3(x: List) = x - -fun List.test3a() {} -fun List.test3a() {} - -fun test4(x: Map) = x -fun test4(x: Map) = x - -fun Map.test4a() {} -fun Map.test4a() {} - -class Inv - -fun test5(x: Inv) = x -fun test5(x: Inv) = x - -fun test6(x: Array) = x -fun test6(x: Array) = x - -fun test7(x: Inv) = x -fun Inv.test7() {} diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOlverloadsGenericFunctions.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOlverloadsGenericFunctions.kt index a5ae854223d..0c94abadb03 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOlverloadsGenericFunctions.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOlverloadsGenericFunctions.kt @@ -1,26 +1,27 @@ +// FIR_IDENTICAL fun test1(x: List) = x fun test1(x: List) = x fun List.test1a() {} fun List.test1a() {} -fun test2(x: List) = x -fun test2(x: List) = x +fun test2(x: List) = x +fun test2(x: List) = x -fun List.test2a() {} -fun List.test2a() {} +fun List.test2a() {} +fun List.test2a() {} -fun test3(x: List) = x -fun test3(x: List) = x +fun test3(x: List) = x +fun test3(x: List) = x -fun List.test3a() {} -fun List.test3a() {} +fun List.test3a() {} +fun List.test3a() {} -fun test4(x: Map) = x -fun test4(x: Map) = x +fun test4(x: Map) = x +fun test4(x: Map) = x -fun Map.test4a() {} -fun Map.test4a() {} +fun Map.test4a() {} +fun Map.test4a() {} class Inv @@ -31,4 +32,4 @@ fun test6(x: Array) = x fun test6(x: Array) = x fun test7(x: Inv) = x -fun Inv.test7() {} \ No newline at end of file +fun Inv.test7() {} diff --git a/compiler/testData/diagnostics/tests/override/Generics.kt b/compiler/testData/diagnostics/tests/override/Generics.kt index 7275172c0fc..9fb626ef355 100644 --- a/compiler/testData/diagnostics/tests/override/Generics.kt +++ b/compiler/testData/diagnostics/tests/override/Generics.kt @@ -49,12 +49,12 @@ abstract class MyAbstractClass1 : MyTrait, MyAbstractClass() { abstract class MyLegalAbstractClass1 : MyTrait, MyAbstractClass() {} class MyIllegalClass2(t : T) : MyTrait, MyAbstractClass() { - fun foo(t: T) = t - fun bar(t: T) = t + fun foo(t: T) = t + fun bar(t: T) = t val <R> pr : T = t } abstract class MyLegalAbstractClass2(t : T) : MyTrait, MyAbstractClass() { - fun foo(t: T) = t - fun bar(t: T) = t + fun foo(t: T) = t + fun bar(t: T) = t val <R> pr : T = t -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/override/InheritingJavaClassWithRawTypeInOverrideSignature.kt b/compiler/testData/diagnostics/tests/override/InheritingJavaClassWithRawTypeInOverrideSignature.kt index 1c068203a19..a0c91d4201e 100644 --- a/compiler/testData/diagnostics/tests/override/InheritingJavaClassWithRawTypeInOverrideSignature.kt +++ b/compiler/testData/diagnostics/tests/override/InheritingJavaClassWithRawTypeInOverrideSignature.kt @@ -17,4 +17,4 @@ public abstract class B implements A { public class C extends B implements A {} // FILE: Main.kt -class X : C() // false positive in K1, OK in K2 +class X : C() // false positive in K1, OK in K2 diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.fir.kt deleted file mode 100644 index 2dcd146db9a..00000000000 --- a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.fir.kt +++ /dev/null @@ -1,33 +0,0 @@ -// FILE: A.java -import org.jetbrains.annotations.*; - -public interface A { - void foo(@Nullable String x); -} - -// FILE: B.java -import org.jetbrains.annotations.*; - -public interface B { - void foo(@NotNull String x); -} - -// FILE: C.kt - -class C1 : A, B { - override fun foo(x: String) {} -} - -class C2 : A, B { - override fun foo(x: String?) {} -} - -interface I : A, B - -class C3 : I { - override fun foo(x: String) {} -} - -class C4 : I { - override fun foo(x: String?) {} -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt index c4ac7bba791..b88f8c7b65c 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: A.java import org.jetbrains.annotations.*; @@ -15,19 +16,19 @@ public interface B { // FILE: C.kt class C1 : A, B { - override fun foo(x: String) {} + override fun foo(x: String) {} } class C2 : A, B { - override fun foo(x: String?) {} + override fun foo(x: String?) {} } -interface I : A, B +interface I : A, B class C3 : I { - override fun foo(x: String) {} + override fun foo(x: String) {} } class C4 : I { - override fun foo(x: String?) {} -} \ No newline at end of file + override fun foo(x: String?) {} +} diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/ambiguousSuperWithGenerics.kt b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/ambiguousSuperWithGenerics.kt index eab44b72628..bf5c70c1e9a 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/ambiguousSuperWithGenerics.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/ambiguousSuperWithGenerics.kt @@ -16,7 +16,7 @@ class GenericDerivedClass : GenericBaseClass(), GenericBaseInterface { super.ambiguous(x) } -class SpecializedDerivedClass : GenericBaseClass(), GenericBaseInterface { +class SpecializedDerivedClass : GenericBaseClass(), GenericBaseInterface { override fun foo(x: Int): Int = super.foo(x) override fun bar(x: String): String = super.bar(x) @@ -26,12 +26,12 @@ class SpecializedDerivedClass : GenericBaseCl super.ambiguous(x) } -class MixedDerivedClass : GenericBaseClass(), GenericBaseInterface { +class MixedDerivedClass : GenericBaseClass(), GenericBaseInterface { override fun foo(x: Int): Int = super.foo(x) override fun bar(x: T): T = super.bar(x) override fun ambiguous(x: Int): Int = super.ambiguous(x) - override fun ambiguous(x: T): T = + override fun ambiguous(x: T): T = super.ambiguous(x) } diff --git a/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.fir.kt b/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.fir.kt deleted file mode 100644 index 74310efe47f..00000000000 --- a/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.fir.kt +++ /dev/null @@ -1,53 +0,0 @@ -// !SKIP_JAVAC -// !LANGUAGE: +InlineClasses -// ALLOW_KOTLIN_PACKAGE -// !DIAGNOSTICS: -UNUSED_PARAMETER - -package kotlin.jvm - -annotation class JvmInline - -@JvmInline -value class A0(val x: Int) - -@JvmInline -value class A1 -@JvmInline -value class A2() -@JvmInline -value class A3(x: Int) -@JvmInline -value class A4(var x: Int) -@JvmInline -value class A5(val x: Int, val y: Int) -@JvmInline -value class A6(x: Int, val y: Int) -@JvmInline -value class A7(vararg val x: Int) -@JvmInline -value class A8(open val x: Int) -@JvmInline -value class A9(final val x: Int) - -class B1 { - companion object { - @JvmInline - value class C1(val x: Int) - } - - @JvmInline - value class C2(val x: Int) -} - -object B2 { - @JvmInline - value class C3(val x: Int) -} - -@JvmInline -final value class D0(val x: Int) -open value class D1(val x: Int) -abstract value class D2(val x: Int) -sealed value class D3(val x: Int) - -value data class D4(val x: String) diff --git a/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.kt b/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.kt index 834ecc06a70..906c0a77c29 100644 --- a/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.kt +++ b/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !SKIP_JAVAC // !LANGUAGE: +InlineClasses // ALLOW_KOTLIN_PACKAGE @@ -50,4 +51,4 @@ final value class D0(val x: Int) abstract value class D2(val x: Int) sealed value class D3(val x: Int) -value data class D4(val x: String) +value data class D4(val x: String) diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/genericFunctions.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/genericFunctions.kt new file mode 100644 index 00000000000..e22efbe51a0 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/genericFunctions.kt @@ -0,0 +1,26 @@ +// FIR_IDENTICAL +fun test2(x: List) = x +fun test2(x: List) = x + +fun List.test2a() {} +fun List.test2a() {} + +fun test3(x: List) = x +fun test3(x: List) = x + +fun List.test3a() {} +fun List.test3a() {} + +fun test4(x: Map) = x +fun test4(x: Map) = x + +fun Map.test4a() {} +fun Map.test4a() {} + +class Inv + +fun test6(x: Array) = x +fun test6(x: Array) = x + +fun test7(x: Inv) = x +fun Inv.test7() {} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.fir.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.fir.kt new file mode 100644 index 00000000000..d5ed93e7cb6 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.fir.kt @@ -0,0 +1,29 @@ +open class GenericBaseClass { + open fun foo(x: T): T = x + open fun ambiguous(x: T): T = x +} + +interface GenericBaseInterface { + fun bar(x: T): T = x + fun ambiguous(x: T): T = x +} + +class GenericDerivedClass : GenericBaseClass(), GenericBaseInterface { + override fun foo(x: T): T = super.foo(x) + override fun bar(x: T): T = super.bar(x) + override fun ambiguous(x: T): T = foo(x) +} + +class SpecializedDerivedClass : GenericBaseClass(), GenericBaseInterface { + override fun foo(x: Int): Int = super.foo(x) + override fun bar(x: String): String = super.bar(x) + override fun ambiguous(x: String): String = bar(x) + override fun ambiguous(x: Int): Int = foo(x) +} + +class MixedDerivedClass : GenericBaseClass(), GenericBaseInterface { + override fun foo(x: Int): Int = super.foo(x) + override fun bar(x: T): T = super.bar(x) + override fun ambiguous(x: Int): Int = foo(x) + override fun ambiguous(x: T): T = bar(x) +} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.kt new file mode 100644 index 00000000000..583ece071ab --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.kt @@ -0,0 +1,29 @@ +open class GenericBaseClass { + open fun foo(x: T): T = x + open fun ambiguous(x: T): T = x +} + +interface GenericBaseInterface { + fun bar(x: T): T = x + fun ambiguous(x: T): T = x +} + +class GenericDerivedClass : GenericBaseClass(), GenericBaseInterface { + override fun foo(x: T): T = super.foo(x) + override fun bar(x: T): T = super.bar(x) + override fun ambiguous(x: T): T = foo(x) +} + +class SpecializedDerivedClass : GenericBaseClass(), GenericBaseInterface { + override fun foo(x: Int): Int = super.foo(x) + override fun bar(x: String): String = super.bar(x) + override fun ambiguous(x: String): String = bar(x) + override fun ambiguous(x: Int): Int = foo(x) +} + +class MixedDerivedClass : GenericBaseClass(), GenericBaseInterface { + override fun foo(x: Int): Int = super.foo(x) + override fun bar(x: T): T = super.bar(x) + override fun ambiguous(x: Int): Int = foo(x) + override fun ambiguous(x: T): T = bar(x) +} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.fir.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.fir.kt new file mode 100644 index 00000000000..38a19248984 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.fir.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -PARAMETER_NAME_CHANGED_ON_OVERRIDE +// FILE: A.java +abstract public class A implements java.util.Collection { + public boolean contains(Object x) {return false;} + public boolean contains(String x) {return false;} +} + +// FILE: main.kt +abstract class KA : A() { + override fun contains(x: String) = false +} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.kt new file mode 100644 index 00000000000..6339d0e4ea7 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -PARAMETER_NAME_CHANGED_ON_OVERRIDE +// FILE: A.java +abstract public class A implements java.util.Collection { + public boolean contains(Object x) {return false;} + public boolean contains(String x) {return false;} +} + +// FILE: main.kt +abstract class KA : A() { + override fun contains(x: String) = false +} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/supertypeDifferentParameterNullability.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/supertypeDifferentParameterNullability.kt new file mode 100644 index 00000000000..e7d855dcff2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/supertypeDifferentParameterNullability.kt @@ -0,0 +1,18 @@ +// FIR_IDENTICAL +// FILE: A.java +import org.jetbrains.annotations.*; + +public interface A { + void foo(@Nullable String x); +} + +// FILE: B.java +import org.jetbrains.annotations.*; + +public interface B { + void foo(@NotNull String x); +} + +// FILE: C.kt + +interface I : A, B diff --git a/compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.fir.kt similarity index 52% rename from compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt rename to compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.fir.kt index 0146979cee0..76484c395fa 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.fir.kt @@ -1,15 +1,16 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER -INAPPLICABLE_JVM_NAME +// WITH_STDLIB @JvmName("bar") -fun foo(a: Any) {} +fun foo(a: Any) {} -fun bar(a: Any) {} +fun bar(a: Any) {} class C { @JvmName("foo1") - fun foo(list: List) {} + fun foo(list: List) {} @JvmName("foo1") - fun foo(list: List) {} + fun foo(list: List) {} } // Conflicts in inheritance. @@ -17,31 +18,31 @@ class C { // A1 -> B1 with accidental override open class A1 { - @JvmName("bar") + @JvmName("bar") open fun foo() {} } class B1 : A1() { - fun bar() {} + fun bar() {} } // A2 -> B2 with intended override and conflicting JVM declarations open class A2 { - @JvmName("bar") + @JvmName("bar") open fun foo() {} } -class B2 : A2() { +class B2 : A2() { override fun foo() {} - fun bar() {} + fun bar() {} } // A3 -> B3 -> C3 with accidental override open class A3 { - @JvmName("bar") + @JvmName("bar") open fun foo() {} } @@ -49,5 +50,5 @@ open class B3: A3() { } class C3: B3() { - fun bar() {} -} \ No newline at end of file + fun bar() {} +} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.kt new file mode 100644 index 00000000000..f19bb52708e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.kt @@ -0,0 +1,54 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -INAPPLICABLE_JVM_NAME +// WITH_STDLIB +@JvmName("bar") +fun foo(a: Any) {} + +fun bar(a: Any) {} + +class C { + @JvmName("foo1") + fun foo(list: List) {} + + @JvmName("foo1") + fun foo(list: List) {} +} + +// Conflicts in inheritance. + +// A1 -> B1 with accidental override + +open class A1 { + @JvmName("bar") + open fun foo() {} +} + +class B1 : A1() { + fun bar() {} +} + +// A2 -> B2 with intended override and conflicting JVM declarations + +open class A2 { + @JvmName("bar") + open fun foo() {} +} + +class B2 : A2() { + override fun foo() {} + + fun bar() {} +} + +// A3 -> B3 -> C3 with accidental override + +open class A3 { + @JvmName("bar") + open fun foo() {} +} + +open class B3: A3() { +} + +class C3: B3() { + fun bar() {} +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.fir.kt deleted file mode 100644 index d0e9db24970..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.fir.kt +++ /dev/null @@ -1,53 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -@JvmName("bar") -fun foo(a: Any) {} - -fun bar(a: Any) {} - -class C { - @JvmName("foo1") - fun foo(list: List) {} - - @JvmName("foo1") - fun foo(list: List) {} -} - -// Conflicts in inheritance. - -// A1 -> B1 with accidental override - -open class A1 { - @JvmName("bar") - open fun foo() {} -} - -class B1 : A1() { - fun bar() {} -} - -// A2 -> B2 with intended override and conflicting JVM declarations - -open class A2 { - @JvmName("bar") - open fun foo() {} -} - -class B2 : A2() { - override fun foo() {} - - fun bar() {} -} - -// A3 -> B3 -> C3 with accidental override - -open class A3 { - @JvmName("bar") - open fun foo() {} -} - -open class B3: A3() { -} - -class C3: B3() { - fun bar() {} -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.txt b/compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.txt deleted file mode 100644 index 51e8a2d7b91..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.txt +++ /dev/null @@ -1,72 +0,0 @@ -package - -public fun bar(/*0*/ a: kotlin.Any): kotlin.Unit -@kotlin.jvm.JvmName(name = "bar") public fun foo(/*0*/ a: kotlin.Any): kotlin.Unit - -public open class A1 { - public constructor A1() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @kotlin.jvm.JvmName(name = "bar") public open fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class A2 { - public constructor A2() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @kotlin.jvm.JvmName(name = "bar") public open fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class A3 { - public constructor A3() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @kotlin.jvm.JvmName(name = "bar") public open fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final class B1 : A1 { - public constructor B1() - public final fun bar(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @kotlin.jvm.JvmName(name = "bar") public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final class B2 : A2 { - public constructor B2() - public final fun bar(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class B3 : A3 { - public constructor B3() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @kotlin.jvm.JvmName(name = "bar") public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final class C { - public constructor C() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @kotlin.jvm.JvmName(name = "foo1") public final fun foo(/*0*/ list: kotlin.collections.List): kotlin.Unit - @kotlin.jvm.JvmName(name = "foo1") public final fun foo(/*0*/ list: kotlin.collections.List): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final class C3 : B3 { - public constructor C3() - public final fun bar(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @kotlin.jvm.JvmName(name = "bar") public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit - 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 a2561221a89..05eb4918e4f 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 @@ -44908,12 +44908,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNames.kt"); } - @Test - @TestMetadata("jvmNamesDuplicate.kt") - public void testJvmNamesDuplicate() { - runTest("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature/jvmNamesDuplicate.kt"); - } - @Test @TestMetadata("jvmOverloads.kt") public void testJvmOverloads() { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJvmIrBackendGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJvmIrBackendGenerated.java index 35a30ddd178..5e7aaf96b84 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJvmIrBackendGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJvmIrBackendGenerated.java @@ -295,6 +295,12 @@ public class DiagnosticsTestWithJvmIrBackendGenerated extends AbstractDiagnostic runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/extensionProperties.kt"); } + @Test + @TestMetadata("genericFunctions.kt") + public void testGenericFunctions() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/genericFunctions.kt"); + } + @Test @TestMetadata("genericType.kt") public void testGenericType() { @@ -307,6 +313,12 @@ public class DiagnosticsTestWithJvmIrBackendGenerated extends AbstractDiagnostic runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritFromTwoTraits.kt"); } + @Test + @TestMetadata("inheritGenericMethodsWithDifferentSubstitution.kt") + public void testInheritGenericMethodsWithDifferentSubstitution() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/inheritGenericMethodsWithDifferentSubstitution.kt"); + } + @Test @TestMetadata("kotlinAndJavaCollections.kt") public void testKotlinAndJavaCollections() { @@ -518,6 +530,44 @@ public class DiagnosticsTestWithJvmIrBackendGenerated extends AbstractDiagnostic } } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop") + @TestDataPath("$PROJECT_ROOT") + public class JavaInterop { + @Test + public void testAllFilesPresentInJavaInterop() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop"), Pattern.compile("^(.+)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("inheritFromJavaCollectionSubclassWithContainsOverload.kt") + public void testInheritFromJavaCollectionSubclassWithContainsOverload() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/inheritFromJavaCollectionSubclassWithContainsOverload.kt"); + } + + @Test + @TestMetadata("supertypeDifferentParameterNullability.kt") + public void testSupertypeDifferentParameterNullability() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/javaInterop/supertypeDifferentParameterNullability.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName") + @TestDataPath("$PROJECT_ROOT") + public class JvmName { + @Test + public void testAllFilesPresentInJvmName() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName"), Pattern.compile("^(.+)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("conflictsWIthJvmNameInClass.kt") + public void testConflictsWIthJvmNameInClass() { + runTest("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/jvmName/conflictsWIthJvmNameInClass.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/specialNames") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/ClassicDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/ClassicDiagnosticsHandler.kt index 25d97a8db49..4c64362e151 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/ClassicDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/ClassicDiagnosticsHandler.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.getJvmSignatureDiagnostics import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.diagnostics.Severity import org.jetbrains.kotlin.platform.jvm.isJvm import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtFile @@ -44,9 +45,8 @@ class ClassicDiagnosticsHandler(testServices: TestServices) : ClassicFrontendAna private val reporter = ClassicDiagnosticReporter(testServices) - @OptIn(ExperimentalStdlibApi::class) override fun processModule(module: TestModule, info: ClassicFrontendOutputArtifact) { - var allDiagnostics = info.analysisResult.bindingContext.diagnostics + computeJvmSignatureDiagnostics(info) + var allDiagnostics = info.analysisResult.bindingContext.diagnostics.toList() if (AdditionalFilesDirectives.CHECK_TYPE in module.directives) { allDiagnostics = allDiagnostics.filter { it.factory.name != Errors.UNDERSCORE_USAGE_WITHOUT_BACKTICKS.name } } @@ -54,6 +54,10 @@ class ClassicDiagnosticsHandler(testServices: TestServices) : ClassicFrontendAna allDiagnostics = allDiagnostics.filter { it.factory.name != Errors.NEWER_VERSION_IN_SINCE_KOTLIN.name } } + if (allDiagnostics.none { it.severity == Severity.ERROR }) { + allDiagnostics = allDiagnostics + computeJvmSignatureDiagnostics(info) + } + val diagnosticsPerFile = allDiagnostics.groupBy { it.psiFile } val withNewInferenceModeEnabled = testServices.withNewInferenceModeEnabled() val configuration = reporter.createConfiguration(module)