From d23e9940ec09906434b57a080bf16b38935626c1 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Wed, 15 Jul 2020 21:40:04 +0300 Subject: [PATCH] [FIR] Change fir builder to use newly created nodes --- .../kotlin/fir/builder/BaseFirBuilder.kt | 18 ++++++++---------- .../converter/ExpressionsConverter.kt | 4 ++-- .../kotlin/fir/builder/PsiConversionUtils.kt | 2 +- .../kotlin/fir/builder/RawFirBuilder.kt | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/compiler/fir/raw-fir/fir-common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/raw-fir/fir-common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index 1b93969f07d..fe9bd4a95d9 100644 --- a/compiler/fir/raw-fir/fir-common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/raw-fir/fir-common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -530,19 +530,17 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte } if (operation in FirOperation.ASSIGNMENTS && operation != FirOperation.ASSIGN) { - return buildOperatorCall { + return buildAssignmentOperatorStatement { source = baseSource this.operation = operation // TODO: take good psi - argumentList = buildBinaryArgumentList( - this@generateAssignment?.convert() ?: buildErrorExpression { - source = null - diagnostic = ConeSimpleDiagnostic( - "Unsupported left value of assignment: ${baseSource?.psi?.text}", DiagnosticKind.ExpressionRequired - ) - }, - value - ) + leftArgument = this@generateAssignment?.convert() ?: buildErrorExpression { + source = null + diagnostic = ConeSimpleDiagnostic( + "Unsupported left value of assignment: ${baseSource?.psi?.text}", DiagnosticKind.ExpressionRequired + ) + } + rightArgument = value } } require(operation == FirOperation.ASSIGN) diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index f96791c4521..c8f25283967 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -270,7 +270,7 @@ class ExpressionsConverter( if (firOperation in FirOperation.ASSIGNMENTS) { return leftArgNode.generateAssignment(binaryExpression.toFirSourceElement(), rightArg, rightArgAsFir, firOperation) { getAsFirExpression(this) } } else { - buildOperatorCall { + buildEqualityOperatorCall { source = binaryExpression.toFirSourceElement() operation = firOperation argumentList = buildBinaryArgumentList(leftArgAsFir, rightArgAsFir) @@ -704,7 +704,7 @@ class ExpressionsConverter( } } return if (whenRefWithSubject != null) { - buildOperatorCall { + buildEqualityOperatorCall { source = whenCondition.toFirSourceElement() operation = FirOperation.EQ argumentList = buildBinaryArgumentList( diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt index d13b9a82421..6cc4e7261a4 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt @@ -32,7 +32,7 @@ internal fun KtWhenCondition.toFirWhenCondition( } return when (this) { is KtWhenConditionWithExpression -> { - buildOperatorCall { + buildEqualityOperatorCall { source = expression?.toFirPsiSourceElement(FirFakeSourceElementKind.WhenCondition) operation = FirOperation.EQ argumentList = buildBinaryArgumentList( diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 2daa2b0d32a..e78080778fe 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -1632,7 +1632,7 @@ class RawFirBuilder( (this as KtExpression).toFirExpression("Incorrect expression in assignment: ${expression.text}") } } else { - buildOperatorCall { + buildEqualityOperatorCall { this.source = source operation = firOperation argumentList = buildBinaryArgumentList(leftArgument, rightArgument)