Start local var scope for destructuring variables after init.
If the scope for a local variable is started before a value has been written, another value from a previous use of the local slot can be present. That value could have a different type which would lead to weird debugging situations and also leads to other tools (such as D8) rejecting the locals information as it is invalid. Fixes KT-33959.
This commit is contained in:
+6
-2
@@ -101,13 +101,17 @@ abstract class AbstractForLoopGenerator(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
v.visitLabel(destructuringStartLabel)
|
|
||||||
|
|
||||||
codegen.initializeDestructuringDeclarationVariables(
|
codegen.initializeDestructuringDeclarationVariables(
|
||||||
destructuringDeclaration,
|
destructuringDeclaration,
|
||||||
TransientReceiver(elementType),
|
TransientReceiver(elementType),
|
||||||
StackValue.local(loopParameterVar, asmElementType)
|
StackValue.local(loopParameterVar, asmElementType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Start the scope for the destructuring variables only after a values
|
||||||
|
// has been written to their locals slot. Otherwise, we can generate
|
||||||
|
// type-incorrect locals information because the local could have previously
|
||||||
|
// been used for a value of incompatible type.
|
||||||
|
v.visitLabel(destructuringStartLabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun assignToLoopParameter()
|
protected abstract fun assignToLoopParameter()
|
||||||
|
|||||||
Reference in New Issue
Block a user