From 29afd674d21bee68c89d9490d74d9f5a04250ce5 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 8 Dec 2021 08:57:15 +0100 Subject: [PATCH] JvmDefaultWithoutCompatibility. Add test with Kotlin Java mixed inheritance --- .../FirBlackBoxCodegenTestGenerated.java | 6 +++ .../withCompatibility/javaInheritance.kt | 51 +++++++++++++++++++ .../withCompatibility/javaInheritance.txt | 32 ++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++ .../LightAnalysisModeTestGenerated.java | 5 ++ 6 files changed, 106 insertions(+) create mode 100644 compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.kt create mode 100644 compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index b6f4e2ba4b8..93ea0f85d61 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -25855,6 +25855,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/differentCases.kt"); } + @Test + @TestMetadata("javaInheritance.kt") + public void testJavaInheritance() throws Exception { + runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.kt"); + } + @Test @TestMetadata("propertyAnnotation.kt") public void testPropertyAnnotation() throws Exception { diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.kt new file mode 100644 index 00000000000..fad1dd432ee --- /dev/null +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.kt @@ -0,0 +1,51 @@ +// !JVM_DEFAULT_MODE: all +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME +// CHECK_BYTECODE_LISTING + +// FILE: KBase.kt +public interface KBase { + public fun test(): String = "Fail" +} + + +// FILE: JDerived.java +public interface JDerived extends KBase { + public default String test() { + return "O"; + } + + public default String test2() { + return "fail"; + } + + public default String test3() { + return ""; + } +} + +// FILE: JClass.java +public class JClass implements KDerived { + + public String test2() { + return KDerived.DefaultImpls.test2(this); + } +} + + +// FILE: main.kt +@JvmDefaultWithCompatibility +interface KDerived : JDerived { + override public fun test2(): String = "K" +} + +class KClass : KDerived + +fun box(): String { + val kClass = KClass() + val value = kClass.test() + kClass.test2() + kClass.test3() + if (value != "OK") return "fail 1: $value" + val jClass = JClass() + return jClass.test() + jClass.test2() + jClass.test3() +} diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.txt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.txt new file mode 100644 index 00000000000..458753b5c24 --- /dev/null +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.txt @@ -0,0 +1,32 @@ +@kotlin.Metadata +public interface KBase { + // source: 'KBase.kt' + public @org.jetbrains.annotations.NotNull method test(): java.lang.String +} + +@kotlin.Metadata +public final class KClass { + // source: 'main.kt' + public method (): void +} + +@kotlin.Metadata +public final class KDerived$DefaultImpls { + // source: 'main.kt' + public deprecated static @java.lang.Deprecated @org.jetbrains.annotations.NotNull method test2(@org.jetbrains.annotations.NotNull p0: KDerived): java.lang.String + public final inner class KDerived$DefaultImpls +} + +@kotlin.Metadata +public interface KDerived { + // source: 'main.kt' + public synthetic static method access$test2$jd(p0: KDerived): java.lang.String + public @org.jetbrains.annotations.NotNull method test2(): java.lang.String + public final inner class KDerived$DefaultImpls +} + +@kotlin.Metadata +public final class MainKt { + // source: 'main.kt' + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 41744d4d3a7..7614534d398 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -25459,6 +25459,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/differentCases.kt"); } + @Test + @TestMetadata("javaInheritance.kt") + public void testJavaInheritance() throws Exception { + runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.kt"); + } + @Test @TestMetadata("propertyAnnotation.kt") public void testPropertyAnnotation() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index f781538d11c..693c93a8b13 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -25855,6 +25855,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/differentCases.kt"); } + @Test + @TestMetadata("javaInheritance.kt") + public void testJavaInheritance() throws Exception { + runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.kt"); + } + @Test @TestMetadata("propertyAnnotation.kt") public void testPropertyAnnotation() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 132c93dba74..e3dbaab3805 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -21489,6 +21489,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/differentCases.kt"); } + @TestMetadata("javaInheritance.kt") + public void testJavaInheritance() throws Exception { + runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/javaInheritance.kt"); + } + @TestMetadata("propertyAnnotation.kt") public void testPropertyAnnotation() throws Exception { runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/withCompatibility/propertyAnnotation.kt");