From 6b62499c8551d01a05fbe0e555a79ac6a4dd2d89 Mon Sep 17 00:00:00 2001 From: Artem Kobzar Date: Mon, 27 Mar 2023 21:45:00 +0000 Subject: [PATCH] [K/JS] Add previousOffset to InteropCallableReferenceLowering + include SYNTHETIC_OFFSET branch into previousOffset calculation --- .../js/lower/InteropCallableReferenceLowering.kt | 6 +++--- .../src/org/jetbrains/kotlin/ir/util/IrUtils.kt | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/InteropCallableReferenceLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/InteropCallableReferenceLowering.kt index 150514d5b83..59535dd920f 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/InteropCallableReferenceLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/InteropCallableReferenceLowering.kt @@ -408,12 +408,12 @@ class InteropCallableReferenceLowering(val context: JsIrBackendContext) : BodyLo if (invokeFun.returnType.isUnit()) { 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. body.statements.add( IrReturnImpl( - body.endOffset - 1, - body.endOffset - 1, + body.endOffset.previousOffset, + body.endOffset.previousOffset, context.irBuiltIns.nothingType, lambdaDeclaration.symbol, unitValue diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt index e655291eec0..597191d899d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt @@ -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 - * [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 get(): Int = - when (compareTo(0)) { + when (this) { 0 -> 0 - -1 -> UNDEFINED_OFFSET - else -> minus(1) + UNDEFINED_OFFSET -> UNDEFINED_OFFSET + SYNTHETIC_OFFSET -> SYNTHETIC_OFFSET + else -> if (this > 0) minus(1) else error("Invalid offset appear") } fun IrAttributeContainer.extractRelatedDeclaration(): IrDeclaration? { @@ -1411,4 +1412,4 @@ fun IrAttributeContainer.extractRelatedDeclaration(): IrDeclaration? { is IrFunctionReference -> symbol.owner else -> null } -} +} \ No newline at end of file