From 47fec1a113ec40df3b4d1a7b29c253c8f7da4522 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 2 Oct 2023 15:22:02 +0200 Subject: [PATCH] K2: use similar sources for if branches (PSI/LT) Related to KT-59584 --- .../fir/lightTree/converter/LightTreeRawFirExpressionBuilder.kt | 2 +- compiler/testData/ir/sourceRanges/this.fir.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirExpressionBuilder.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirExpressionBuilder.kt index f62c31a7110..608616ffe01 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirExpressionBuilder.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirExpressionBuilder.kt @@ -1339,7 +1339,7 @@ class LightTreeRawFirExpressionBuilder( with(components) { val trueBranch = convertLoopBody(thenBlock) branches += buildWhenBranch { - source = thenBlock?.toFirSourceElement() + source = firCondition?.source condition = firCondition ?: buildErrorExpression( null, ConeSyntaxDiagnostic("If statement should have condition") diff --git a/compiler/testData/ir/sourceRanges/this.fir.txt b/compiler/testData/ir/sourceRanges/this.fir.txt index 3d0d06fed35..1147e5e9abc 100644 --- a/compiler/testData/ir/sourceRanges/this.fir.txt +++ b/compiler/testData/ir/sourceRanges/this.fir.txt @@ -8,7 +8,7 @@ @3:4..46 FIELD PROPERTY_BACKING_FIELD name:maybeThis type:.Klass? visibility:private [final] @3:20..46 EXPRESSION_BODY @3:20..46 WHEN type=.Klass? origin=IF - @3:32..36 BRANCH + @3:24..30 BRANCH @3:24..30 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ @3:24..25 CONST Int type=kotlin.Int value=1 @3:29..30 CONST Int type=kotlin.Int value=1