From 239a330ddd198c0c579343fa1cbb1d8743005a9d Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 18 Jan 2022 17:14:15 +0300 Subject: [PATCH] [FE 1.0] Add test for KT-50850 --- ...CompilerTestFE10TestdataTestGenerated.java | 12 +++++++ ...irOldFrontendDiagnosticsTestGenerated.java | 12 +++++++ ...DiagnosticsWithLightTreeTestGenerated.java | 12 +++++++ ...orderOfSupertypesAndFakeOverrides_1.fir.kt | 22 ++++++++++++ .../orderOfSupertypesAndFakeOverrides_1.kt | 22 ++++++++++++ .../orderOfSupertypesAndFakeOverrides_1.txt | 35 ++++++++++++++++++ ...orderOfSupertypesAndFakeOverrides_2.fir.kt | 21 +++++++++++ .../orderOfSupertypesAndFakeOverrides_2.kt | 21 +++++++++++ .../orderOfSupertypesAndFakeOverrides_2.txt | 36 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 12 +++++++ 10 files changed, 205 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.fir.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.txt create mode 100644 compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.fir.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.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 d4a6195490a..92647342ed1 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 @@ -17762,6 +17762,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/j+k/nullForOptionalOrElse.kt"); } + @Test + @TestMetadata("orderOfSupertypesAndFakeOverrides_1.kt") + public void testOrderOfSupertypesAndFakeOverrides_1() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.kt"); + } + + @Test + @TestMetadata("orderOfSupertypesAndFakeOverrides_2.kt") + public void testOrderOfSupertypesAndFakeOverrides_2() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.kt"); + } + @Test @TestMetadata("overrideRawType.kt") public void testOverrideRawType() throws Exception { 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 b943c06b740..048c25e52b6 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 @@ -17762,6 +17762,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/j+k/nullForOptionalOrElse.kt"); } + @Test + @TestMetadata("orderOfSupertypesAndFakeOverrides_1.kt") + public void testOrderOfSupertypesAndFakeOverrides_1() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.kt"); + } + + @Test + @TestMetadata("orderOfSupertypesAndFakeOverrides_2.kt") + public void testOrderOfSupertypesAndFakeOverrides_2() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.kt"); + } + @Test @TestMetadata("overrideRawType.kt") public void testOverrideRawType() throws Exception { 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 11650b20057..2da60ec95cf 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 @@ -17762,6 +17762,18 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/j+k/nullForOptionalOrElse.kt"); } + @Test + @TestMetadata("orderOfSupertypesAndFakeOverrides_1.kt") + public void testOrderOfSupertypesAndFakeOverrides_1() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.kt"); + } + + @Test + @TestMetadata("orderOfSupertypesAndFakeOverrides_2.kt") + public void testOrderOfSupertypesAndFakeOverrides_2() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.kt"); + } + @Test @TestMetadata("overrideRawType.kt") public void testOverrideRawType() throws Exception { diff --git a/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.fir.kt b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.fir.kt new file mode 100644 index 00000000000..0e902c2a6c1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.fir.kt @@ -0,0 +1,22 @@ +// ISSUE: KT-50850 +// FILE: Base.java +public interface Base { + void delete(String s); +} + +// FILE: main.kt +abstract class Derived : Base { + override fun delete(s: String) {} +} + +class InterfaceThenClass : Base, Derived() {} + +fun test_1(x: InterfaceThenClass, s: String?) { + x.delete(s) +} + +class ClassThenInterface : Derived(), Base {} + +fun test_2(x: ClassThenInterface, s: String?) { + x.delete(s) +} diff --git a/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.kt b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.kt new file mode 100644 index 00000000000..9bdcb383b2e --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.kt @@ -0,0 +1,22 @@ +// ISSUE: KT-50850 +// FILE: Base.java +public interface Base { + void delete(String s); +} + +// FILE: main.kt +abstract class Derived : Base { + override fun delete(s: String) {} +} + +class InterfaceThenClass : Base, Derived() {} + +fun test_1(x: InterfaceThenClass, s: String?) { + x.delete(s) +} + +class ClassThenInterface : Derived(), Base {} + +fun test_2(x: ClassThenInterface, s: String?) { + x.delete(s) +} diff --git a/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.txt b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.txt new file mode 100644 index 00000000000..84edddbf790 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.txt @@ -0,0 +1,35 @@ +package + +public fun test_1(/*0*/ x: InterfaceThenClass, /*1*/ s: kotlin.String?): kotlin.Unit +public fun test_2(/*0*/ x: ClassThenInterface, /*1*/ s: kotlin.String?): kotlin.Unit + +public interface Base { + public abstract fun delete(/*0*/ s: kotlin.String!): 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 final class ClassThenInterface : Derived, Base { + public constructor ClassThenInterface() + public open override /*2*/ /*fake_override*/ fun delete(/*0*/ s: kotlin.String): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public abstract class Derived : Base { + public constructor Derived() + public open override /*1*/ fun delete(/*0*/ s: kotlin.String): 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 final class InterfaceThenClass : Base, Derived { + public constructor InterfaceThenClass() + public open override /*2*/ /*fake_override*/ fun delete(/*0*/ s: kotlin.String!): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.fir.kt b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.fir.kt new file mode 100644 index 00000000000..381e144c26e --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.fir.kt @@ -0,0 +1,21 @@ +// ISSUE: KT-50850 +// FILE: JavaBase.java +public interface JavaBase { + void delete(String s); +} + +// FILE: main.kt +abstract class KotlinBase { + open fun delete(s: String) {} +} + +class InterfaceThenClass : JavaBase, KotlinBase() {} +class ClassThenInterface : KotlinBase(), JavaBase {} + +fun test_1(x: InterfaceThenClass, s: String?) { + x.delete(s) +} + +fun test_2(x: ClassThenInterface, s: String?) { + x.delete(s) +} diff --git a/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.kt b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.kt new file mode 100644 index 00000000000..d27e88c3d7d --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.kt @@ -0,0 +1,21 @@ +// ISSUE: KT-50850 +// FILE: JavaBase.java +public interface JavaBase { + void delete(String s); +} + +// FILE: main.kt +abstract class KotlinBase { + open fun delete(s: String) {} +} + +class InterfaceThenClass : JavaBase, KotlinBase() {} +class ClassThenInterface : KotlinBase(), JavaBase {} + +fun test_1(x: InterfaceThenClass, s: String?) { + x.delete(s) +} + +fun test_2(x: ClassThenInterface, s: String?) { + x.delete(s) +} diff --git a/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.txt b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.txt new file mode 100644 index 00000000000..c236aace2a6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.txt @@ -0,0 +1,36 @@ +package + +public fun test_1(/*0*/ x: InterfaceThenClass, /*1*/ s: kotlin.String?): kotlin.Unit +public fun test_2(/*0*/ x: ClassThenInterface, /*1*/ s: kotlin.String?): kotlin.Unit + +public final class ClassThenInterface : KotlinBase, JavaBase { + public constructor ClassThenInterface() + public open override /*2*/ /*fake_override*/ fun delete(/*0*/ s: kotlin.String): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class InterfaceThenClass : JavaBase, KotlinBase { + public constructor InterfaceThenClass() + public open override /*2*/ /*fake_override*/ fun delete(/*0*/ s: kotlin.String!): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaBase { + public abstract fun delete(/*0*/ s: kotlin.String!): 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 abstract class KotlinBase { + public constructor KotlinBase() + public open fun delete(/*0*/ s: kotlin.String): 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 dd8c7ab26f1..62465ee32b3 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 @@ -17768,6 +17768,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/j+k/nullForOptionalOrElse.kt"); } + @Test + @TestMetadata("orderOfSupertypesAndFakeOverrides_1.kt") + public void testOrderOfSupertypesAndFakeOverrides_1() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_1.kt"); + } + + @Test + @TestMetadata("orderOfSupertypesAndFakeOverrides_2.kt") + public void testOrderOfSupertypesAndFakeOverrides_2() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/orderOfSupertypesAndFakeOverrides_2.kt"); + } + @Test @TestMetadata("overrideRawType.kt") public void testOverrideRawType() throws Exception {