Fix for wrong local variable table at inlining lambda with finallies
This commit is contained in:
+12
-5
@@ -121,6 +121,13 @@ class IntervalMetaInfo<T : SplittableInterval<T>> {
|
|||||||
return currentIntervals.map { split(it, by, keepStart) }
|
return currentIntervals.map { split(it, by, keepStart) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun splitAndRemoveIntervalsFromCurrents(by : Interval) {
|
||||||
|
val copies = ArrayList(currentIntervals)
|
||||||
|
copies.forEach {
|
||||||
|
splitAndRemoveInterval(it, by, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun processCurrent(curIns: LabelNode, directOrder: Boolean) {
|
fun processCurrent(curIns: LabelNode, directOrder: Boolean) {
|
||||||
getInterval(curIns, directOrder).forEach {
|
getInterval(curIns, directOrder).forEach {
|
||||||
val added = currentIntervals.add(it)
|
val added = currentIntervals.add(it)
|
||||||
@@ -193,16 +200,16 @@ public class LocalVarNodeWrapper(val node: LocalVariableNode) : Interval, Splitt
|
|||||||
override val endLabel: LabelNode
|
override val endLabel: LabelNode
|
||||||
get() = node.end
|
get() = node.end
|
||||||
|
|
||||||
override fun split(split: Interval, keepStart: Boolean): SplitPair<LocalVarNodeWrapper> {
|
override fun split(splitBy: Interval, keepStart: Boolean): SplitPair<LocalVarNodeWrapper> {
|
||||||
val newPartInterval = if (keepStart) {
|
val newPartInterval = if (keepStart) {
|
||||||
val oldEnd = endLabel
|
val oldEnd = endLabel
|
||||||
node.end = split.startLabel
|
node.end = splitBy.startLabel
|
||||||
Pair(split.endLabel, oldEnd)
|
Pair(splitBy.endLabel, oldEnd)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val oldStart = startLabel
|
val oldStart = startLabel
|
||||||
node.start = split.endLabel
|
node.start = splitBy.endLabel
|
||||||
Pair(oldStart, split.startLabel)
|
Pair(oldStart, splitBy.startLabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
return SplitPair(this, LocalVarNodeWrapper(
|
return SplitPair(this, LocalVarNodeWrapper(
|
||||||
|
|||||||
@@ -700,7 +700,7 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
SimpleInterval splitBy = new SimpleInterval((LabelNode) start.info, extension.finallyIntervalEnd);
|
SimpleInterval splitBy = new SimpleInterval((LabelNode) start.info, extension.finallyIntervalEnd);
|
||||||
processor.getTryBlocksMetaInfo().splitCurrentIntervals(splitBy, true);
|
processor.getTryBlocksMetaInfo().splitCurrentIntervals(splitBy, true);
|
||||||
|
|
||||||
processor.getLocalVarsMetaInfo().splitCurrentIntervals(splitBy, true);
|
//processor.getLocalVarsMetaInfo().splitAndRemoveIntervalsFromCurrents(splitBy);
|
||||||
|
|
||||||
mark.dropTo();
|
mark.dropTo();
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+35
@@ -0,0 +1,35 @@
|
|||||||
|
import test.*
|
||||||
|
|
||||||
|
fun test1(): String {
|
||||||
|
try {
|
||||||
|
doCall {
|
||||||
|
try {
|
||||||
|
doCall {
|
||||||
|
val a = 1
|
||||||
|
if (1 == 1) {
|
||||||
|
return "a"
|
||||||
|
}
|
||||||
|
else if (2 == 2) {
|
||||||
|
return "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "d"
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
"1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
"2"
|
||||||
|
}
|
||||||
|
return "f"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
test1()
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
public inline fun <R> doCall(block: ()-> R) : R {
|
||||||
|
return block()
|
||||||
|
}
|
||||||
+6
@@ -658,6 +658,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/finallyInFinally.1.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/finallyInFinally.1.kt");
|
||||||
doTestMultiFileWithInlineCheck(fileName);
|
doTestMultiFileWithInlineCheck(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("wrongVarInterval.1.kt")
|
||||||
|
public void testWrongVarInterval() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/wrongVarInterval.1.kt");
|
||||||
|
doTestMultiFileWithInlineCheck(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/chained")
|
@TestMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/chained")
|
||||||
|
|||||||
+6
@@ -658,6 +658,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/finallyInFinally.1.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/finallyInFinally.1.kt");
|
||||||
doBoxTestWithInlineCheck(fileName);
|
doBoxTestWithInlineCheck(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("wrongVarInterval.1.kt")
|
||||||
|
public void testWrongVarInterval() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/wrongVarInterval.1.kt");
|
||||||
|
doBoxTestWithInlineCheck(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/chained")
|
@TestMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/chained")
|
||||||
|
|||||||
Reference in New Issue
Block a user