Fix default interface generic extension fun call with inline class type
When we've determined that we are going to invoke an erased inline class
method ('static foo-impl(this, ...)' in inline class), keep track of it
so that the remaining type mapping logic proceeds correctly.
#KT-26998 Fixed Target versions 1.3.20
This commit is contained in:
@@ -862,6 +862,9 @@ public class KotlinTypeMapper {
|
||||
}
|
||||
else {
|
||||
boolean toInlinedErasedClass = currentOwner.isInline() && !isAccessor(functionDescriptor);
|
||||
if (toInlinedErasedClass) {
|
||||
functionDescriptor = descriptor;
|
||||
}
|
||||
|
||||
boolean isStaticInvocation = (isStaticDeclaration(functionDescriptor) &&
|
||||
!(functionDescriptor instanceof ImportedFromObjectCallableDescriptor)) ||
|
||||
@@ -890,7 +893,7 @@ public class KotlinTypeMapper {
|
||||
: functionDescriptor.getOriginal();
|
||||
|
||||
signature = toInlinedErasedClass
|
||||
? mapSignatureForInlineErasedClassSkipGeneric(descriptor.getOriginal())
|
||||
? mapSignatureForInlineErasedClassSkipGeneric(functionToCall)
|
||||
: mapSignatureSkipGeneric(functionToCall);
|
||||
returnKotlinType = functionToCall.getReturnType();
|
||||
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
interface IFoo<T : IFoo<T>> {
|
||||
fun T.foo(): String = bar()
|
||||
fun bar(): String
|
||||
}
|
||||
|
||||
inline class Z(val x: Int) : IFoo<Z> {
|
||||
override fun bar(): String = "OK"
|
||||
}
|
||||
|
||||
inline class L(val x: Long) : IFoo<L> {
|
||||
override fun bar(): String = "OK"
|
||||
}
|
||||
|
||||
inline class S(val x: String) : IFoo<S> {
|
||||
override fun bar(): String = x
|
||||
}
|
||||
|
||||
fun Z.testZ() {
|
||||
if (Z(42).foo() != "OK") throw AssertionError()
|
||||
}
|
||||
|
||||
fun L.testL() {
|
||||
if (L(4L).foo() != "OK") throw AssertionError()
|
||||
}
|
||||
|
||||
fun S.testS() {
|
||||
if (S("OK").foo() != "OK") throw AssertionError()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Z(42).testZ()
|
||||
L(4L).testL()
|
||||
S("").testS()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -12087,6 +12087,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/defaultInterfaceMethodCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceExtensionFunCall.kt")
|
||||
public void testGenericDefaultInterfaceExtensionFunCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceExtensionFunCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceMethodCall.kt")
|
||||
public void testGenericDefaultInterfaceMethodCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceMethodCall.kt");
|
||||
|
||||
+5
@@ -12087,6 +12087,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/defaultInterfaceMethodCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceExtensionFunCall.kt")
|
||||
public void testGenericDefaultInterfaceExtensionFunCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceExtensionFunCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceMethodCall.kt")
|
||||
public void testGenericDefaultInterfaceMethodCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceMethodCall.kt");
|
||||
|
||||
+5
@@ -12092,6 +12092,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/defaultInterfaceMethodCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceExtensionFunCall.kt")
|
||||
public void testGenericDefaultInterfaceExtensionFunCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceExtensionFunCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceMethodCall.kt")
|
||||
public void testGenericDefaultInterfaceMethodCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceMethodCall.kt");
|
||||
|
||||
+5
@@ -10612,6 +10612,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/defaultInterfaceMethodCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceExtensionFunCall.kt")
|
||||
public void testGenericDefaultInterfaceExtensionFunCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceExtensionFunCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceMethodCall.kt")
|
||||
public void testGenericDefaultInterfaceMethodCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceMethodCall.kt");
|
||||
|
||||
+5
@@ -11672,6 +11672,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/defaultInterfaceMethodCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceExtensionFunCall.kt")
|
||||
public void testGenericDefaultInterfaceExtensionFunCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceExtensionFunCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericDefaultInterfaceMethodCall.kt")
|
||||
public void testGenericDefaultInterfaceMethodCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceMethodCalls/genericDefaultInterfaceMethodCall.kt");
|
||||
|
||||
Reference in New Issue
Block a user