Fix for KT-17588: Compiler error while optimizer tries to get rid of captured variable
#KT-17588 Fixed
This commit is contained in:
+1
-1
@@ -230,7 +230,7 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
private fun findCleanInstructions(refValue: CapturedVarDescriptor, oldVarIndex: Int, instructions: InsnList): List<VarInsnNode> {
|
||||
val cleanInstructions =
|
||||
InsnSequence(instructions).filterIsInstance<VarInsnNode>().filter {
|
||||
it.`var` == oldVarIndex
|
||||
it.opcode == Opcodes.ASTORE && it.`var` == oldVarIndex
|
||||
}.filter {
|
||||
it.previous?.opcode == Opcodes.ACONST_NULL
|
||||
}.filter {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//WITH_RUNTIME
|
||||
class Test {
|
||||
|
||||
data class Style(
|
||||
val color: Int? = null,
|
||||
val underlined: Boolean? = null,
|
||||
val separator: String = ""
|
||||
)
|
||||
|
||||
init {
|
||||
var flag: Boolean? = null
|
||||
|
||||
val receiver: String = "123"
|
||||
try {
|
||||
receiver.let { a2 ->
|
||||
flag = false
|
||||
}
|
||||
} finally {
|
||||
receiver.hashCode()
|
||||
}
|
||||
val style = Style(null, flag, "123")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
Test()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -3865,6 +3865,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17588.kt")
|
||||
public void testKt17588() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/capturedVarsOptimization/kt17588.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sharedSlotsWithCapturedVars.kt")
|
||||
public void testSharedSlotsWithCapturedVars() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt");
|
||||
|
||||
@@ -3865,6 +3865,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17588.kt")
|
||||
public void testKt17588() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/capturedVarsOptimization/kt17588.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sharedSlotsWithCapturedVars.kt")
|
||||
public void testSharedSlotsWithCapturedVars() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt");
|
||||
|
||||
@@ -3865,6 +3865,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17588.kt")
|
||||
public void testKt17588() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/capturedVarsOptimization/kt17588.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sharedSlotsWithCapturedVars.kt")
|
||||
public void testSharedSlotsWithCapturedVars() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt");
|
||||
|
||||
@@ -4538,6 +4538,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17588.kt")
|
||||
public void testKt17588() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/capturedVarsOptimization/kt17588.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sharedSlotsWithCapturedVars.kt")
|
||||
public void testSharedSlotsWithCapturedVars() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt");
|
||||
|
||||
Reference in New Issue
Block a user