Make proper check for defaults on delegation to DefaultImpls
This commit is contained in:
@@ -237,11 +237,14 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
|
||||
boolean isErasedInlineClass
|
||||
) {
|
||||
// Skip Java 8 default methods
|
||||
if (CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(interfaceFun) ||
|
||||
JvmAnnotationUtilKt.isCallableMemberCompiledToJvmDefault(
|
||||
DescriptorUtils.unwrapFakeOverrideToAnyDeclaration(interfaceFun), state.getJvmDefaultMode()
|
||||
)
|
||||
) {
|
||||
if (CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(interfaceFun)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CallableMemberDescriptor actualImplementation =
|
||||
interfaceFun.getKind().isReal() ? interfaceFun : ImplKt.findImplementationFromInterface(interfaceFun);
|
||||
assert actualImplementation != null : "Can't find actual implementation for " + interfaceFun;
|
||||
if (JvmAnnotationUtilKt.isCallableMemberCompiledToJvmDefault(actualImplementation, state.getJvmDefaultMode())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: 1.kt
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
|
||||
interface Foo<T> {
|
||||
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<String> {
|
||||
override fun test(p: String) = p
|
||||
|
||||
override val String.prop: String
|
||||
get() = this
|
||||
}
|
||||
|
||||
interface Foo3: Foo<String>, Foo2
|
||||
|
||||
class Base : Foo3
|
||||
|
||||
fun box(): String {
|
||||
val base = Base()
|
||||
return base.test("O") + with(base) { "K".prop }
|
||||
}
|
||||
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user