[K/JS] Add previousOffset to InteropCallableReferenceLowering + include SYNTHETIC_OFFSET branch into previousOffset calculation

This commit is contained in:
Artem Kobzar
2023-03-27 21:45:00 +00:00
committed by Space Team
parent 9df5c54db3
commit 6b62499c85
2 changed files with 9 additions and 8 deletions
@@ -408,12 +408,12 @@ class InteropCallableReferenceLowering(val context: JsIrBackendContext) : BodyLo
if (invokeFun.returnType.isUnit()) { if (invokeFun.returnType.isUnit()) {
val unitValue = JsIrBuilder.buildGetObjectValue(context.irBuiltIns.unitType, context.irBuiltIns.unitClass) val unitValue = JsIrBuilder.buildGetObjectValue(context.irBuiltIns.unitType, context.irBuiltIns.unitClass)
// Set both offsets of the IrReturn to body.endOffset - 1 so that a breakpoint set at the closing brace of a lambda expression // Set both offsets of the IrReturn to body.previousOffset so that a breakpoint set at the closing brace of a lambda expression
// could be hit. // could be hit.
body.statements.add( body.statements.add(
IrReturnImpl( IrReturnImpl(
body.endOffset - 1, body.endOffset.previousOffset,
body.endOffset - 1, body.endOffset.previousOffset,
context.irBuiltIns.nothingType, context.irBuiltIns.nothingType,
lambdaDeclaration.symbol, lambdaDeclaration.symbol,
unitValue unitValue
@@ -1394,14 +1394,15 @@ val IrFunction.isValueClassTypedEquals: Boolean
/** /**
* The method is used to calculate the previous offset from the current one to prevent situations when it can calculate * The method is used to calculate the previous offset from the current one to prevent situations when it can calculate
* [UNDEFINED_OFFSET] from 0 offset and -2 offset from the [UNDEFINED OFFSET] * [UNDEFINED_OFFSET] from 0 offset and [SYNTHETIC_OFFSET] offset from the [UNDEFINED OFFSET]
*/ */
val Int.previousOffset val Int.previousOffset
get(): Int = get(): Int =
when (compareTo(0)) { when (this) {
0 -> 0 0 -> 0
-1 -> UNDEFINED_OFFSET UNDEFINED_OFFSET -> UNDEFINED_OFFSET
else -> minus(1) SYNTHETIC_OFFSET -> SYNTHETIC_OFFSET
else -> if (this > 0) minus(1) else error("Invalid offset appear")
} }
fun IrAttributeContainer.extractRelatedDeclaration(): IrDeclaration? { fun IrAttributeContainer.extractRelatedDeclaration(): IrDeclaration? {