From 9d48ecfac338992dc4cff1eb7641d6448a07d9db Mon Sep 17 00:00:00 2001 From: Mikhail Bogdanov Date: Wed, 10 Jun 2020 09:35:09 +0200 Subject: [PATCH] Make proper check for defaults on delegation to DefaultImpls --- .../kotlin/codegen/ClassBodyCodegen.java | 13 +++++---- .../defaults/interop/newAndOldSchemes2.kt | 27 +++++++++++++++++++ ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ++++ ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ++++ 4 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes2.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java index 2d4b6348253..a83d7ffc767 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java @@ -237,11 +237,14 @@ public abstract class ClassBodyCodegen extends MemberCodegen { + fun test(p: T) = "fail" + val T.prop: String + get() = "fail" +} + +// FILE: main.kt +// !JVM_DEFAULT_MODE: all +// JVM_TARGET: 1.8 +interface Foo2: Foo { + override fun test(p: 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 070c620c9fc..5a2a752a514 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java @@ -515,6 +515,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes.kt"); } + @TestMetadata("newAndOldSchemes2.kt") + public void testNewAndOldSchemes2() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes2.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 da6791d3ea9..bd5b4f3ed6f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java @@ -510,6 +510,11 @@ public class IrCompileKotlinAgainstKotlinTestGenerated extends AbstractIrCompile runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes.kt"); } + @TestMetadata("newAndOldSchemes2.kt") + public void testNewAndOldSchemes2() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newAndOldSchemes2.kt"); + } + @TestMetadata("newSchemeWithJvmDefault.kt") public void testNewSchemeWithJvmDefault() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/jvm8/defaults/interop/newSchemeWithJvmDefault.kt");