Properly map super calls in typeMapper
This commit is contained in:
@@ -659,12 +659,12 @@ public class KotlinTypeMapper {
|
|||||||
baseMethodDescriptor = findBaseDeclaration(functionDescriptor).getOriginal();
|
baseMethodDescriptor = findBaseDeclaration(functionDescriptor).getOriginal();
|
||||||
ClassDescriptor ownerForDefault = (ClassDescriptor) baseMethodDescriptor.getContainingDeclaration();
|
ClassDescriptor ownerForDefault = (ClassDescriptor) baseMethodDescriptor.getContainingDeclaration();
|
||||||
ownerForDefaultImpl =
|
ownerForDefaultImpl =
|
||||||
isJvmInterface(ownerForDefault) && (state == null || !isJvm8Interface(ownerForDefault, state)) ?
|
isJvmInterface(ownerForDefault) && !isJvm8Interface(ownerForDefault) ?
|
||||||
mapDefaultImpls(ownerForDefault) : mapClass(ownerForDefault);
|
mapDefaultImpls(ownerForDefault) : mapClass(ownerForDefault);
|
||||||
|
|
||||||
if (isInterface && (superCall || descriptor.getVisibility() == Visibilities.PRIVATE || isAccessor(descriptor))) {
|
if (isInterface && (superCall || descriptor.getVisibility() == Visibilities.PRIVATE || isAccessor(descriptor))) {
|
||||||
thisClass = mapClass(currentOwner);
|
thisClass = mapClass(currentOwner);
|
||||||
if (declarationOwner instanceof JavaClassDescriptor) {
|
if (declarationOwner instanceof JavaClassDescriptor || isJvm8Interface(declarationOwner)) {
|
||||||
invokeOpcode = INVOKESPECIAL;
|
invokeOpcode = INVOKESPECIAL;
|
||||||
signature = mapSignatureSkipGeneric(functionDescriptor);
|
signature = mapSignatureSkipGeneric(functionDescriptor);
|
||||||
owner = thisClass;
|
owner = thisClass;
|
||||||
@@ -743,6 +743,10 @@ public class KotlinTypeMapper {
|
|||||||
thisClass, receiverParameterType, calleeType);
|
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) {
|
public static boolean isAccessor(@NotNull CallableMemberDescriptor descriptor) {
|
||||||
return descriptor instanceof AccessorForCallableDescriptor<?>;
|
return descriptor instanceof AccessorForCallableDescriptor<?>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()
|
||||||
|
}
|
||||||
+6
@@ -175,6 +175,12 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("compiler/testData/codegen/java8/box/jvm8/noDelegation")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user