diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 4b71254f03d..da2726859e0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -15164,6 +15164,59 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8DefaultInterfaceMethods extends AbstractFirBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: "); + } + + public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("javaDefaultMethod.kt") + public void testJavaDefaultMethod() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethod.kt"); + } + + @TestMetadata("javaDefaultMethodOverriddenByKotlin.kt") + public void testJavaDefaultMethodOverriddenByKotlin() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethodOverriddenByKotlin.kt"); + } + + @TestMetadata("jvmDefaultAll.kt") + public void testJvmDefaultAll() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAll.kt"); + } + + @TestMetadata("jvmDefaultAllPrimaryProperty.kt") + public void testJvmDefaultAllPrimaryProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllPrimaryProperty.kt"); + } + + @TestMetadata("jvmDefaultAllProperty.kt") + public void testJvmDefaultAllProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllProperty.kt"); + } + + @TestMetadata("jvmDefaultEnable.kt") + public void testJvmDefaultEnable() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnable.kt"); + } + + @TestMetadata("jvmDefaultEnablePrimaryProperty.kt") + public void testJvmDefaultEnablePrimaryProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnablePrimaryProperty.kt"); + } + + @TestMetadata("jvmDefaultEnableProperty.kt") + public void testJvmDefaultEnableProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnableProperty.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt index 1407ef3875a..298dbd39fca 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.codegen.classFileContainsMethod import org.jetbrains.kotlin.backend.jvm.codegen.isJvmInterface +import org.jetbrains.kotlin.backend.jvm.ir.isCompiledToJvmDefault import org.jetbrains.kotlin.backend.jvm.ir.isFromJava import org.jetbrains.kotlin.backend.jvm.ir.isStaticInlineClassReplacement import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.InlineClassAbi.mangledNameFor @@ -71,7 +72,7 @@ class MemoizedInlineClassReplacements( when { it.isRemoveAtSpecialBuiltinStub() -> null - it.isInlineClassMemberFakeOverriddenFromDefaultJavaInterfaceMethod() -> + it.isInlineClassMemberFakeOverriddenFromJvmDefaultInterfaceMethod() -> null it.origin == IrDeclarationOrigin.IR_BUILTINS_STUB -> createMethodReplacement(it) @@ -97,14 +98,21 @@ class MemoizedInlineClassReplacements( valueParameters.size == 1 && valueParameters[0].type.isInt() - private fun IrFunction.isInlineClassMemberFakeOverriddenFromDefaultJavaInterfaceMethod(): Boolean { + private fun IrFunction.isInlineClassMemberFakeOverriddenFromJvmDefaultInterfaceMethod(): Boolean { if (this !is IrSimpleFunction) return false if (!this.isFakeOverride) return false val parentClass = parentClassOrNull ?: return false if (!parentClass.isInline) return false val overridden = resolveFakeOverride() ?: return false - return overridden.isFromJava() && overridden.modality != Modality.ABSTRACT && overridden.parentAsClass.isJvmInterface + if (!overridden.parentAsClass.isJvmInterface) return false + if (overridden.modality == Modality.ABSTRACT) return false + + // We have a non-abstract interface member. + // It is a JVM default interface method if one of the following conditions are true: + // - it is a Java method, + // - it is a Kotlin function compiled to JVM default interface method. + return overridden.isFromJava() || overridden.isCompiledToJvmDefault(context.state.jvmDefaultMode) } /** diff --git a/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethod.kt b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethod.kt new file mode 100644 index 00000000000..c0cfa2a8fee --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethod.kt @@ -0,0 +1,38 @@ +// TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: JVM +// ^ KT-43698, fixed in JVM_IR +// JVM_TARGET: 1.8 +// FILE: javaDefaultMethod.kt +inline class K(val k: String) : J { + override fun get2() = k +} + +fun box(): String { + val k = K("K") + + val test1 = k.get1() + k.get2() + if (test1 != "OK") throw AssertionError("test1: $test1") + + val j: J = k + val test2 = j.get1() + j.get2() + if (test2 != "OK") throw AssertionError("test2: $test2") + + val test3 = JT.test(k) + if (test3 != "OK") throw AssertionError("test3: $test3") + + return "OK" +} + +// FILE: J.java +public interface J { + default String get1() { return "O"; } + default String get2() { return "Failed"; } +} + +// FILE: JT.java +public class JT { + public static String test(J j) { + return j.get1() + j.get2(); + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethodOverriddenByKotlin.kt b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethodOverriddenByKotlin.kt new file mode 100644 index 00000000000..02ac7ea6202 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethodOverriddenByKotlin.kt @@ -0,0 +1,49 @@ +// TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: JVM +// ^ KT-43698, fixed in JVM_IR +// JVM_TARGET: 1.8 +// FILE: javaDefaultMethod.kt +interface K2 : J { + override fun get2() = "Kotlin" +} + +inline class K(val k: String) : K2 { + override fun get2() = k +} + +fun box(): String { + val k = K("K") + + val test1 = k.get1() + k.get2() + if (test1 != "OK") throw AssertionError("test1: $test1") + + val j: J = k + val test2 = j.get1() + j.get2() + if (test2 != "OK") throw AssertionError("test2: $test2") + + val test3 = JT.test(k) + if (test3 != "OK") throw AssertionError("test3: $test3") + + val k2: K2 = k + val test4 = k2.get1() + k2.get2() + if (test4 != "OK") throw AssertionError("test4: $test4") + + val test5 = JT.test(k2) + if (test5 != "OK") throw AssertionError("test5: $test5") + + return "OK" +} + +// FILE: J.java +public interface J { + default String get1() { return "O"; } + default String get2() { return "Java"; } +} + +// FILE: JT.java +public class JT { + public static String test(J j) { + return j.get1() + j.get2(); + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAll.kt b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAll.kt new file mode 100644 index 00000000000..3c40e5857ee --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAll.kt @@ -0,0 +1,48 @@ +// !JVM_DEFAULT_MODE: all +// TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: JVM +// ^ KT-43698, fixed in JVM_IR +// WITH_RUNTIME +// JVM_TARGET: 1.8 +// FILE: jvmDefaultAll.kt + +interface IFooBar { + fun foo() = "O" + fun bar() = "Failed" +} + +interface IFooBar2 : IFooBar + +inline class Test1(val k: String): IFooBar { + override fun bar(): String = k +} + +inline class Test2(val k: String): IFooBar2 { + override fun bar(): String = k +} + +fun box(): String { + val k = Test1("K") + val ik: IFooBar = k + val k2 = Test2("K") + val ik2: IFooBar = k2 + val ik3: IFooBar2 = k2 + + val test1 = k.foo() + k.bar() + if (test1 != "OK") throw AssertionError("test1: $test1") + + val test2 = ik.foo() + ik.bar() + if (test2 != "OK") throw AssertionError("test2: $test2") + + val test3 = k2.foo() + k2.bar() + if (test3 != "OK") throw AssertionError("test3: $test3") + + val test4 = ik2.foo() + ik2.bar() + if (test4 != "OK") throw AssertionError("test4: $test4") + + val test5 = ik3.foo() + ik3.bar() + if (test5 != "OK") throw AssertionError("test5: $test5") + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllPrimaryProperty.kt b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllPrimaryProperty.kt new file mode 100644 index 00000000000..0258f121629 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllPrimaryProperty.kt @@ -0,0 +1,44 @@ +// !JVM_DEFAULT_MODE: all +// TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: JVM +// ^ KT-43698, fixed in JVM_IR +// WITH_RUNTIME +// JVM_TARGET: 1.8 +// FILE: jvmDefaultAll.kt + +interface IFooBar { + val foo get() = "O" + val bar get() = "Failed" +} + +interface IFooBar2 : IFooBar + +inline class Test1(override val bar: String): IFooBar + +inline class Test2(override val bar: String): IFooBar2 + +fun box(): String { + val k = Test1("K") + val ik: IFooBar = k + val k2 = Test2("K") + val ik2: IFooBar = k2 + val ik3: IFooBar2 = k2 + + val test1 = k.foo + k.bar + if (test1 != "OK") throw AssertionError("test1: $test1") + + val test2 = ik.foo + ik.bar + if (test2 != "OK") throw AssertionError("test2: $test2") + + val test3 = k2.foo + k2.bar + if (test3 != "OK") throw AssertionError("test3: $test3") + + val test4 = ik2.foo + ik2.bar + if (test4 != "OK") throw AssertionError("test4: $test4") + + val test5 = ik3.foo + ik3.bar + if (test5 != "OK") throw AssertionError("test5: $test5") + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllProperty.kt b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllProperty.kt new file mode 100644 index 00000000000..6932507a332 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllProperty.kt @@ -0,0 +1,50 @@ +// !JVM_DEFAULT_MODE: all +// TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: JVM +// ^ KT-43698, fixed in JVM_IR +// WITH_RUNTIME +// JVM_TARGET: 1.8 +// FILE: jvmDefaultAll.kt + +interface IFooBar { + val foo get() = "O" + val bar get() = "Failed" +} + +interface IFooBar2 : IFooBar + +inline class Test1(val k: String): IFooBar { + override val bar: String + get() = k +} + +inline class Test2(val k: String): IFooBar2 { + override val bar: String + get() = k +} + +fun box(): String { + val k = Test1("K") + val ik: IFooBar = k + val k2 = Test2("K") + val ik2: IFooBar = k2 + val ik3: IFooBar2 = k2 + + val test1 = k.foo + k.bar + if (test1 != "OK") throw AssertionError("test1: $test1") + + val test2 = ik.foo + ik.bar + if (test2 != "OK") throw AssertionError("test2: $test2") + + val test3 = k2.foo + k2.bar + if (test3 != "OK") throw AssertionError("test3: $test3") + + val test4 = ik2.foo + ik2.bar + if (test4 != "OK") throw AssertionError("test4: $test4") + + val test5 = ik3.foo + ik3.bar + if (test5 != "OK") throw AssertionError("test5: $test5") + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnable.kt b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnable.kt new file mode 100644 index 00000000000..ab633f270fd --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnable.kt @@ -0,0 +1,48 @@ +// !JVM_DEFAULT_MODE: enable +// TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: JVM +// ^ KT-43698, fixed in JVM_IR +// WITH_RUNTIME +// JVM_TARGET: 1.8 +// FILE: jvmDefaultEnable.kt + +interface IFooBar { + @JvmDefault fun foo() = "O" + @JvmDefault fun bar() = "Failed" +} + +interface IFooBar2 : IFooBar + +inline class Test1(val k: String): IFooBar { + override fun bar(): String = k +} + +inline class Test2(val k: String): IFooBar2 { + override fun bar(): String = k +} + +fun box(): String { + val k = Test1("K") + val ik: IFooBar = k + val k2 = Test2("K") + val ik2: IFooBar = k2 + val ik3: IFooBar2 = k2 + + val test1 = k.foo() + k.bar() + if (test1 != "OK") throw AssertionError("test1: $test1") + + val test2 = ik.foo() + ik.bar() + if (test2 != "OK") throw AssertionError("test2: $test2") + + val test3 = k2.foo() + k2.bar() + if (test3 != "OK") throw AssertionError("test3: $test3") + + val test4 = ik2.foo() + ik2.bar() + if (test4 != "OK") throw AssertionError("test4: $test4") + + val test5 = ik3.foo() + ik3.bar() + if (test5 != "OK") throw AssertionError("test5: $test5") + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnablePrimaryProperty.kt b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnablePrimaryProperty.kt new file mode 100644 index 00000000000..c89f86e2d83 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnablePrimaryProperty.kt @@ -0,0 +1,44 @@ +// !JVM_DEFAULT_MODE: enable +// TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: JVM +// ^ KT-43698, fixed in JVM_IR +// WITH_RUNTIME +// JVM_TARGET: 1.8 +// FILE: jvmDefaultEnable.kt + +interface IFooBar { + @JvmDefault val foo get() = "O" + @JvmDefault val bar get() = "Failed" +} + +interface IFooBar2 : IFooBar + +inline class Test1(override val bar: String): IFooBar + +inline class Test2(override val bar: String): IFooBar2 + +fun box(): String { + val k = Test1("K") + val ik: IFooBar = k + val k2 = Test2("K") + val ik2: IFooBar = k2 + val ik3: IFooBar2 = k2 + + val test1 = k.foo + k.bar + if (test1 != "OK") throw AssertionError("test1: $test1") + + val test2 = ik.foo + ik.bar + if (test2 != "OK") throw AssertionError("test2: $test2") + + val test3 = k2.foo + k2.bar + if (test3 != "OK") throw AssertionError("test3: $test3") + + val test4 = ik2.foo + ik2.bar + if (test4 != "OK") throw AssertionError("test4: $test4") + + val test5 = ik3.foo + ik3.bar + if (test5 != "OK") throw AssertionError("test5: $test5") + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnableProperty.kt b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnableProperty.kt new file mode 100644 index 00000000000..3e04523b893 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnableProperty.kt @@ -0,0 +1,50 @@ +// !JVM_DEFAULT_MODE: enable +// TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// IGNORE_BACKEND: JVM +// ^ KT-43698, fixed in JVM_IR +// WITH_RUNTIME +// JVM_TARGET: 1.8 +// FILE: jvmDefaultEnable.kt + +interface IFooBar { + @JvmDefault val foo get() = "O" + @JvmDefault val bar get() = "Failed" +} + +interface IFooBar2 : IFooBar + +inline class Test1(val k: String): IFooBar { + override val bar: String + get() = k +} + +inline class Test2(val k: String): IFooBar2 { + override val bar: String + get() = k +} + +fun box(): String { + val k = Test1("K") + val ik: IFooBar = k + val k2 = Test2("K") + val ik2: IFooBar = k2 + val ik3: IFooBar2 = k2 + + val test1 = k.foo + k.bar + if (test1 != "OK") throw AssertionError("test1: $test1") + + val test2 = ik.foo + ik.bar + if (test2 != "OK") throw AssertionError("test2: $test2") + + val test3 = k2.foo + k2.bar + if (test3 != "OK") throw AssertionError("test3: $test3") + + val test4 = ik2.foo + ik2.bar + if (test4 != "OK") throw AssertionError("test4: $test4") + + val test5 = ik3.foo + ik3.bar + if (test5 != "OK") throw AssertionError("test5: $test5") + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/javaDefaultInterfaceMember.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/javaDefaultInterfaceMember.kt new file mode 100644 index 00000000000..6cfdccc36e0 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/javaDefaultInterfaceMember.kt @@ -0,0 +1,38 @@ +// JVM_TARGET: 1.8 +// FILE: javaDefaultInterfaceMember.kt +interface KFoo2 : JIFoo + +interface KFooUnrelated { + fun foo() +} + +interface KFoo3 : KFoo2, KFooUnrelated { + override fun foo() {} +} + +interface KBar2 : JIBar + +inline class TestFoo1(val x: Int) : JIFoo + +inline class TestFoo2(val x: Int) : KFoo2 + +inline class TestFoo3(val x: Int) : KFoo3 + +inline class TestBar1(val x: Int) : JIBar { + override fun bar() {} +} + +inline class TestBar2(val x: Int) : KBar2 { + override fun bar() {} +} + +// FILE: JIFoo.java +public interface JIFoo { + default void foo() {} +} + +// FILE: JIBar.java +public interface JIBar { + default void foo() {} + default void bar() {} +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/javaDefaultInterfaceMember.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/javaDefaultInterfaceMember.txt similarity index 60% rename from compiler/testData/codegen/bytecodeListing/inlineClasses/javaDefaultInterfaceMember.txt rename to compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/javaDefaultInterfaceMember.txt index 2d69cc08b7b..0b72b8b2180 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/javaDefaultInterfaceMember.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/javaDefaultInterfaceMember.txt @@ -1,3 +1,8 @@ +@kotlin.Metadata +public interface KBar2 { + // source: 'javaDefaultInterfaceMember.kt' +} + @kotlin.Metadata public interface KFoo2 { // source: 'javaDefaultInterfaceMember.kt' @@ -25,11 +30,13 @@ public interface KFooUnrelated { @kotlin.jvm.JvmInline @kotlin.Metadata -public final class Test1 { +public final class TestBar1 { // source: 'javaDefaultInterfaceMember.kt' private final field x: int private synthetic method (p0: int): void - public synthetic final static method box-impl(p0: int): Test1 + public method bar(): void + public static method bar-impl(p0: int): void + public synthetic final static method box-impl(p0: int): TestBar1 public static method constructor-impl(p0: int): int public method equals(p0: java.lang.Object): boolean public static method equals-impl(p0: int, p1: java.lang.Object): boolean @@ -44,11 +51,13 @@ public final class Test1 { @kotlin.jvm.JvmInline @kotlin.Metadata -public final class Test2 { +public final class TestBar2 { // source: 'javaDefaultInterfaceMember.kt' private final field x: int private synthetic method (p0: int): void - public synthetic final static method box-impl(p0: int): Test2 + public method bar(): void + public static method bar-impl(p0: int): void + public synthetic final static method box-impl(p0: int): TestBar2 public static method constructor-impl(p0: int): int public method equals(p0: java.lang.Object): boolean public static method equals-impl(p0: int, p1: java.lang.Object): boolean @@ -63,11 +72,49 @@ public final class Test2 { @kotlin.jvm.JvmInline @kotlin.Metadata -public final class Test3 { +public final class TestFoo1 { // source: 'javaDefaultInterfaceMember.kt' private final field x: int private synthetic method (p0: int): void - public synthetic final static method box-impl(p0: int): Test3 + public synthetic final static method box-impl(p0: int): TestFoo1 + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class TestFoo2 { + // source: 'javaDefaultInterfaceMember.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): TestFoo2 + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class TestFoo3 { + // source: 'javaDefaultInterfaceMember.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): TestFoo3 public static method constructor-impl(p0: int): int public method equals(p0: java.lang.Object): boolean public static method equals-impl(p0: int, p1: java.lang.Object): boolean diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll.kt new file mode 100644 index 00000000000..eb1d1efd205 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll.kt @@ -0,0 +1,18 @@ +// !JVM_DEFAULT_MODE: all +// WITH_RUNTIME +// JVM_TARGET: 1.8 + +interface IFooBar { + fun foo() = "O" + fun bar() = "Failed" +} + +interface IFooBar2 : IFooBar + +inline class Test1(val k: String): IFooBar { + override fun bar(): String = k +} + +inline class Test2(val k: String): IFooBar2 { + override fun bar(): String = k +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll.txt new file mode 100644 index 00000000000..f3b6814a038 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll.txt @@ -0,0 +1,53 @@ +@kotlin.Metadata +public interface IFooBar { + // source: 'jvmDefaultAll.kt' + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public @org.jetbrains.annotations.NotNull method foo(): java.lang.String +} + +@kotlin.Metadata +public interface IFooBar2 { + // source: 'jvmDefaultAll.kt' +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class Test1 { + // source: 'jvmDefaultAll.kt' + private final @org.jetbrains.annotations.NotNull field k: java.lang.String + private synthetic method (p0: java.lang.String): void + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public static @org.jetbrains.annotations.NotNull method bar-impl(p0: java.lang.String): java.lang.String + public synthetic final static method box-impl(p0: java.lang.String): Test1 + public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean + public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.String): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.String): java.lang.String + public synthetic final method unbox-impl(): java.lang.String +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class Test2 { + // source: 'jvmDefaultAll.kt' + private final @org.jetbrains.annotations.NotNull field k: java.lang.String + private synthetic method (p0: java.lang.String): void + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public static @org.jetbrains.annotations.NotNull method bar-impl(p0: java.lang.String): java.lang.String + public synthetic final static method box-impl(p0: java.lang.String): Test2 + public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean + public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.String): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.String): java.lang.String + public synthetic final method unbox-impl(): java.lang.String +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll_ir.txt new file mode 100644 index 00000000000..0d942d45dc1 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll_ir.txt @@ -0,0 +1,53 @@ +@kotlin.Metadata +public interface IFooBar { + // source: 'jvmDefaultAll.kt' + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public @org.jetbrains.annotations.NotNull method foo(): java.lang.String +} + +@kotlin.Metadata +public interface IFooBar2 { + // source: 'jvmDefaultAll.kt' +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class Test1 { + // source: 'jvmDefaultAll.kt' + private final @org.jetbrains.annotations.NotNull field k: java.lang.String + private synthetic method (p0: java.lang.String): void + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public static @org.jetbrains.annotations.NotNull method bar-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public synthetic final static method box-impl(p0: java.lang.String): Test1 + public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean + public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.String): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.String): java.lang.String + public synthetic final method unbox-impl(): java.lang.String +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class Test2 { + // source: 'jvmDefaultAll.kt' + private final @org.jetbrains.annotations.NotNull field k: java.lang.String + private synthetic method (p0: java.lang.String): void + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public static @org.jetbrains.annotations.NotNull method bar-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public synthetic final static method box-impl(p0: java.lang.String): Test2 + public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean + public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.String): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.String): java.lang.String + public synthetic final method unbox-impl(): java.lang.String +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable.kt new file mode 100644 index 00000000000..8fe943b641c --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable.kt @@ -0,0 +1,18 @@ +// !JVM_DEFAULT_MODE: enable +// WITH_RUNTIME +// JVM_TARGET: 1.8 + +interface IFooBar { + @JvmDefault fun foo() = "O" + @JvmDefault fun bar() = "Failed" +} + +interface IFooBar2 : IFooBar + +inline class Test1(val k: String): IFooBar { + override fun bar(): String = k +} + +inline class Test2(val k: String): IFooBar2 { + override fun bar(): String = k +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable.txt new file mode 100644 index 00000000000..9732168d406 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable.txt @@ -0,0 +1,53 @@ +@kotlin.Metadata +public interface IFooBar { + // source: 'jvmDefaultEnable.kt' + public @kotlin.jvm.JvmDefault @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public @kotlin.jvm.JvmDefault @org.jetbrains.annotations.NotNull method foo(): java.lang.String +} + +@kotlin.Metadata +public interface IFooBar2 { + // source: 'jvmDefaultEnable.kt' +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class Test1 { + // source: 'jvmDefaultEnable.kt' + private final @org.jetbrains.annotations.NotNull field k: java.lang.String + private synthetic method (p0: java.lang.String): void + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public static @org.jetbrains.annotations.NotNull method bar-impl(p0: java.lang.String): java.lang.String + public synthetic final static method box-impl(p0: java.lang.String): Test1 + public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean + public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.String): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.String): java.lang.String + public synthetic final method unbox-impl(): java.lang.String +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class Test2 { + // source: 'jvmDefaultEnable.kt' + private final @org.jetbrains.annotations.NotNull field k: java.lang.String + private synthetic method (p0: java.lang.String): void + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public static @org.jetbrains.annotations.NotNull method bar-impl(p0: java.lang.String): java.lang.String + public synthetic final static method box-impl(p0: java.lang.String): Test2 + public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean + public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.String): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.String): java.lang.String + public synthetic final method unbox-impl(): java.lang.String +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable_ir.txt new file mode 100644 index 00000000000..20c34e9f340 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable_ir.txt @@ -0,0 +1,53 @@ +@kotlin.Metadata +public interface IFooBar { + // source: 'jvmDefaultEnable.kt' + public @kotlin.jvm.JvmDefault @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public @kotlin.jvm.JvmDefault @org.jetbrains.annotations.NotNull method foo(): java.lang.String +} + +@kotlin.Metadata +public interface IFooBar2 { + // source: 'jvmDefaultEnable.kt' +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class Test1 { + // source: 'jvmDefaultEnable.kt' + private final @org.jetbrains.annotations.NotNull field k: java.lang.String + private synthetic method (p0: java.lang.String): void + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public static @org.jetbrains.annotations.NotNull method bar-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public synthetic final static method box-impl(p0: java.lang.String): Test1 + public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean + public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.String): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.String): java.lang.String + public synthetic final method unbox-impl(): java.lang.String +} + +@kotlin.jvm.JvmInline +@kotlin.Metadata +public final class Test2 { + // source: 'jvmDefaultEnable.kt' + private final @org.jetbrains.annotations.NotNull field k: java.lang.String + private synthetic method (p0: java.lang.String): void + public @org.jetbrains.annotations.NotNull method bar(): java.lang.String + public static @org.jetbrains.annotations.NotNull method bar-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public synthetic final static method box-impl(p0: java.lang.String): Test2 + public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean + public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.String): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.String): java.lang.String + public synthetic final method unbox-impl(): java.lang.String +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/javaDefaultInterfaceMember.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/javaDefaultInterfaceMember.kt deleted file mode 100644 index adf140afc0e..00000000000 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/javaDefaultInterfaceMember.kt +++ /dev/null @@ -1,22 +0,0 @@ -// JVM_TARGET: 1.8 -// FILE: javaDefaultInterfaceMember.kt -interface KFoo2 : JIFoo - -interface KFooUnrelated { - fun foo() -} - -interface KFoo3 : KFoo2, KFooUnrelated { - override fun foo() {} -} - -inline class Test1(val x: Int) : JIFoo - -inline class Test2(val x: Int) : KFoo2 - -inline class Test3(val x: Int) : KFoo3 - -// FILE: JIFoo.java -public interface JIFoo { - default void foo() {} -} diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/interfaceJvmDefaultImplStubs.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/interfaceJvmDefaultImplStubs.kt index 8cda986d8d4..41c38966dc0 100644 --- a/compiler/testData/codegen/bytecodeText/inlineClasses/interfaceJvmDefaultImplStubs.kt +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/interfaceJvmDefaultImplStubs.kt @@ -25,13 +25,14 @@ inline class B(val x: Int) : A // 1 public static f-impl\(I\)Ljava/lang/String; // 1 public f\(\)Ljava/lang/String; -// 1 public static g-impl\(I\)Ljava/lang/String; +// 0 public static g-impl\(I\)Ljava/lang/String; // 0 public g\(\)Ljava/lang/String; -// 1 INVOKESTATIC B.g-impl \(I\)Ljava/lang/String; +// 0 INVOKESTATIC B.g-impl \(I\)Ljava/lang/String; // JVM_TEMPLATES: // 2 INVOKESTATIC B.f-impl \(I\)Ljava/lang/String; // JVM_IR_TEMPLATES: // 1 INVOKESTATIC B.f-impl \(I\)Ljava/lang/String; + diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index b175f9f569d..2b539076b31 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -16564,6 +16564,59 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8DefaultInterfaceMethods extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("javaDefaultMethod.kt") + public void testJavaDefaultMethod() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethod.kt"); + } + + @TestMetadata("javaDefaultMethodOverriddenByKotlin.kt") + public void testJavaDefaultMethodOverriddenByKotlin() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethodOverriddenByKotlin.kt"); + } + + @TestMetadata("jvmDefaultAll.kt") + public void testJvmDefaultAll() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAll.kt"); + } + + @TestMetadata("jvmDefaultAllPrimaryProperty.kt") + public void testJvmDefaultAllPrimaryProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllPrimaryProperty.kt"); + } + + @TestMetadata("jvmDefaultAllProperty.kt") + public void testJvmDefaultAllProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllProperty.kt"); + } + + @TestMetadata("jvmDefaultEnable.kt") + public void testJvmDefaultEnable() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnable.kt"); + } + + @TestMetadata("jvmDefaultEnablePrimaryProperty.kt") + public void testJvmDefaultEnablePrimaryProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnablePrimaryProperty.kt"); + } + + @TestMetadata("jvmDefaultEnableProperty.kt") + public void testJvmDefaultEnableProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnableProperty.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index 83948ecead1..a730a1eb31d 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -1007,11 +1007,6 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithManyKindsOfMembers.kt"); } - @TestMetadata("javaDefaultInterfaceMember.kt") - public void testJavaDefaultInterfaceMember() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/javaDefaultInterfaceMember.kt"); - } - @TestMetadata("jvmName.kt") public void testJvmName() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/jvmName.kt"); @@ -1072,6 +1067,34 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrimitive.kt"); } + @TestMetadata("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultInterfaceMembers extends AbstractBytecodeListingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInDefaultInterfaceMembers() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("javaDefaultInterfaceMember.kt") + public void testJavaDefaultInterfaceMember() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/javaDefaultInterfaceMember.kt"); + } + + @TestMetadata("jvmDefaultAll.kt") + public void testJvmDefaultAll() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll.kt"); + } + + @TestMetadata("jvmDefaultEnable.kt") + public void testJvmDefaultEnable() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable.kt"); + } + } + @TestMetadata("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 2ee2e8e18c8..a190e8c247f 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16564,6 +16564,59 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8DefaultInterfaceMethods extends AbstractLightAnalysisModeTest { + @TestMetadata("javaDefaultMethod.kt") + public void ignoreJavaDefaultMethod() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethod.kt"); + } + + @TestMetadata("javaDefaultMethodOverriddenByKotlin.kt") + public void ignoreJavaDefaultMethodOverriddenByKotlin() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethodOverriddenByKotlin.kt"); + } + + @TestMetadata("jvmDefaultAll.kt") + public void ignoreJvmDefaultAll() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAll.kt"); + } + + @TestMetadata("jvmDefaultAllPrimaryProperty.kt") + public void ignoreJvmDefaultAllPrimaryProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllPrimaryProperty.kt"); + } + + @TestMetadata("jvmDefaultAllProperty.kt") + public void ignoreJvmDefaultAllProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllProperty.kt"); + } + + @TestMetadata("jvmDefaultEnable.kt") + public void ignoreJvmDefaultEnable() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnable.kt"); + } + + @TestMetadata("jvmDefaultEnablePrimaryProperty.kt") + public void ignoreJvmDefaultEnablePrimaryProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnablePrimaryProperty.kt"); + } + + @TestMetadata("jvmDefaultEnableProperty.kt") + public void ignoreJvmDefaultEnableProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnableProperty.kt"); + } + + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 328025700e5..856d146d81d 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -15164,6 +15164,59 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8DefaultInterfaceMethods extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("javaDefaultMethod.kt") + public void testJavaDefaultMethod() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethod.kt"); + } + + @TestMetadata("javaDefaultMethodOverriddenByKotlin.kt") + public void testJavaDefaultMethodOverriddenByKotlin() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/javaDefaultMethodOverriddenByKotlin.kt"); + } + + @TestMetadata("jvmDefaultAll.kt") + public void testJvmDefaultAll() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAll.kt"); + } + + @TestMetadata("jvmDefaultAllPrimaryProperty.kt") + public void testJvmDefaultAllPrimaryProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllPrimaryProperty.kt"); + } + + @TestMetadata("jvmDefaultAllProperty.kt") + public void testJvmDefaultAllProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultAllProperty.kt"); + } + + @TestMetadata("jvmDefaultEnable.kt") + public void testJvmDefaultEnable() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnable.kt"); + } + + @TestMetadata("jvmDefaultEnablePrimaryProperty.kt") + public void testJvmDefaultEnablePrimaryProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnablePrimaryProperty.kt"); + } + + @TestMetadata("jvmDefaultEnableProperty.kt") + public void testJvmDefaultEnableProperty() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods/jvmDefaultEnableProperty.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 16f066ea6c2..74eab19f719 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -977,11 +977,6 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithManyKindsOfMembers.kt"); } - @TestMetadata("javaDefaultInterfaceMember.kt") - public void testJavaDefaultInterfaceMember() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/javaDefaultInterfaceMember.kt"); - } - @TestMetadata("jvmName.kt") public void testJvmName() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/jvmName.kt"); @@ -1042,6 +1037,34 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrimitive.kt"); } + @TestMetadata("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DefaultInterfaceMembers extends AbstractIrBytecodeListingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInDefaultInterfaceMembers() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("javaDefaultInterfaceMember.kt") + public void testJavaDefaultInterfaceMember() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/javaDefaultInterfaceMember.kt"); + } + + @TestMetadata("jvmDefaultAll.kt") + public void testJvmDefaultAll() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultAll.kt"); + } + + @TestMetadata("jvmDefaultEnable.kt") + public void testJvmDefaultEnable() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/defaultInterfaceMembers/jvmDefaultEnable.kt"); + } + } + @TestMetadata("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index e94581ca30c..ab656bc1582 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -13134,6 +13134,19 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8DefaultInterfaceMethods extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 230765ea840..191c494524a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -13134,6 +13134,19 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8DefaultInterfaceMethods extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 7892ef2e51c..82fc5e0759a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -13199,6 +13199,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8DefaultInterfaceMethods extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index c4bbcb442e3..38e97a4ec19 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -7434,6 +7434,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jvm8DefaultInterfaceMethods extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInJvm8DefaultInterfaceMethods() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/jvm8DefaultInterfaceMethods"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses/propertyDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)