Support interface delegation to inline class values (KT-27318)
This commit is contained in:
@@ -1582,10 +1582,13 @@ public class FunctionCodegen {
|
||||
reg += argTypes[i].getSize();
|
||||
}
|
||||
|
||||
String internalName = typeMapper.mapType(toClass).getInternalName();
|
||||
String internalName = typeMapper.mapClass(toClass).getInternalName();
|
||||
if (toClass.getKind() == ClassKind.INTERFACE) {
|
||||
iv.invokeinterface(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor());
|
||||
}
|
||||
else if (toClass.isInline()) {
|
||||
iv.invokestatic(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor(), false);
|
||||
}
|
||||
else {
|
||||
iv.invokevirtual(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor(), false);
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
interface IFoo {
|
||||
fun getO(): String
|
||||
val k: String
|
||||
|
||||
val ok: String get() = getO() + k
|
||||
}
|
||||
|
||||
inline class InlineFooImpl(val s: String): IFoo {
|
||||
override fun getO(): String = s
|
||||
override val k: String get() = "K"
|
||||
}
|
||||
|
||||
class Test(s: String) : IFoo by InlineFooImpl(s)
|
||||
|
||||
fun box() = Test("O").ok
|
||||
+5
@@ -11769,6 +11769,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineFunctionInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceImplementationByDelegation.kt")
|
||||
public void testInterfaceImplementationByDelegation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceImplementationByDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("iterateOverArrayOfInlineClassValues.kt")
|
||||
public void testIterateOverArrayOfInlineClassValues() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/iterateOverArrayOfInlineClassValues.kt");
|
||||
|
||||
+5
@@ -11769,6 +11769,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineFunctionInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceImplementationByDelegation.kt")
|
||||
public void testInterfaceImplementationByDelegation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceImplementationByDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("iterateOverArrayOfInlineClassValues.kt")
|
||||
public void testIterateOverArrayOfInlineClassValues() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/iterateOverArrayOfInlineClassValues.kt");
|
||||
|
||||
+5
@@ -11774,6 +11774,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineFunctionInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceImplementationByDelegation.kt")
|
||||
public void testInterfaceImplementationByDelegation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceImplementationByDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("iterateOverArrayOfInlineClassValues.kt")
|
||||
public void testIterateOverArrayOfInlineClassValues() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/iterateOverArrayOfInlineClassValues.kt");
|
||||
|
||||
+5
@@ -10309,6 +10309,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineFunctionInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceImplementationByDelegation.kt")
|
||||
public void testInterfaceImplementationByDelegation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceImplementationByDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("iterateOverArrayOfInlineClassValues.kt")
|
||||
public void testIterateOverArrayOfInlineClassValues() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/iterateOverArrayOfInlineClassValues.kt");
|
||||
|
||||
+5
@@ -11354,6 +11354,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineFunctionInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceImplementationByDelegation.kt")
|
||||
public void testInterfaceImplementationByDelegation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/interfaceImplementationByDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("iterateOverArrayOfInlineClassValues.kt")
|
||||
public void testIterateOverArrayOfInlineClassValues() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/iterateOverArrayOfInlineClassValues.kt");
|
||||
|
||||
Reference in New Issue
Block a user