JVM KT-41150: Fix backward compatibility for inline vals in inline class
In 1.3.x, for inline class member inline vals 'getFoo-impl' method was generated in corresponding inline class. Since 1.4.0, getters for properties returning inline class values are mangled (so corresponding getters are named 'getFoo-<mangling_hash>'. However, to maintain backward compatibility with libraries compiled with 1.3.x, inliner should be able to find 'getFoo-impl' method in the bytecode.
This commit is contained in:
@@ -658,6 +658,10 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
if (nameWithoutManglingSuffix != null) {
|
||||
methodNode = getMethodNode(bytes, nameWithoutManglingSuffix, asmMethod.descriptor, classType)
|
||||
}
|
||||
if (methodNode == null) {
|
||||
val nameWithImplSuffix = "$nameWithoutManglingSuffix-impl"
|
||||
methodNode = getMethodNode(bytes, nameWithImplSuffix, asmMethod.descriptor, classType)
|
||||
}
|
||||
}
|
||||
return methodNode
|
||||
}
|
||||
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline class IC1(val x: String) {
|
||||
inline val test get() = IC2(x)
|
||||
}
|
||||
|
||||
inline class IC2(val x: String)
|
||||
|
||||
|
||||
// FILE: 2.kt
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
|
||||
import test.*
|
||||
|
||||
fun box() : String =
|
||||
IC1("OK").test.x
|
||||
+5
@@ -1891,6 +1891,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithInlineValReturningInlineClass.kt")
|
||||
public void testInlineClassWithInlineValReturningInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineClassWithInlineValReturningInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionInsideInlineClassesBox.kt")
|
||||
public void testInlineFunctionInsideInlineClassesBox() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineFunctionInsideInlineClassesBox.kt");
|
||||
|
||||
Generated
+5
@@ -1891,6 +1891,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithInlineValReturningInlineClass.kt")
|
||||
public void testInlineClassWithInlineValReturningInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineClassWithInlineValReturningInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionInsideInlineClassesBox.kt")
|
||||
public void testInlineFunctionInsideInlineClassesBox() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineFunctionInsideInlineClassesBox.kt");
|
||||
|
||||
+5
@@ -1891,6 +1891,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithInlineValReturningInlineClass.kt")
|
||||
public void testInlineClassWithInlineValReturningInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineClassWithInlineValReturningInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionInsideInlineClassesBox.kt")
|
||||
public void testInlineFunctionInsideInlineClassesBox() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineFunctionInsideInlineClassesBox.kt");
|
||||
|
||||
Generated
+5
@@ -1891,6 +1891,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithInlineValReturningInlineClass.kt")
|
||||
public void testInlineClassWithInlineValReturningInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineClassWithInlineValReturningInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionInsideInlineClassesBox.kt")
|
||||
public void testInlineFunctionInsideInlineClassesBox() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineFunctionInsideInlineClassesBox.kt");
|
||||
|
||||
Generated
+5
@@ -1691,6 +1691,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithInlineValReturningInlineClass.kt")
|
||||
public void testInlineClassWithInlineValReturningInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineClassWithInlineValReturningInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionInsideInlineClassesBox.kt")
|
||||
public void testInlineFunctionInsideInlineClassesBox() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineFunctionInsideInlineClassesBox.kt");
|
||||
|
||||
Generated
+5
@@ -1691,6 +1691,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithInlineValReturningInlineClass.kt")
|
||||
public void testInlineClassWithInlineValReturningInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineClassWithInlineValReturningInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionInsideInlineClassesBox.kt")
|
||||
public void testInlineFunctionInsideInlineClassesBox() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineFunctionInsideInlineClassesBox.kt");
|
||||
|
||||
+5
@@ -1691,6 +1691,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithInlineValReturningInlineClass.kt")
|
||||
public void testInlineClassWithInlineValReturningInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineClassWithInlineValReturningInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionInsideInlineClassesBox.kt")
|
||||
public void testInlineFunctionInsideInlineClassesBox() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/inlineClasses/inlineFunctionInsideInlineClassesBox.kt");
|
||||
|
||||
Reference in New Issue
Block a user