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");
|
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
|
@Test
|
||||||
@TestMetadata("singleThen.kt")
|
@TestMetadata("singleThen.kt")
|
||||||
public void testSingleThen() throws Exception {
|
public void testSingleThen() throws Exception {
|
||||||
|
|||||||
+6
@@ -4612,6 +4612,12 @@ public class FirPsiBytecodeTextTestGenerated extends AbstractFirPsiBytecodeTextT
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt61768.kt");
|
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
|
@Test
|
||||||
@TestMetadata("singleThen.kt")
|
@TestMetadata("singleThen.kt")
|
||||||
public void testSingleThen() throws Exception {
|
public void testSingleThen() throws Exception {
|
||||||
|
|||||||
+5
-3
@@ -180,7 +180,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
|||||||
.getLambdaMetafactoryArguments(reference, samSuperType, false)
|
.getLambdaMetafactoryArguments(reference, samSuperType, false)
|
||||||
if (lambdaMetafactoryArguments is LambdaMetafactoryArguments) {
|
if (lambdaMetafactoryArguments is LambdaMetafactoryArguments) {
|
||||||
return wrapSamConversionArgumentWithIndySamConversion(expression) { samType ->
|
return wrapSamConversionArgumentWithIndySamConversion(expression) { samType ->
|
||||||
wrapWithIndySamConversion(samType, lambdaMetafactoryArguments)
|
wrapWithIndySamConversion(samType, lambdaMetafactoryArguments, expression.startOffset, expression.endOffset)
|
||||||
}
|
}
|
||||||
} else if (lambdaMetafactoryArguments is MetafactoryArgumentsResult.Failure.FunctionHazard) {
|
} else if (lambdaMetafactoryArguments is MetafactoryArgumentsResult.Failure.FunctionHazard) {
|
||||||
// Try wrapping function with a proxy local function and see if that helps.
|
// 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(
|
private fun wrapWithIndySamConversion(
|
||||||
samType: IrType,
|
samType: IrType,
|
||||||
lambdaMetafactoryArguments: LambdaMetafactoryArguments
|
lambdaMetafactoryArguments: LambdaMetafactoryArguments,
|
||||||
|
startOffset: Int = UNDEFINED_OFFSET,
|
||||||
|
endOffset:Int = UNDEFINED_OFFSET
|
||||||
): IrCall {
|
): IrCall {
|
||||||
val notNullSamType = samType.makeNotNull()
|
val notNullSamType = samType.makeNotNull()
|
||||||
.removeAnnotations { it.type.classFqName in specialNullabilityAnnotationsFqNames }
|
.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].
|
// See [org.jetbrains.kotlin.backend.jvm.JvmSymbols::indyLambdaMetafactoryIntrinsic].
|
||||||
irCall(jvmIndyLambdaMetafactoryIntrinsic, notNullSamType).apply {
|
irCall(jvmIndyLambdaMetafactoryIntrinsic, notNullSamType).apply {
|
||||||
putTypeArgument(0, notNullSamType)
|
putTypeArgument(0, notNullSamType)
|
||||||
|
|||||||
+9
-9
@@ -18,15 +18,15 @@ MODULE main
|
|||||||
*L
|
*L
|
||||||
1#1,17:1
|
1#1,17:1
|
||||||
24#2:18
|
24#2:18
|
||||||
15#3:19
|
14#3,2:19
|
||||||
1#4:20
|
1#4:21
|
||||||
*S KotlinDebug
|
*S KotlinDebug
|
||||||
*F
|
*F
|
||||||
+ 1 2.kt
|
+ 1 2.kt
|
||||||
_2Kt
|
_2Kt
|
||||||
*L
|
*L
|
||||||
24#1:19
|
24#1:19,2
|
||||||
24#1:20
|
24#1:21
|
||||||
*E
|
*E
|
||||||
} )
|
} )
|
||||||
K2
|
K2
|
||||||
@@ -46,15 +46,15 @@ MODULE main
|
|||||||
*L
|
*L
|
||||||
1#1,17:1
|
1#1,17:1
|
||||||
24#2:18
|
24#2:18
|
||||||
26#2:21
|
26#2:22
|
||||||
15#3:19
|
14#3,2:19
|
||||||
1#4:20
|
1#4:21
|
||||||
*S KotlinDebug
|
*S KotlinDebug
|
||||||
*F
|
*F
|
||||||
+ 1 2.kt
|
+ 1 2.kt
|
||||||
_2Kt
|
_2Kt
|
||||||
*L
|
*L
|
||||||
24#1:19
|
24#1:19,2
|
||||||
24#1:20
|
24#1:21
|
||||||
*E
|
*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");
|
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
|
@Test
|
||||||
@TestMetadata("singleThen.kt")
|
@TestMetadata("singleThen.kt")
|
||||||
public void testSingleThen() throws Exception {
|
public void testSingleThen() throws Exception {
|
||||||
|
|||||||
+6
@@ -4612,6 +4612,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/lineNumbers/kt61768.kt");
|
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
|
@Test
|
||||||
@TestMetadata("singleThen.kt")
|
@TestMetadata("singleThen.kt")
|
||||||
public void testSingleThen() throws Exception {
|
public void testSingleThen() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user