JVM IR: Avoid double mangling of function reference invoke methods
This commit is contained in:
committed by
Alexander Udalov
parent
276ffd5a4b
commit
84d78035e4
+6
@@ -19193,6 +19193,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("returnIC.kt")
|
@TestMetadata("returnIC.kt")
|
||||||
public void testReturnIC() throws Exception {
|
public void testReturnIC() throws Exception {
|
||||||
|
|||||||
+18
@@ -3572,6 +3572,24 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledInlineClassInterfaceImplementation.kt");
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledInlineClassInterfaceImplementation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappersIndy.kt")
|
||||||
|
public void testMangledSamWrappersIndy() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappersIndy.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappersOld.kt")
|
||||||
|
public void testMangledSamWrappersOld() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappersOld.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noActualCallsOfInlineFunctionsOfInlineClass.kt")
|
@TestMetadata("noActualCallsOfInlineFunctionsOfInlineClass.kt")
|
||||||
public void testNoActualCallsOfInlineFunctionsOfInlineClass() throws Exception {
|
public void testNoActualCallsOfInlineFunctionsOfInlineClass() throws Exception {
|
||||||
|
|||||||
+1
-9
@@ -574,15 +574,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
|||||||
private fun createInvokeMethod(receiverVar: IrValueDeclaration?): IrSimpleFunction =
|
private fun createInvokeMethod(receiverVar: IrValueDeclaration?): IrSimpleFunction =
|
||||||
functionReferenceClass.addFunction {
|
functionReferenceClass.addFunction {
|
||||||
setSourceRange(if (isLambda) callee else irFunctionReference)
|
setSourceRange(if (isLambda) callee else irFunctionReference)
|
||||||
name =
|
name = superMethod.name
|
||||||
if (samSuperType == null && callee.returnType.isInlineClassType() &&
|
|
||||||
context.state.functionsWithInlineClassReturnTypesMangled
|
|
||||||
) {
|
|
||||||
// For functions with inline class return type we need to mangle the invoke method.
|
|
||||||
// Otherwise, bridge lowering may fail to generate bridges for inline class types erasing to Any.
|
|
||||||
val suffix = InlineClassAbi.hashReturnSuffix(callee)
|
|
||||||
Name.identifier("${superMethod.name.asString()}-${suffix}")
|
|
||||||
} else superMethod.name
|
|
||||||
returnType = callee.returnType
|
returnType = callee.returnType
|
||||||
isSuspend = callee.isSuspend
|
isSuspend = callee.isSuspend
|
||||||
}.apply {
|
}.apply {
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
// IGNORE_BACKEND: WASM
|
||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
inline class A(val value: String)
|
||||||
|
|
||||||
|
fun interface B {
|
||||||
|
fun f(x: A): A
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun g(unit: Unit = Unit, b: B): A {
|
||||||
|
return b.f(A("Fail"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val b = { _ : A -> A("O") }
|
||||||
|
return g(b = b).value + g { A("K") }.value
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
inline class A(val value: String)
|
||||||
|
|
||||||
|
fun interface B {
|
||||||
|
fun f(x: A): A
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun g(unit: Unit = Unit, b: B): A {
|
||||||
|
return b.f(A("Fail"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val b = { _ : A -> A("OK") }
|
||||||
|
return g(b = b).value
|
||||||
|
}
|
||||||
|
|
||||||
|
// @B.class:
|
||||||
|
// 1 public abstract f-ZsE1S_E\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// @MangledSamWrappersKt.class:
|
||||||
|
// 3 INVOKEINTERFACE B.f-ZsE1S_E \(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// @MangledSamWrappersKt$sam$B$0.class:
|
||||||
|
// public final synthetic f-ZsE1S_E\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
|
||||||
|
// JVM_TEMPLATES:
|
||||||
|
// @MangledSamWrappersKt$box$b$1.class:
|
||||||
|
// 1 public final invoke\(Ljava/lang/String;\)LA;
|
||||||
|
|
||||||
|
// JVM_IR_TEMPLATES:
|
||||||
|
// @MangledSamWrappersKt$box$b$1.class:
|
||||||
|
// 0 public final invoke-ZsE1S_E-ZsE1S_E\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// 1 public final invoke-ZsE1S_E\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// 1 public synthetic bridge invoke\(Ljava/lang/Object;\)Ljava/lang/Object;
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
// LAMBDAS: INDY
|
||||||
|
|
||||||
|
inline class A(val value: String?)
|
||||||
|
|
||||||
|
fun interface B {
|
||||||
|
fun f(x: A): A
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun g(unit: Unit = Unit, b: B): A {
|
||||||
|
return b.f(A("Fail"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val b = { _ : A -> A("OK") }
|
||||||
|
return g(b = b).value!!
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0 public final invoke-ZsE1S_E-ZsE1S_E\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// 0 public final invoke-ZsE1S_E\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// 0 public synthetic bridge invoke\(Ljava/lang/Object;\)Ljava/lang/Object;
|
||||||
|
|
||||||
|
// @B.class:
|
||||||
|
// 1 public abstract f-ZsE1S_E\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// @MangledSamWrappersKt.class:
|
||||||
|
// 3 INVOKEINTERFACE B.f-ZsE1S_E \(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// 1 private final static box\$lambda-0\(LA;\)LA;
|
||||||
|
// @MangledSamWrappersKt$sam$B$0.class:
|
||||||
|
// public final synthetic f-ZsE1S_E\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
// USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||||
|
inline class A(val value: String)
|
||||||
|
|
||||||
|
fun interface B {
|
||||||
|
fun f(x: A): A
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun g(unit: Unit = Unit, b: B): A {
|
||||||
|
return b.f(A("Fail"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val b = { _ : A -> A("OK") }
|
||||||
|
return g(b = b).value
|
||||||
|
}
|
||||||
|
|
||||||
|
// @B.class:
|
||||||
|
// 1 public abstract f-iUtXLc0\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// @MangledSamWrappersKt.class:
|
||||||
|
// 3 INVOKEINTERFACE B.f-iUtXLc0 \(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// @MangledSamWrappersKt$sam$B$0.class:
|
||||||
|
// public final synthetic f-iUtXLc0\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
|
||||||
|
// JVM_TEMPLATES:
|
||||||
|
// @MangledSamWrappersKt$box$b$1.class:
|
||||||
|
// 1 public final invoke\(Ljava/lang/String;\)LA;
|
||||||
|
|
||||||
|
// JVM_IR_TEMPLATES:
|
||||||
|
// @MangledSamWrappersKt$box$b$1.class:
|
||||||
|
// 0 public final invoke-iUtXLc0-iUtXLc0\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// 1 public final invoke-iUtXLc0\(Ljava/lang/String;\)Ljava/lang/String;
|
||||||
|
// 1 public synthetic bridge invoke\(Ljava/lang/Object;\)Ljava/lang/Object;
|
||||||
+6
@@ -19169,6 +19169,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("returnIC.kt")
|
@TestMetadata("returnIC.kt")
|
||||||
public void testReturnIC() throws Exception {
|
public void testReturnIC() throws Exception {
|
||||||
|
|||||||
+18
@@ -3440,6 +3440,24 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledInlineClassInterfaceImplementation.kt");
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledInlineClassInterfaceImplementation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappersIndy.kt")
|
||||||
|
public void testMangledSamWrappersIndy() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappersIndy.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappersOld.kt")
|
||||||
|
public void testMangledSamWrappersOld() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappersOld.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noActualCallsOfInlineFunctionsOfInlineClass.kt")
|
@TestMetadata("noActualCallsOfInlineFunctionsOfInlineClass.kt")
|
||||||
public void testNoActualCallsOfInlineFunctionsOfInlineClass() throws Exception {
|
public void testNoActualCallsOfInlineFunctionsOfInlineClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -19193,6 +19193,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("returnIC.kt")
|
@TestMetadata("returnIC.kt")
|
||||||
public void testReturnIC() throws Exception {
|
public void testReturnIC() throws Exception {
|
||||||
|
|||||||
+18
@@ -3572,6 +3572,24 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledInlineClassInterfaceImplementation.kt");
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledInlineClassInterfaceImplementation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappersIndy.kt")
|
||||||
|
public void testMangledSamWrappersIndy() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappersIndy.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("mangledSamWrappersOld.kt")
|
||||||
|
public void testMangledSamWrappersOld() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/mangledSamWrappersOld.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noActualCallsOfInlineFunctionsOfInlineClass.kt")
|
@TestMetadata("noActualCallsOfInlineFunctionsOfInlineClass.kt")
|
||||||
public void testNoActualCallsOfInlineFunctionsOfInlineClass() throws Exception {
|
public void testNoActualCallsOfInlineFunctionsOfInlineClass() throws Exception {
|
||||||
|
|||||||
+5
@@ -15899,6 +15899,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void ignoreMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("returnIC.kt")
|
@TestMetadata("returnIC.kt")
|
||||||
public void ignoreReturnIC() throws Exception {
|
public void ignoreReturnIC() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -14056,6 +14056,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("returnIC.kt")
|
@TestMetadata("returnIC.kt")
|
||||||
public void testReturnIC() throws Exception {
|
public void testReturnIC() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||||
|
|||||||
Generated
+5
@@ -13467,6 +13467,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("returnIC.kt")
|
@TestMetadata("returnIC.kt")
|
||||||
public void testReturnIC() throws Exception {
|
public void testReturnIC() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||||
|
|||||||
Generated
+5
@@ -13532,6 +13532,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("returnIC.kt")
|
@TestMetadata("returnIC.kt")
|
||||||
public void testReturnIC() throws Exception {
|
public void testReturnIC() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -7542,6 +7542,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mangledSamWrappers.kt")
|
||||||
|
public void testMangledSamWrappers() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/mangledSamWrappers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("returnIC.kt")
|
@TestMetadata("returnIC.kt")
|
||||||
public void testReturnIC() throws Exception {
|
public void testReturnIC() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user