Do not add duplicate $completion when compiling JVM against JVM_IR
This change fixes JvmOldAgainstIrBoxInlineTestGenerated.Suspend and JvmIrAgainstOldBoxInlineTestGenerated.Suspend tests.
This commit is contained in:
+10
@@ -230,6 +230,16 @@ class CoroutineTransformerMethodVisitor(
|
|||||||
if (last is LabelNode) last as LabelNode
|
if (last is LabelNode) last as LabelNode
|
||||||
else LabelNode().also { insert(last, it) }
|
else LabelNode().also { insert(last, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When compiling with the old backend against the bytecode generated by JVM IR, $completion may already be in LVT.
|
||||||
|
if (methodNode.localVariables.any {
|
||||||
|
it.name == SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME &&
|
||||||
|
areLabelsBeforeSameInsn(startLabel, it.start) &&
|
||||||
|
areLabelsBeforeSameInsn(endLabel, it.end)
|
||||||
|
}) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
methodNode.localVariables.add(
|
methodNode.localVariables.add(
|
||||||
LocalVariableNode(
|
LocalVariableNode(
|
||||||
SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME,
|
SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME,
|
||||||
|
|||||||
@@ -317,6 +317,9 @@ internal fun firstLabelInChain(node: LabelNode): LabelNode {
|
|||||||
return curNode
|
return curNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun areLabelsBeforeSameInsn(first: LabelNode, second: LabelNode): Boolean =
|
||||||
|
firstLabelInChain(first) == firstLabelInChain(second)
|
||||||
|
|
||||||
internal val MethodNode?.nodeText: String
|
internal val MethodNode?.nodeText: String
|
||||||
get() {
|
get() {
|
||||||
if (this == null) {
|
if (this == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user