JVM IR: do not attempt to mangle function expressions
For some reasons, lambdas and function expressions are represented slightly differently in psi2ir. Lambdas are translated to a block with a function of origin LOCAL_FUNCTION_FOR_LAMBDA and name "<anonymous>", but function expressions are translated to a block with DEFINED function "<no name provided>". Tweak the condition for detecting local functions a bit, to avoid similar situation in the future if we add some other origins for local functions. #KT-48207 Fixed
This commit is contained in:
+6
@@ -18606,6 +18606,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("functionExpression.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/functionExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||||
|
|||||||
+2
-3
@@ -57,11 +57,10 @@ class MemoizedInlineClassReplacements(
|
|||||||
storageManager.createMemoizedFunctionWithNullableValues {
|
storageManager.createMemoizedFunctionWithNullableValues {
|
||||||
when {
|
when {
|
||||||
// Don't mangle anonymous or synthetic functions
|
// Don't mangle anonymous or synthetic functions
|
||||||
it.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA ||
|
(it.isLocal && it is IrSimpleFunction && it.overriddenSymbols.isEmpty()) ||
|
||||||
(it.origin == IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR && it.visibility == DescriptorVisibilities.LOCAL) ||
|
(it.origin == IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR && it.visibility == DescriptorVisibilities.LOCAL) ||
|
||||||
it.isStaticInlineClassReplacement ||
|
it.isStaticInlineClassReplacement ||
|
||||||
it.origin.isSynthetic ||
|
it.origin.isSynthetic ->
|
||||||
it.origin == IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE ->
|
|
||||||
null
|
null
|
||||||
|
|
||||||
it.isInlineClassFieldGetter ->
|
it.isInlineClassFieldGetter ->
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
inline fun new(init: (Z) -> Unit): Z = Z(42)
|
||||||
|
|
||||||
|
inline class Z(val value: Int)
|
||||||
|
|
||||||
|
fun box(): String =
|
||||||
|
if (new(fun(z: Z) {}).value == 42) "OK" else "Fail"
|
||||||
+6
@@ -18474,6 +18474,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("functionExpression.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/functionExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||||
|
|||||||
+6
@@ -18606,6 +18606,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("functionExpression.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/functionExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||||
|
|||||||
+5
@@ -15364,6 +15364,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionExpression.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/functionExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -13383,6 +13383,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionExpression.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/functionExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
||||||
|
|||||||
Generated
+5
@@ -12789,6 +12789,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionExpression.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/functionExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
||||||
|
|||||||
Generated
+5
@@ -12854,6 +12854,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionExpression.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/functionExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -6899,6 +6899,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionExpression.kt")
|
||||||
|
public void testFunctionExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/functionExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user