JVM Codegen: Mark line number before calling of indy in SAM Conversion
Fixes: KT-62965
This commit is contained in:
+6
@@ -4612,6 +4612,12 @@ public class FirLightTreeBytecodeTextTestGenerated extends AbstractFirLightTreeB
|
||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt61768.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt62965.kt")
|
||||
public void testKt62965() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt62965.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("singleThen.kt")
|
||||
public void testSingleThen() throws Exception {
|
||||
|
||||
+6
@@ -4612,6 +4612,12 @@ public class FirPsiBytecodeTextTestGenerated extends AbstractFirPsiBytecodeTextT
|
||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt61768.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt62965.kt")
|
||||
public void testKt62965() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt62965.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("singleThen.kt")
|
||||
public void testSingleThen() throws Exception {
|
||||
|
||||
+5
-3
@@ -180,7 +180,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
||||
.getLambdaMetafactoryArguments(reference, samSuperType, false)
|
||||
if (lambdaMetafactoryArguments is LambdaMetafactoryArguments) {
|
||||
return wrapSamConversionArgumentWithIndySamConversion(expression) { samType ->
|
||||
wrapWithIndySamConversion(samType, lambdaMetafactoryArguments)
|
||||
wrapWithIndySamConversion(samType, lambdaMetafactoryArguments, expression.startOffset, expression.endOffset)
|
||||
}
|
||||
} else if (lambdaMetafactoryArguments is MetafactoryArgumentsResult.Failure.FunctionHazard) {
|
||||
// Try wrapping function with a proxy local function and see if that helps.
|
||||
@@ -399,11 +399,13 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
||||
|
||||
private fun wrapWithIndySamConversion(
|
||||
samType: IrType,
|
||||
lambdaMetafactoryArguments: LambdaMetafactoryArguments
|
||||
lambdaMetafactoryArguments: LambdaMetafactoryArguments,
|
||||
startOffset: Int = UNDEFINED_OFFSET,
|
||||
endOffset:Int = UNDEFINED_OFFSET
|
||||
): IrCall {
|
||||
val notNullSamType = samType.makeNotNull()
|
||||
.removeAnnotations { it.type.classFqName in specialNullabilityAnnotationsFqNames }
|
||||
return context.createJvmIrBuilder(currentScope!!).run {
|
||||
return context.createJvmIrBuilder(currentScope!!, startOffset, endOffset).run {
|
||||
// See [org.jetbrains.kotlin.backend.jvm.JvmSymbols::indyLambdaMetafactoryIntrinsic].
|
||||
irCall(jvmIndyLambdaMetafactoryIntrinsic, notNullSamType).apply {
|
||||
putTypeArgument(0, notNullSamType)
|
||||
|
||||
+9
-9
@@ -18,15 +18,15 @@ MODULE main
|
||||
*L
|
||||
1#1,17:1
|
||||
24#2:18
|
||||
15#3:19
|
||||
1#4:20
|
||||
14#3,2:19
|
||||
1#4:21
|
||||
*S KotlinDebug
|
||||
*F
|
||||
+ 1 2.kt
|
||||
_2Kt
|
||||
*L
|
||||
24#1:19
|
||||
24#1:20
|
||||
24#1:19,2
|
||||
24#1:21
|
||||
*E
|
||||
} )
|
||||
K2
|
||||
@@ -46,15 +46,15 @@ MODULE main
|
||||
*L
|
||||
1#1,17:1
|
||||
24#2:18
|
||||
26#2:21
|
||||
15#3:19
|
||||
1#4:20
|
||||
26#2:22
|
||||
14#3,2:19
|
||||
1#4:21
|
||||
*S KotlinDebug
|
||||
*F
|
||||
+ 1 2.kt
|
||||
_2Kt
|
||||
*L
|
||||
24#1:19
|
||||
24#1:20
|
||||
24#1:19,2
|
||||
24#1:21
|
||||
*E
|
||||
} )
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
|
||||
fun foo() {
|
||||
Runnable {
|
||||
}.run()
|
||||
}
|
||||
|
||||
// 1 LINENUMBER 4 L0\n +INVOKEDYNAMIC run\(\)Ljava/lang/Runnable
|
||||
+6
@@ -11381,6 +11381,12 @@ public class JvmAbiConsistencyTestRestGenerated extends AbstractJvmAbiConsistenc
|
||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt61768.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt62965.kt")
|
||||
public void testKt62965() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt62965.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("singleThen.kt")
|
||||
public void testSingleThen() throws Exception {
|
||||
|
||||
+6
@@ -4612,6 +4612,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt61768.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt62965.kt")
|
||||
public void testKt62965() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt62965.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("singleThen.kt")
|
||||
public void testSingleThen() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user