From e9699e717337f7f5e028f1314f5ffd73643b8b8d Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 10 Mar 2020 11:02:16 +0300 Subject: [PATCH] FIR2IR: provide correct origins for arithmetic operators --- .../kotlin/fir/backend/ConversionUtils.kt | 40 ++++++++- .../kotlin/fir/backend/Fir2IrVisitor.kt | 25 +----- .../classes/enumWithMultipleCtors.fir.txt | 2 +- .../classes/qualifiedSuperCalls.fir.txt | 2 +- .../declarations/constValInitializers.fir.txt | 8 +- .../parameters/constructor.fir.txt | 2 +- .../parameters/useNextParamInLambda.fir.txt | 2 +- .../differentReceivers.fir.txt | 2 +- .../localDifferentReceivers.fir.txt | 2 +- .../provideDelegate/memberExtension.fir.txt | 2 +- .../ir/irText/expressions/arrayAccess.fir.txt | 4 +- .../ir/irText/expressions/assignments.fir.txt | 2 +- .../boundInnerGenericConstructor.fir.txt | 2 +- .../ir/irText/expressions/for.fir.txt | 2 +- .../multipleThisReferences.fir.txt | 2 +- .../sam/genericSamProjectedOut.fir.txt | 2 +- .../expressions/sam/samConstructors.fir.txt | 2 +- .../expressions/simpleOperators.fir.txt | 89 ------------------- .../ir/irText/expressions/simpleOperators.kt | 1 + .../ir/irText/expressions/stringPlus.fir.txt | 33 ------- .../ir/irText/expressions/stringPlus.kt | 1 + .../thisOfGenericOuterClass.fir.txt | 2 +- .../lambdas/destructuringInLambda.fir.txt | 2 +- 23 files changed, 64 insertions(+), 167 deletions(-) delete mode 100644 compiler/testData/ir/irText/expressions/simpleOperators.fir.txt delete mode 100644 compiler/testData/ir/irText/expressions/stringPlus.fir.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 1d0c88dcbc3..1a6b5bcee5f 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -17,19 +17,26 @@ import org.jetbrains.kotlin.fir.psi import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirThisReference -import org.jetbrains.kotlin.fir.resolve.toSymbol +import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference +import org.jetbrains.kotlin.fir.resolve.* +import org.jetbrains.kotlin.fir.resolve.calls.SyntheticPropertySymbol import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.AccessorSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.expressions.IrConstKind +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.IrErrorType import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.KtForExpression +import org.jetbrains.kotlin.psi.KtOperationReferenceExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.util.OperatorNameConventions internal fun FirElement.convertWithOffsets( f: (startOffset: Int, endOffset: Int) -> T @@ -179,4 +186,33 @@ private fun FirTypeRef.collectCallableNamesFromThisAndSupertypes( internal tailrec fun FirCallableSymbol<*>.deepestOverriddenSymbol(): FirCallableSymbol<*> { val overriddenSymbol = overriddenSymbol ?: return this return overriddenSymbol.deepestOverriddenSymbol() -} \ No newline at end of file +} + +private val nameToOperationConventionOrigin = mutableMapOf( + OperatorNameConventions.PLUS to IrStatementOrigin.PLUS, + OperatorNameConventions.MINUS to IrStatementOrigin.MINUS, + OperatorNameConventions.TIMES to IrStatementOrigin.MUL, + OperatorNameConventions.DIV to IrStatementOrigin.DIV, + OperatorNameConventions.MOD to IrStatementOrigin.PERC, + OperatorNameConventions.REM to IrStatementOrigin.PERC, + OperatorNameConventions.RANGE_TO to IrStatementOrigin.RANGE +) + +internal fun FirReference.statementOrigin(): IrStatementOrigin? { + return when (this) { + is FirPropertyFromParameterResolvedNamedReference -> IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER + is FirResolvedNamedReference -> when (resolvedSymbol) { + is AccessorSymbol, is SyntheticPropertySymbol -> IrStatementOrigin.GET_PROPERTY + is FirNamedFunctionSymbol -> when { + resolvedSymbol.callableId.isInvoke() -> IrStatementOrigin.INVOKE + source.psi is KtForExpression && resolvedSymbol.callableId.isIteratorNext() -> IrStatementOrigin.FOR_LOOP_NEXT + source.psi is KtForExpression && resolvedSymbol.callableId.isIteratorHasNext() -> IrStatementOrigin.FOR_LOOP_HAS_NEXT + source.psi is KtForExpression && resolvedSymbol.callableId.isIterator() -> IrStatementOrigin.FOR_LOOP_ITERATOR + source.psi is KtOperationReferenceExpression -> nameToOperationConventionOrigin[resolvedSymbol.callableId.callableName] + else -> null + } + else -> null + } + else -> null + } +} diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index c28e648ab3f..684d6cbbb73 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -18,12 +18,11 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirSuperReference -import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference -import org.jetbrains.kotlin.fir.resolve.* -import org.jetbrains.kotlin.fir.resolve.calls.SyntheticPropertySymbol +import org.jetbrains.kotlin.fir.resolve.firSymbolProvider +import org.jetbrains.kotlin.fir.resolve.isIteratorNext +import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.transformers.IntegerLiteralTypeApproximationTransformer import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperator -import org.jetbrains.kotlin.fir.symbols.AccessorSymbol import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* @@ -472,24 +471,6 @@ class Fir2IrVisitor( }) } - private fun FirReference.statementOrigin(): IrStatementOrigin? { - return when (this) { - is FirPropertyFromParameterResolvedNamedReference -> IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER - is FirResolvedNamedReference -> when (resolvedSymbol) { - is AccessorSymbol, is SyntheticPropertySymbol -> IrStatementOrigin.GET_PROPERTY - is FirNamedFunctionSymbol -> when { - resolvedSymbol.callableId.isInvoke() -> IrStatementOrigin.INVOKE - source.psi is KtForExpression && resolvedSymbol.callableId.isIteratorNext() -> IrStatementOrigin.FOR_LOOP_NEXT - source.psi is KtForExpression && resolvedSymbol.callableId.isIteratorHasNext() -> IrStatementOrigin.FOR_LOOP_HAS_NEXT - source.psi is KtForExpression && resolvedSymbol.callableId.isIterator() -> IrStatementOrigin.FOR_LOOP_ITERATOR - else -> null - } - else -> null - } - else -> null - } - } - private fun FirQualifiedAccess.toIrExpression(typeRef: FirTypeRef): IrExpression { val type = typeRef.toIrType() val symbol = calleeReference.toSymbol(declarationStorage) diff --git a/compiler/testData/ir/irText/classes/enumWithMultipleCtors.fir.txt b/compiler/testData/ir/irText/classes/enumWithMultipleCtors.fir.txt index e7dafc3b9f4..c3359a23d7d 100644 --- a/compiler/testData/ir/irText/classes/enumWithMultipleCtors.fir.txt +++ b/compiler/testData/ir/irText/classes/enumWithMultipleCtors.fir.txt @@ -24,7 +24,7 @@ FILE fqName: fileName:/enumWithMultipleCtors.kt $this: VALUE_PARAMETER name: type:.A.Y BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun f (): kotlin.String declared in .A.Y' - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: CALL 'public open fun f (): kotlin.String declared in .A' type=kotlin.String origin=null $this: GET_VAR ': .A.Y declared in .A.Y.f' type=.A.Y origin=null other: CONST String type=kotlin.String value="#Y" diff --git a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt index bcff9d58e23..28f7553de47 100644 --- a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt +++ b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt @@ -68,7 +68,7 @@ FILE fqName: fileName:/qualifiedSuperCalls.kt $this: VALUE_PARAMETER name: type:.CBoth BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .CBoth' - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: CALL 'public open fun (): kotlin.Int declared in .ILeft' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .CBoth declared in .CBoth.' type=.CBoth origin=null other: CALL 'public open fun (): kotlin.Int declared in .IRight' type=kotlin.Int origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/declarations/constValInitializers.fir.txt b/compiler/testData/ir/irText/declarations/constValInitializers.fir.txt index 2d8845f61e5..65d29b8d5c3 100644 --- a/compiler/testData/ir/irText/declarations/constValInitializers.fir.txt +++ b/compiler/testData/ir/irText/declarations/constValInitializers.fir.txt @@ -20,8 +20,8 @@ FILE fqName: fileName:/constValInitializers.kt PROPERTY name:I2 visibility:public modality:FINAL [const,val] FIELD PROPERTY_BACKING_FIELD name:I2 type:kotlin.Int visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY other: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY other: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY @@ -42,7 +42,7 @@ FILE fqName: fileName:/constValInitializers.kt PROPERTY name:STR2 visibility:public modality:FINAL [const,val] FIELD PROPERTY_BACKING_FIELD name:STR2 type:kotlin.String visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: CONST String type=kotlin.String value="String" other: CONST String type=kotlin.String value="2" FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String @@ -53,7 +53,7 @@ FILE fqName: fileName:/constValInitializers.kt PROPERTY name:STR3 visibility:public modality:FINAL [const,val] FIELD PROPERTY_BACKING_FIELD name:STR3 type:kotlin.String visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: CALL 'public final fun (): kotlin.String declared in ' type=kotlin.String origin=GET_PROPERTY other: CALL 'public final fun (): kotlin.String declared in ' type=kotlin.String origin=GET_PROPERTY FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String diff --git a/compiler/testData/ir/irText/declarations/parameters/constructor.fir.txt b/compiler/testData/ir/irText/declarations/parameters/constructor.fir.txt index 385f3a38364..ce2ad56a37e 100644 --- a/compiler/testData/ir/irText/declarations/parameters/constructor.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/constructor.fir.txt @@ -187,7 +187,7 @@ FILE fqName: fileName:/constructor.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor (x: kotlin.Int) [primary] declared in .Test4' : - x: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + x: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: GET_VAR 'x: kotlin.Int declared in .Test4.' type=kotlin.Int origin=null other: GET_VAR 'y: kotlin.Int declared in .Test4.' type=kotlin.Int origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] diff --git a/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.fir.txt b/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.fir.txt index d36a65d3362..3af32fcadd7 100644 --- a/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.fir.txt @@ -30,7 +30,7 @@ FILE fqName: fileName:/useNextParamInLambda.kt SET_VAR 'var result: kotlin.String [var] declared in .box' type=kotlin.Unit origin=null CONST String type=kotlin.String value="OK" RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: CALL 'public final fun f (f1: kotlin.Function0, f2: kotlin.Function0): kotlin.String declared in ' type=kotlin.String origin=null f1: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt index d56b1e708a8..f4f08fd1b4c 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt @@ -76,7 +76,7 @@ FILE fqName: fileName:/differentReceivers.kt PROPERTY name:testOK visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:testOK type:kotlin.String visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: CALL 'public final fun (): kotlin.String declared in ' type=kotlin.String origin=GET_PROPERTY other: CALL 'public final fun (): kotlin.String declared in ' type=kotlin.String origin=GET_PROPERTY FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt index ef09f9a8e07..199bbee2287 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt @@ -50,7 +50,7 @@ FILE fqName: fileName:/localDifferentReceivers.kt VAR name:testO type:kotlin.String [val] VAR name:testK type:kotlin.String [val] VAR name:testOK type:kotlin.String [val] - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: GET_VAR 'val testO: kotlin.String [val] declared in .box' type=kotlin.String origin=null other: GET_VAR 'val testK: kotlin.String [val] declared in .box' type=kotlin.String origin=null RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt index 85ce430cb87..d6a56b70722 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt @@ -29,7 +29,7 @@ FILE fqName: fileName:/memberExtension.kt VALUE_PARAMETER name:p index:1 type:kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun getValue (receiver: kotlin.String, p: kotlin.Any): kotlin.String [operator] declared in .Host.StringDelegate' - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: GET_VAR 'receiver: kotlin.String declared in .Host.StringDelegate.getValue' type=kotlin.String origin=null other: CALL 'public final fun (): kotlin.String declared in .Host.StringDelegate' type=kotlin.String origin=GET_PROPERTY $this: GET_VAR ': .Host.StringDelegate declared in .Host.StringDelegate.getValue' type=.Host.StringDelegate origin=null diff --git a/compiler/testData/ir/irText/expressions/arrayAccess.fir.txt b/compiler/testData/ir/irText/expressions/arrayAccess.fir.txt index 082ad87190b..cffd614d158 100644 --- a/compiler/testData/ir/irText/expressions/arrayAccess.fir.txt +++ b/compiler/testData/ir/irText/expressions/arrayAccess.fir.txt @@ -16,8 +16,8 @@ FILE fqName: fileName:/arrayAccess.kt VALUE_PARAMETER name:a index:0 type:kotlin.IntArray BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (a: kotlin.IntArray): kotlin.Int declared in ' - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in kotlin.IntArray' type=kotlin.Int origin=null $this: GET_VAR 'a: kotlin.IntArray declared in .test' type=kotlin.IntArray origin=null index: CONST Int type=kotlin.Int value=0 diff --git a/compiler/testData/ir/irText/expressions/assignments.fir.txt b/compiler/testData/ir/irText/expressions/assignments.fir.txt index e896a887f1e..dea4e173e1f 100644 --- a/compiler/testData/ir/irText/expressions/assignments.fir.txt +++ b/compiler/testData/ir/irText/expressions/assignments.fir.txt @@ -45,7 +45,7 @@ FILE fqName: fileName:/assignments.kt SET_VAR 'var x: kotlin.Int [var] declared in .test1' type=kotlin.Unit origin=null CONST Int type=kotlin.Int value=1 SET_VAR 'var x: kotlin.Int [var] declared in .test1' type=kotlin.Unit origin=null - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: GET_VAR 'var x: kotlin.Int [var] declared in .test1' type=kotlin.Int origin=null other: CONST Int type=kotlin.Int value=1 FUN name:test2 visibility:public modality:FINAL <> (r:.Ref) returnType:kotlin.Unit diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.fir.txt index a48d7859bc4..e4cb6c9b60d 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.fir.txt @@ -86,6 +86,6 @@ FILE fqName:test fileName:/boundInnerGenericConstructor.kt CONST String type=kotlin.String value="K" FUNCTION_REFERENCE 'public constructor (a: T of test.Foo, b: P of test.Foo.Inner) [primary] declared in test.Foo.Inner' type=kotlin.reflect.KFunction2> origin=null reflectionTarget= RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in test' - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin' type=kotlin.String origin=null + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin' type=kotlin.String origin=PLUS $receiver: ERROR_CALL 'Unresolved reference: #' type=IrErrorType other: ERROR_CALL 'Unresolved reference: #' type=IrErrorType diff --git a/compiler/testData/ir/irText/expressions/for.fir.txt b/compiler/testData/ir/irText/expressions/for.fir.txt index 9f93a5b33af..34323ca52a1 100644 --- a/compiler/testData/ir/irText/expressions/for.fir.txt +++ b/compiler/testData/ir/irText/expressions/for.fir.txt @@ -58,7 +58,7 @@ FILE fqName: fileName:/for.kt BLOCK type=kotlin.Unit origin=FOR_LOOP VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.IntIterator [val] CALL 'public open fun iterator (): kotlin.collections.IntIterator [operator] declared in kotlin.ranges.IntProgression' type=kotlin.collections.IntIterator origin=null - $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange [operator] declared in kotlin.Int' type=kotlin.ranges.IntRange origin=null + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange [operator] declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE $this: CONST Int type=kotlin.Int value=1 other: CONST Int type=kotlin.Int value=10 WHILE label=null origin=FOR_LOOP_INNER_WHILE diff --git a/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt b/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt index f873cedf4e7..c0b60c0cba8 100644 --- a/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt @@ -83,7 +83,7 @@ FILE fqName: fileName:/multipleThisReferences.kt PROPERTY name:xx visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:private [final] EXPRESSION_BODY - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: CALL 'public final fun (): kotlin.Int declared in .Outer.Inner' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .Host.test. declared in .Host.test.' type=.Host.test. origin=null other: GET_VAR 'y: kotlin.Int declared in .Host.' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt index 2456eb416d5..bd482f313ff 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt @@ -9,7 +9,7 @@ FILE fqName: fileName:/genericSamProjectedOut.kt VALUE_PARAMETER name:it index:0 type:kotlin.String? BLOCK_BODY GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - CALL 'public open fun plus (hello: example.Hello?): kotlin.Unit [operator] declared in example.SomeJavaClass' type=kotlin.Unit origin=null + CALL 'public open fun plus (hello: example.Hello?): kotlin.Unit [operator] declared in example.SomeJavaClass' type=kotlin.Unit origin=PLUS $this: GET_VAR 'a: example.SomeJavaClass declared in .test' type=example.SomeJavaClass origin=null hello: FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit diff --git a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt index 3b54c4d655b..642f9c5110a 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt @@ -31,6 +31,6 @@ FILE fqName: fileName:/samConstructors.kt VALUE_PARAMETER name:b index:1 type:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in .test4' - CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MINUS $this: GET_VAR 'a: kotlin.Int declared in .test4.' type=kotlin.Int origin=null other: GET_VAR 'b: kotlin.Int declared in .test4.' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/simpleOperators.fir.txt b/compiler/testData/ir/irText/expressions/simpleOperators.fir.txt deleted file mode 100644 index be91b6dc399..00000000000 --- a/compiler/testData/ir/irText/expressions/simpleOperators.fir.txt +++ /dev/null @@ -1,89 +0,0 @@ -FILE fqName: fileName:/simpleOperators.kt - FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test1' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test1' type=kotlin.Int origin=null - FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test2' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test2' type=kotlin.Int origin=null - FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test3 (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test3' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test3' type=kotlin.Int origin=null - FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test4 (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun div (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test4' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test4' type=kotlin.Int origin=null - FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test5 (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun rem (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test5' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test5' type=kotlin.Int origin=null - FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.ranges.IntRange - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test6 (a: kotlin.Int, b: kotlin.Int): kotlin.ranges.IntRange declared in ' - CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange [operator] declared in kotlin.Int' type=kotlin.ranges.IntRange origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test6' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test6' type=kotlin.Int origin=null - FUN name:test1x visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1x (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test1x' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test1x' type=kotlin.Int origin=null - FUN name:test2x visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test2x (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test2x' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test2x' type=kotlin.Int origin=null - FUN name:test3x visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test3x (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test3x' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test3x' type=kotlin.Int origin=null - FUN name:test4x visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test4x (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun div (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test4x' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test4x' type=kotlin.Int origin=null - FUN name:test5x visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:a index:0 type:kotlin.Int - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test5x (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in ' - CALL 'public final fun rem (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'a: kotlin.Int declared in .test5x' type=kotlin.Int origin=null - other: GET_VAR 'b: kotlin.Int declared in .test5x' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/simpleOperators.kt b/compiler/testData/ir/irText/expressions/simpleOperators.kt index c44dde5e193..b2daa5134a5 100644 --- a/compiler/testData/ir/irText/expressions/simpleOperators.kt +++ b/compiler/testData/ir/irText/expressions/simpleOperators.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun test1(a: Int, b: Int) = a + b fun test2(a: Int, b: Int) = a - b fun test3(a: Int, b: Int) = a * b diff --git a/compiler/testData/ir/irText/expressions/stringPlus.fir.txt b/compiler/testData/ir/irText/expressions/stringPlus.fir.txt deleted file mode 100644 index 269e44410cf..00000000000 --- a/compiler/testData/ir/irText/expressions/stringPlus.fir.txt +++ /dev/null @@ -1,33 +0,0 @@ -FILE fqName: fileName:/stringPlus.kt - FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.String, b:kotlin.Any) returnType:kotlin.String - VALUE_PARAMETER name:a index:0 type:kotlin.String - VALUE_PARAMETER name:b index:1 type:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.String, b: kotlin.Any): kotlin.String declared in ' - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null - $this: GET_VAR 'a: kotlin.String declared in .test1' type=kotlin.String origin=null - other: GET_VAR 'b: kotlin.Any declared in .test1' type=kotlin.Any origin=null - FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.String, b:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER name:a index:0 type:kotlin.String - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.String, b: kotlin.Int): kotlin.String declared in ' - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null - $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null - $this: GET_VAR 'a: kotlin.String declared in .test2' type=kotlin.String origin=null - other: CONST String type=kotlin.String value="+" - other: GET_VAR 'b: kotlin.Int declared in .test2' type=kotlin.Int origin=null - FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.String, b:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER name:a index:0 type:kotlin.String - VALUE_PARAMETER name:b index:1 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test3 (a: kotlin.String, b: kotlin.Int): kotlin.String declared in ' - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null - $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null - $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null - $this: GET_VAR 'a: kotlin.String declared in .test3' type=kotlin.String origin=null - other: CONST String type=kotlin.String value="+" - other: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'b: kotlin.Int declared in .test3' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=1 - other: GET_VAR 'a: kotlin.String declared in .test3' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/expressions/stringPlus.kt b/compiler/testData/ir/irText/expressions/stringPlus.kt index 90776bb3785..2c530ecd8f7 100644 --- a/compiler/testData/ir/irText/expressions/stringPlus.kt +++ b/compiler/testData/ir/irText/expressions/stringPlus.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun test1(a: String, b: Any) = a + b fun test2(a: String, b: Int) = a + "+" + b fun test3(a: String, b: Int) = (a + "+") + (b + 1) + a \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt b/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt index a08aae3f628..f61f25b005f 100644 --- a/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt +++ b/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt @@ -77,7 +77,7 @@ FILE fqName: fileName:/thisOfGenericOuterClass.kt PROPERTY name:xx visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:private [final] EXPRESSION_BODY - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: CALL 'public final fun (): T of .Outer declared in .Outer' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .Outer declared in .test' type=.Outer origin=null other: CALL 'public final fun (): kotlin.Int declared in .Outer.Inner' type=kotlin.Int origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt index ae4110df71c..4af81a44728 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt @@ -79,7 +79,7 @@ FILE fqName: fileName:/destructuringInLambda.kt CALL 'public final fun component2 (): kotlin.Int declared in .A' type=kotlin.Int origin=null $this: GET_VAR ': .A declared in .fn.' type=.A origin=null RETURN type=kotlin.Nothing from='local final fun (: .A): kotlin.Int declared in .fn' - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: CONST Int type=kotlin.Int value=42 other: GET_VAR 'val y: kotlin.Int [val] declared in .fn.' type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1<.A, kotlin.Int>