JVM IR: do not mangle synthetic methods with inline class parameters

For example, synthetic `$annotations` methods for properties were
previously mangled to `$annotations-...`, which breaks annotation
loader, and fails an assert in ClassCodegen.generateMethod.
This commit is contained in:
Alexander Udalov
2019-12-02 18:39:41 +01:00
parent 66ffdf1b2d
commit f869be6a71
8 changed files with 48 additions and 1 deletions
@@ -51,7 +51,7 @@ class MemoizedInlineClassReplacements {
it.isSyntheticInlineClassMember ||
it.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA ||
it.origin == IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR ||
it.origin == JvmLoweredDeclarationOrigin.POLYMORPHIC_SIGNATURE_INSTANTIATION -> null
it.origin.isSynthetic -> null
it.hasMethodReplacement -> createMethodReplacement(it)
it.hasStaticReplacement -> createStaticReplacement(it)
else -> null
@@ -0,0 +1,17 @@
// IGNORE_BACKEND_FIR: JVM_IR
@Target(AnnotationTarget.PROPERTY)
annotation class Anno
inline class Z(val s: String)
class A {
@Anno
val Z.r: String get() = s
}
fun box(): String {
with(A()) {
return Z("OK").r
}
}
@@ -12408,6 +12408,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("annotatedMemberExtensionProperty.kt")
public void testAnnotatedMemberExtensionProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/annotatedMemberExtensionProperty.kt");
}
@TestMetadata("boundCallableReferencePassedToInlineFunction.kt")
public void testBoundCallableReferencePassedToInlineFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt");
@@ -12423,6 +12423,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("annotatedMemberExtensionProperty.kt")
public void testAnnotatedMemberExtensionProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/annotatedMemberExtensionProperty.kt");
}
@TestMetadata("boundCallableReferencePassedToInlineFunction.kt")
public void testBoundCallableReferencePassedToInlineFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt");
@@ -11258,6 +11258,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("annotatedMemberExtensionProperty.kt")
public void testAnnotatedMemberExtensionProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/annotatedMemberExtensionProperty.kt");
}
@TestMetadata("boundCallableReferencePassedToInlineFunction.kt")
public void testBoundCallableReferencePassedToInlineFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt");
@@ -11258,6 +11258,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("annotatedMemberExtensionProperty.kt")
public void testAnnotatedMemberExtensionProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/annotatedMemberExtensionProperty.kt");
}
@TestMetadata("boundCallableReferencePassedToInlineFunction.kt")
public void testBoundCallableReferencePassedToInlineFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt");
@@ -9743,6 +9743,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
}
@TestMetadata("annotatedMemberExtensionProperty.kt")
public void testAnnotatedMemberExtensionProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/annotatedMemberExtensionProperty.kt");
}
@TestMetadata("boundCallableReferencePassedToInlineFunction.kt")
public void testBoundCallableReferencePassedToInlineFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt");
@@ -10883,6 +10883,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("annotatedMemberExtensionProperty.kt")
public void testAnnotatedMemberExtensionProperty() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/annotatedMemberExtensionProperty.kt");
}
@TestMetadata("boundCallableReferencePassedToInlineFunction.kt")
public void testBoundCallableReferencePassedToInlineFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt");