From af3bda51ec229b4f15023a31642f44234fe986c4 Mon Sep 17 00:00:00 2001 From: Mikhail Bogdanov Date: Fri, 19 Jun 2020 15:54:23 +0200 Subject: [PATCH] Fix compilation on mixed hierarchies in compatibility mode --- .../kotlin/codegen/ClassBodyCodegen.java | 12 ++------- .../kotlin/codegen/FunctionCodegen.java | 5 ++-- .../jvm/annotations/jvmAnnotationUtil.kt | 13 ++++++--- .../interop/newAndOldSchemes2Compatibility.kt | 27 +++++++++++++++++++ ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ++++ ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ++++ 6 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes2Compatibility.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java index cab52ea6fd5..c8e6e9732f3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java @@ -10,7 +10,6 @@ import kotlin.collections.CollectionsKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.backend.common.CodegenUtil; -import org.jetbrains.kotlin.backend.common.bridges.ImplKt; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.codegen.context.ClassContext; import org.jetbrains.kotlin.codegen.state.GenerationState; @@ -39,7 +38,6 @@ import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedS import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration; import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE; import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL; -import static org.jetbrains.kotlin.util.DeclarationUtilKt.findImplementationFromInterface; import static org.jetbrains.kotlin.util.DeclarationUtilKt.findInterfaceImplementation; public abstract class ClassBodyCodegen extends MemberCodegen { @@ -239,14 +237,8 @@ public abstract class ClassBodyCodegen extends MemberCodegen { + fun test(p: T) = "fail" + val T.prop: String + get() = "fail" +} + +// FILE: main.kt +// !JVM_DEFAULT_MODE: all-compatibility +// JVM_TARGET: 1.8 +interface Foo2: Foo { + override fun test(p: String) : String = p + + override val String.prop: String + get() = this +} + +interface Foo3: Foo, Foo2 + +class Base : Foo3 + +fun box(): String { + val base = Base() + return base.test("O") + with(base) { "K".prop } +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java index 5a2a752a514..deba6983d82 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java @@ -520,6 +520,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes2.kt"); } + @TestMetadata("newAndOldSchemes2Compatibility.kt") + public void testNewAndOldSchemes2Compatibility() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes2Compatibility.kt"); + } + @TestMetadata("newSchemeWithJvmDefault.kt") public void testNewSchemeWithJvmDefault() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newSchemeWithJvmDefault.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java index bd5b4f3ed6f..b07d8fc7748 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java @@ -515,6 +515,11 @@ public class IrCompileKotlinAgainstKotlinTestGenerated extends AbstractIrCompile runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes2.kt"); } + @TestMetadata("newAndOldSchemes2Compatibility.kt") + public void testNewAndOldSchemes2Compatibility() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes2Compatibility.kt"); + } + @TestMetadata("newSchemeWithJvmDefault.kt") public void testNewSchemeWithJvmDefault() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newSchemeWithJvmDefault.kt");