diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index 21a03210b73..6a44cd96287 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -659,12 +659,12 @@ public class KotlinTypeMapper { baseMethodDescriptor = findBaseDeclaration(functionDescriptor).getOriginal(); ClassDescriptor ownerForDefault = (ClassDescriptor) baseMethodDescriptor.getContainingDeclaration(); ownerForDefaultImpl = - isJvmInterface(ownerForDefault) && (state == null || !isJvm8Interface(ownerForDefault, state)) ? + isJvmInterface(ownerForDefault) && !isJvm8Interface(ownerForDefault) ? mapDefaultImpls(ownerForDefault) : mapClass(ownerForDefault); if (isInterface && (superCall || descriptor.getVisibility() == Visibilities.PRIVATE || isAccessor(descriptor))) { thisClass = mapClass(currentOwner); - if (declarationOwner instanceof JavaClassDescriptor) { + if (declarationOwner instanceof JavaClassDescriptor || isJvm8Interface(declarationOwner)) { invokeOpcode = INVOKESPECIAL; signature = mapSignatureSkipGeneric(functionDescriptor); owner = thisClass; @@ -743,6 +743,10 @@ public class KotlinTypeMapper { thisClass, receiverParameterType, calleeType); } + private boolean isJvm8Interface(@NotNull ClassDescriptor ownerForDefault) { + return isJvmInterface(ownerForDefault) && (state != null && JvmCodegenUtil.isJvm8Interface(ownerForDefault, state)); + } + public static boolean isAccessor(@NotNull CallableMemberDescriptor descriptor) { return descriptor instanceof AccessorForCallableDescriptor; } diff --git a/compiler/testData/codegen/java8/box/jvm8/superCall.kt b/compiler/testData/codegen/java8/box/jvm8/superCall.kt new file mode 100644 index 00000000000..6bff699ec15 --- /dev/null +++ b/compiler/testData/codegen/java8/box/jvm8/superCall.kt @@ -0,0 +1,24 @@ +// JVM_TARGET: 1.8 + + +interface Test { + fun test(): String { + return "OK" + } +} + +interface Test2 : Test { + override fun test(): String { + return super.test() + } +} + + +class TestClass : Test2 { + +} + + +fun box(): String { + return TestClass().test() +} \ No newline at end of file diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java index 086b3bffb32..16ef6108147 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java @@ -175,6 +175,12 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg doTest(fileName); } + @TestMetadata("superCall.kt") + public void testSuperCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/superCall.kt"); + doTest(fileName); + } + @TestMetadata("compiler/testData/codegen/java8/box/jvm8/noDelegation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)