From ca22e05acdfbe957b3c98002ef76dcb7d2365388 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 20 Mar 2020 15:57:39 +0300 Subject: [PATCH] [FIR2IR] Support safe calls --- .../fir/backend/generators/CallGenerator.kt | 61 +++++++++++++- .../box/annotations/annotationProperty.kt | 1 - .../boxingOptimization/safeCallWithElvis.kt | 1 - .../forInIndices/forInNonOptimizedIndices.kt | 1 - .../codegen/box/ranges/safeCallRangeTo.kt | 1 - .../codegen/box/regressions/arrayLengthNPE.kt | 1 - .../codegen/box/regressions/hashCodeNPE.kt | 1 - .../codegen/box/safeCall/genericNull.kt | 1 - compiler/testData/codegen/box/unit/kt4265.kt | 1 - .../ir/irText/expressions/bangbang.fir.txt | 15 +++- .../expressions/chainOfSafeCalls.fir.txt | 39 --------- .../ir/irText/expressions/chainOfSafeCalls.kt | 1 + .../irText/expressions/coercionToUnit.fir.txt | 34 ++++++-- .../irText/expressions/dotQualified.fir.txt | 13 --- .../ir/irText/expressions/dotQualified.kt | 1 + .../expressions/extFunSafeInvoke.fir.txt | 17 +++- .../ir/irText/expressions/kt30020.fir.txt | 30 ++++++- .../safeCallWithIncrementDecrement.fir.txt | 72 +++++++++++++---- .../ir/irText/expressions/safeCalls.fir.txt | 79 ++++++++++++++++--- .../temporaryInEnumEntryInitializer.fir.txt | 15 +++- .../expressions/temporaryInInitBlock.fir.txt | 36 --------- .../expressions/temporaryInInitBlock.kt | 1 + .../variableAsFunctionCall.fir.txt | 28 ++++++- 23 files changed, 307 insertions(+), 143 deletions(-) delete mode 100644 compiler/testData/ir/irText/expressions/chainOfSafeCalls.fir.txt delete mode 100644 compiler/testData/ir/irText/expressions/dotQualified.fir.txt delete mode 100644 compiler/testData/ir/irText/expressions/temporaryInInitBlock.fir.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallGenerator.kt index ff6dc55bc71..f6151055a2d 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallGenerator.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.classifierOrNull +import org.jetbrains.kotlin.ir.types.makeNotNull import org.jetbrains.kotlin.ir.util.defaultType internal class CallGenerator( @@ -43,7 +44,49 @@ internal class CallGenerator( private fun ConeKotlinType.toIrType(): IrType = with(typeConverter) { toIrType() } fun convertToIrCall(qualifiedAccess: FirQualifiedAccess, typeRef: FirTypeRef): IrExpression { - val type = typeRef.toIrType() + val explicitReceiver = qualifiedAccess.explicitReceiver + if (!qualifiedAccess.safe || explicitReceiver == null) { + return convertToUnsafeIrCall(qualifiedAccess, typeRef) + } + return qualifiedAccess.convertWithOffsets { startOffset, endOffset -> + val type = typeRef.toIrType() + val callableSymbol = (qualifiedAccess.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirCallableSymbol<*> + val typeShouldBeNotNull = callableSymbol?.fir?.returnTypeRef?.coneTypeSafe()?.isNullable == false + val unsafeIrCall = convertToUnsafeIrCall(qualifiedAccess, typeRef, makeNotNull = typeShouldBeNotNull) + IrBlockImpl(startOffset, endOffset, type, IrStatementOrigin.SAFE_CALL).apply { + val receiver = visitor.convertToIrExpression(explicitReceiver) + val receiverVariable = declarationStorage.declareTemporaryVariable(receiver).apply { + parent = conversionScope.parentFromStack() + } + statements += receiverVariable + statements += IrWhenImpl(startOffset, endOffset, type).apply { + val variableSymbol = symbolTable.referenceValue(receiverVariable.descriptor) + val condition = IrCallImpl( + startOffset, endOffset, irBuiltIns.booleanType, irBuiltIns.eqeqSymbol, origin = IrStatementOrigin.EQEQ + ).apply { + putValueArgument(0, IrGetValueImpl(startOffset, endOffset, variableSymbol)) + putValueArgument(1, IrConstImpl.constNull(startOffset, endOffset, irBuiltIns.nothingNType)) + } + branches += IrBranchImpl( + condition, IrConstImpl.constNull(startOffset, endOffset, irBuiltIns.nothingNType) + ) + val newReceiver = IrGetValueImpl(startOffset, endOffset, variableSymbol) + val replacedCall = unsafeIrCall.replaceReceiver( + newReceiver, isDispatch = explicitReceiver == qualifiedAccess.dispatchReceiver + ) + branches += IrElseBranchImpl( + IrConstImpl.boolean(startOffset, endOffset, irBuiltIns.booleanType, true), + replacedCall + ) + } + } + } + } + + private fun convertToUnsafeIrCall( + qualifiedAccess: FirQualifiedAccess, typeRef: FirTypeRef, makeNotNull: Boolean = false + ): IrExpression { + val type = typeRef.toIrType().let { if (makeNotNull) it.makeNotNull() else it } val symbol = qualifiedAccess.calleeReference.toSymbol( session, classifierStorage, @@ -293,6 +336,22 @@ internal class CallGenerator( } } + private fun IrExpression.replaceReceiver(newReceiver: IrExpression, isDispatch: Boolean): IrExpression { + when (this) { + is IrCallImpl -> { + if (!isDispatch) { + extensionReceiver = newReceiver + } else { + dispatchReceiver = newReceiver + } + } + is IrFieldExpressionBase -> { + receiver = newReceiver + } + } + return this + } + private fun generateErrorCallExpression( startOffset: Int, endOffset: Int, diff --git a/compiler/testData/codegen/box/annotations/annotationProperty.kt b/compiler/testData/codegen/box/annotations/annotationProperty.kt index 3758425d1e7..7490db2c7a8 100644 --- a/compiler/testData/codegen/box/annotations/annotationProperty.kt +++ b/compiler/testData/codegen/box/annotations/annotationProperty.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/boxingOptimization/safeCallWithElvis.kt b/compiler/testData/codegen/box/boxingOptimization/safeCallWithElvis.kt index 99dc7d5da99..1ffec309237 100644 --- a/compiler/testData/codegen/box/boxingOptimization/safeCallWithElvis.kt +++ b/compiler/testData/codegen/box/boxingOptimization/safeCallWithElvis.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/ranges/forInIndices/forInNonOptimizedIndices.kt b/compiler/testData/codegen/box/ranges/forInIndices/forInNonOptimizedIndices.kt index 7006da15ae7..8068b8b4c6e 100644 --- a/compiler/testData/codegen/box/ranges/forInIndices/forInNonOptimizedIndices.kt +++ b/compiler/testData/codegen/box/ranges/forInIndices/forInNonOptimizedIndices.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/ranges/safeCallRangeTo.kt b/compiler/testData/codegen/box/ranges/safeCallRangeTo.kt index b338979b609..dc1bc8285ba 100644 --- a/compiler/testData/codegen/box/ranges/safeCallRangeTo.kt +++ b/compiler/testData/codegen/box/ranges/safeCallRangeTo.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS diff --git a/compiler/testData/codegen/box/regressions/arrayLengthNPE.kt b/compiler/testData/codegen/box/regressions/arrayLengthNPE.kt index 859d01c313b..e3c91e64aaf 100644 --- a/compiler/testData/codegen/box/regressions/arrayLengthNPE.kt +++ b/compiler/testData/codegen/box/regressions/arrayLengthNPE.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // See KT-14242 var x = 1 fun box(): String { diff --git a/compiler/testData/codegen/box/regressions/hashCodeNPE.kt b/compiler/testData/codegen/box/regressions/hashCodeNPE.kt index ba7252dcba5..d362db21e77 100644 --- a/compiler/testData/codegen/box/regressions/hashCodeNPE.kt +++ b/compiler/testData/codegen/box/regressions/hashCodeNPE.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // See KT-14242 var x = 1 fun box(): String { diff --git a/compiler/testData/codegen/box/safeCall/genericNull.kt b/compiler/testData/codegen/box/safeCall/genericNull.kt index 6e3ed6865fc..d8ffc413616 100644 --- a/compiler/testData/codegen/box/safeCall/genericNull.kt +++ b/compiler/testData/codegen/box/safeCall/genericNull.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun foo(t: T) { t?.toInt() } diff --git a/compiler/testData/codegen/box/unit/kt4265.kt b/compiler/testData/codegen/box/unit/kt4265.kt index 68e0d7999f3..3c1aaf9d462 100644 --- a/compiler/testData/codegen/box/unit/kt4265.kt +++ b/compiler/testData/codegen/box/unit/kt4265.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun T.let(f: (T) -> R): R = f(this) fun box(): String { diff --git a/compiler/testData/ir/irText/expressions/bangbang.fir.txt b/compiler/testData/ir/irText/expressions/bangbang.fir.txt index d097b902fb5..df073e2d155 100644 --- a/compiler/testData/ir/irText/expressions/bangbang.fir.txt +++ b/compiler/testData/ir/irText/expressions/bangbang.fir.txt @@ -12,8 +12,19 @@ FILE fqName: fileName:/bangbang.kt RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any?): kotlin.Int declared in ' CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Int origin=EXCLEXCL : kotlin.Int - arg0: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int? origin=null - $this: GET_VAR 'a: kotlin.Any? declared in .test2' type=kotlin.Any? origin=null + arg0: BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val] + GET_VAR 'a: kotlin.Any? declared in .test2' type=kotlin.Any? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .test2' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .test2' type=kotlin.Any? origin=null FUN name:test3 visibility:public modality:FINAL (a:X of .test3) returnType:X of .test3 TYPE_PARAMETER name:X index:0 variance: superTypes:[kotlin.Any?] VALUE_PARAMETER name:a index:0 type:X of .test3 diff --git a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.fir.txt b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.fir.txt deleted file mode 100644 index 6a47ca46e36..00000000000 --- a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.fir.txt +++ /dev/null @@ -1,39 +0,0 @@ -FILE fqName: fileName:/chainOfSafeCalls.kt - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> () returnType:.C [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:foo visibility:public modality:FINAL <> ($this:.C) returnType:.C - $this: VALUE_PARAMETER name: type:.C - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (): .C declared in .C' - GET_VAR ': .C declared in .C.foo' type=.C origin=null - FUN name:bar visibility:public modality:FINAL <> ($this:.C) returnType:.C? - $this: VALUE_PARAMETER name: type:.C - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun bar (): .C? declared in .C' - GET_VAR ': .C declared in .C.bar' type=.C origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test visibility:public modality:FINAL <> (nc:.C?) returnType:.C? - VALUE_PARAMETER name:nc index:0 type:.C? - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test (nc: .C?): .C? declared in ' - CALL 'public final fun foo (): .C declared in .C' type=.C? origin=null - $this: CALL 'public final fun foo (): .C declared in .C' type=.C? origin=null - $this: CALL 'public final fun bar (): .C? declared in .C' type=.C? origin=null - $this: CALL 'public final fun foo (): .C declared in .C' type=.C? origin=null - $this: GET_VAR 'nc: .C? declared in .test' type=.C? origin=null diff --git a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.kt b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.kt index 89242c63126..9ae44ac8c1b 100644 --- a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.kt +++ b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class C { fun foo(): C = this fun bar(): C? = this diff --git a/compiler/testData/ir/irText/expressions/coercionToUnit.fir.txt b/compiler/testData/ir/irText/expressions/coercionToUnit.fir.txt index 5e05bf9077e..e4baa82bd7c 100644 --- a/compiler/testData/ir/irText/expressions/coercionToUnit.fir.txt +++ b/compiler/testData/ir/irText/expressions/coercionToUnit.fir.txt @@ -20,9 +20,31 @@ FILE fqName: fileName:/coercionToUnit.kt element: CONST String type=kotlin.String value="" FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit? origin=null - $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY - p0: CONST String type=kotlin.String value="Hello," - CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit? origin=null - $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY - p0: CONST String type=kotlin.String value="world!" + BLOCK type=kotlin.Unit? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:java.io.PrintStream? [val] + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY + WHEN type=kotlin.Unit? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: java.io.PrintStream? [val] declared in .test3' type=java.io.PrintStream? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null + $this: GET_VAR 'val tmp_0: java.io.PrintStream? [val] declared in .test3' type=java.io.PrintStream? origin=null + p0: CONST String type=kotlin.String value="Hello," + BLOCK type=kotlin.Unit? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:java.io.PrintStream? [val] + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY + WHEN type=kotlin.Unit? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: java.io.PrintStream? [val] declared in .test3' type=java.io.PrintStream? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null + $this: GET_VAR 'val tmp_1: java.io.PrintStream? [val] declared in .test3' type=java.io.PrintStream? origin=null + p0: CONST String type=kotlin.String value="world!" diff --git a/compiler/testData/ir/irText/expressions/dotQualified.fir.txt b/compiler/testData/ir/irText/expressions/dotQualified.fir.txt deleted file mode 100644 index ef415e33da0..00000000000 --- a/compiler/testData/ir/irText/expressions/dotQualified.fir.txt +++ /dev/null @@ -1,13 +0,0 @@ -FILE fqName: fileName:/dotQualified.kt - FUN name:length visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Int - VALUE_PARAMETER name:s index:0 type:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun length (s: kotlin.String): kotlin.Int declared in ' - CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 's: kotlin.String declared in .length' type=kotlin.String origin=null - FUN name:lengthN visibility:public modality:FINAL <> (s:kotlin.String?) returnType:kotlin.Int? - VALUE_PARAMETER name:s index:0 type:kotlin.String? - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun lengthN (s: kotlin.String?): kotlin.Int? declared in ' - CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int? origin=GET_PROPERTY - $this: GET_VAR 's: kotlin.String? declared in .lengthN' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/expressions/dotQualified.kt b/compiler/testData/ir/irText/expressions/dotQualified.kt index e74f60e0bae..88bd2b549f6 100644 --- a/compiler/testData/ir/irText/expressions/dotQualified.kt +++ b/compiler/testData/ir/irText/expressions/dotQualified.kt @@ -1,2 +1,3 @@ +// FIR_IDENTICAL fun length(s: String) = s.length fun lengthN(s: String?) = s?.length diff --git a/compiler/testData/ir/irText/expressions/extFunSafeInvoke.fir.txt b/compiler/testData/ir/irText/expressions/extFunSafeInvoke.fir.txt index 060e4e65581..a4cf40f3a73 100644 --- a/compiler/testData/ir/irText/expressions/extFunSafeInvoke.fir.txt +++ b/compiler/testData/ir/irText/expressions/extFunSafeInvoke.fir.txt @@ -4,6 +4,17 @@ FILE fqName: fileName:/extFunSafeInvoke.kt VALUE_PARAMETER name:fn index:1 type:kotlin.Function3 BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (receiver: kotlin.Any?, fn: kotlin.Function3): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - CONST Int type=kotlin.Int value=42 - CONST String type=kotlin.String value="Hello" + BLOCK type=IrErrorType origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val] + GET_VAR 'receiver: kotlin.Any? declared in .test' type=kotlin.Any? origin=null + WHEN type=IrErrorType origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .test' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CONST Int type=kotlin.Int value=42 + CONST String type=kotlin.String value="Hello" diff --git a/compiler/testData/ir/irText/expressions/kt30020.fir.txt b/compiler/testData/ir/irText/expressions/kt30020.fir.txt index e01f187ee80..d610248a406 100644 --- a/compiler/testData/ir/irText/expressions/kt30020.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt30020.fir.txt @@ -50,15 +50,37 @@ FILE fqName: fileName:/kt30020.kt : kotlin.Int $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList - arg0: CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList? origin=GET_PROPERTY - $this: GET_VAR 'nx: .X? declared in .test' type=.X? origin=null + arg0: BLOCK type=kotlin.collections.MutableList? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.X? [val] + GET_VAR 'nx: .X? declared in .test' type=.X? origin=null + WHEN type=kotlin.collections.MutableList? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: .X? [val] declared in .test' type=.X? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=GET_PROPERTY + $this: GET_VAR 'val tmp_0: .X? [val] declared in .test' type=.X? origin=null element: CONST Int type=kotlin.Int value=5 CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null : kotlin.Int $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList - arg0: CALL 'public abstract fun f (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList? origin=null - $this: GET_VAR 'nx: .X? declared in .test' type=.X? origin=null + arg0: BLOCK type=kotlin.collections.MutableList? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.X? [val] + GET_VAR 'nx: .X? declared in .test' type=.X? origin=null + WHEN type=kotlin.collections.MutableList? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: .X? [val] declared in .test' type=.X? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public abstract fun f (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=null + $this: GET_VAR 'val tmp_1: .X? [val] declared in .test' type=.X? origin=null element: CONST Int type=kotlin.Int value=6 FUN name:testExtensionReceiver visibility:public modality:FINAL <> ($receiver:kotlin.collections.MutableList) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:kotlin.collections.MutableList diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.txt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.txt index 0d9d574e0b3..c7b61b2225c 100644 --- a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.txt +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.txt @@ -34,8 +34,19 @@ FILE fqName:test fileName:/safeCallWithIncrementDecrement.kt $receiver: VALUE_PARAMETER name: type:kotlin.Int? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun inc (): kotlin.Int? [operator] declared in test' - CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int? origin=null - $this: GET_VAR ': kotlin.Int? declared in test.inc' type=kotlin.Int? origin=null + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int? [val] + GET_VAR ': kotlin.Int? declared in test.inc' type=kotlin.Int? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in test.inc' type=kotlin.Int? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in test.inc' type=kotlin.Int? origin=null FUN name:get visibility:public modality:FINAL <> ($receiver:kotlin.Int?, index:kotlin.Int) returnType:kotlin.Int [operator] $receiver: VALUE_PARAMETER name: type:kotlin.Int? VALUE_PARAMETER name:index index:0 type:kotlin.Int @@ -50,26 +61,59 @@ FILE fqName:test fileName:/safeCallWithIncrementDecrement.kt FUN name:testProperty visibility:public modality:FINAL <> (nc:test.C?) returnType:kotlin.Unit VALUE_PARAMETER name:nc index:0 type:test.C? BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int? [val] - CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int? origin=GET_PROPERTY - $receiver: GET_VAR 'nc: test.C? declared in test.testProperty' type=test.C? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int? [val] + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:test.C? [val] + GET_VAR 'nc: test.C? declared in test.testProperty' type=test.C? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_2: test.C? [val] declared in test.testProperty' type=test.C? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY + $receiver: GET_VAR 'val tmp_2: test.C? [val] declared in test.testProperty' type=test.C? origin=null CALL 'public final fun (value: kotlin.Int): kotlin.Unit declared in test' type=kotlin.Unit origin=EQ $receiver: GET_VAR 'nc: test.C? declared in test.testProperty' type=test.C? origin=null value: CALL 'public final fun inc (): kotlin.Int? [operator] declared in test' type=kotlin.Int? origin=null - $receiver: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in test.testProperty' type=kotlin.Int? origin=null - GET_VAR 'val tmp_0: kotlin.Int? [val] declared in test.testProperty' type=kotlin.Int? origin=null + $receiver: GET_VAR 'val tmp_1: kotlin.Int? [val] declared in test.testProperty' type=kotlin.Int? origin=null + GET_VAR 'val tmp_1: kotlin.Int? [val] declared in test.testProperty' type=kotlin.Int? origin=null FUN name:testArrayAccess visibility:public modality:FINAL <> (nc:test.C?) returnType:kotlin.Unit VALUE_PARAMETER name:nc index:0 type:test.C? BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in test' type=kotlin.Int origin=null - $receiver: CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int? origin=GET_PROPERTY - $receiver: GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null + $receiver: BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:test.C? [val] + GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_4: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY + $receiver: GET_VAR 'val tmp_4: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null index: CONST Int type=kotlin.Int value=0 CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit [operator] declared in test' type=kotlin.Unit origin=null - $receiver: CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int? origin=GET_PROPERTY - $receiver: GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null + $receiver: BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:test.C? [val] + GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_5: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY + $receiver: GET_VAR 'val tmp_5: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null index: CONST Int type=kotlin.Int value=0 value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_1: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null - GET_VAR 'val tmp_1: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_3: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + GET_VAR 'val tmp_3: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/safeCalls.fir.txt b/compiler/testData/ir/irText/expressions/safeCalls.fir.txt index 63e916b0e9c..7c53a733e55 100644 --- a/compiler/testData/ir/irText/expressions/safeCalls.fir.txt +++ b/compiler/testData/ir/irText/expressions/safeCalls.fir.txt @@ -64,22 +64,55 @@ FILE fqName: fileName:/safeCalls.kt VALUE_PARAMETER name:x index:0 type:kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (x: kotlin.String?): kotlin.Int? declared in ' - CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int? origin=GET_PROPERTY - $this: GET_VAR 'x: kotlin.String? declared in .test1' type=kotlin.String? origin=null + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.String? [val] + GET_VAR 'x: kotlin.String? declared in .test1' type=kotlin.String? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.String? [val] declared in .test1' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'val tmp_0: kotlin.String? [val] declared in .test1' type=kotlin.String? origin=null FUN name:test2 visibility:public modality:FINAL <> (x:kotlin.String?) returnType:kotlin.Int? VALUE_PARAMETER name:x index:0 type:kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (x: kotlin.String?): kotlin.Int? declared in ' - CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int? origin=null - $this: GET_VAR 'x: kotlin.String? declared in .test2' type=kotlin.String? origin=null + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.String? [val] + GET_VAR 'x: kotlin.String? declared in .test2' type=kotlin.String? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: kotlin.String? [val] declared in .test2' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_1: kotlin.String? [val] declared in .test2' type=kotlin.String? origin=null FUN name:test3 visibility:public modality:FINAL <> (x:kotlin.String?, y:kotlin.Any?) returnType:kotlin.Boolean? VALUE_PARAMETER name:x index:0 type:kotlin.String? VALUE_PARAMETER name:y index:1 type:kotlin.Any? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (x: kotlin.String?, y: kotlin.Any?): kotlin.Boolean? declared in ' - CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any' type=kotlin.Boolean? origin=null - $this: GET_VAR 'x: kotlin.String? declared in .test3' type=kotlin.String? origin=null - other: GET_VAR 'y: kotlin.Any? declared in .test3' type=kotlin.Any? origin=null + BLOCK type=kotlin.Boolean? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.String? [val] + GET_VAR 'x: kotlin.String? declared in .test3' type=kotlin.String? origin=null + WHEN type=kotlin.Boolean? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_2: kotlin.String? [val] declared in .test3' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any' type=kotlin.Boolean origin=null + $this: GET_VAR 'val tmp_2: kotlin.String? [val] declared in .test3' type=kotlin.String? origin=null + other: GET_VAR 'y: kotlin.Any? declared in .test3' type=kotlin.Any? origin=null FUN name:test4 visibility:public modality:FINAL <> (x:.Ref?) returnType:kotlin.Unit VALUE_PARAMETER name:x index:0 type:.Ref? BLOCK_BODY @@ -91,9 +124,20 @@ FILE fqName: fileName:/safeCalls.kt VALUE_PARAMETER name:s index:0 type:kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test5 (s: kotlin.String?): kotlin.Int? declared in ' - CALL 'public open fun extLength (): kotlin.Int declared in .IHost' type=kotlin.Int? origin=null - $this: GET_VAR ': .IHost declared in .test5' type=.IHost origin=null - $receiver: GET_VAR 's: kotlin.String? declared in .test5' type=kotlin.String? origin=null + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.String? [val] + GET_VAR 's: kotlin.String? declared in .test5' type=kotlin.String? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_3: kotlin.String? [val] declared in .test5' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun extLength (): kotlin.Int declared in .IHost' type=kotlin.Int origin=null + $this: GET_VAR ': .IHost declared in .test5' type=.IHost origin=null + $receiver: GET_VAR 'val tmp_3: kotlin.String? [val] declared in .test5' type=kotlin.String? origin=null FUN name:foo visibility:public modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Int $receiver: VALUE_PARAMETER name: type:kotlin.Int BLOCK_BODY @@ -101,5 +145,16 @@ FILE fqName: fileName:/safeCalls.kt CONST Int type=kotlin.Int value=239 FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun foo (): kotlin.Int declared in ' type=kotlin.Int? origin=null - $receiver: CONST Int type=kotlin.Int value=42 + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=42 + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_4: kotlin.Int [val] declared in .box' type=kotlin.Int origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun foo (): kotlin.Int declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_4: kotlin.Int [val] declared in .box' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.fir.txt b/compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.fir.txt index d5bf634f25c..92ceee73663 100644 --- a/compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.fir.txt +++ b/compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.fir.txt @@ -35,8 +35,19 @@ FILE fqName: fileName:/temporaryInEnumEntryInitializer.kt CONSTRUCTOR visibility:private <> () returnType:.En.ENTRY [primary] BLOCK_BODY ENUM_CONSTRUCTOR_CALL 'private constructor (x: kotlin.String?) [primary] declared in .En' - x: CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String? origin=null - $this: CALL 'public final fun (): kotlin.Any? declared in ' type=kotlin.Any? origin=GET_PROPERTY + x: BLOCK type=kotlin.String? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val] + CALL 'public final fun (): kotlin.Any? declared in ' type=kotlin.Any? origin=GET_PROPERTY + WHEN type=kotlin.String? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .En.ENTRY.' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null + $this: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .En.ENTRY.' type=kotlin.Any? origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:ENTRY modality:FINAL visibility:private superTypes:[.En]' FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.En> SYNTHETIC_BODY kind=ENUM_VALUES diff --git a/compiler/testData/ir/irText/expressions/temporaryInInitBlock.fir.txt b/compiler/testData/ir/irText/expressions/temporaryInInitBlock.fir.txt deleted file mode 100644 index 0c61b4bc438..00000000000 --- a/compiler/testData/ir/irText/expressions/temporaryInInitBlock.fir.txt +++ /dev/null @@ -1,36 +0,0 @@ -FILE fqName: fileName:/temporaryInInitBlock.kt - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> (x:kotlin.Any?) returnType:.C [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Any? - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:s visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String? visibility:private [final] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.String? - correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.C - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String? declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String? visibility:private [final]' type=kotlin.String? origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - ANONYMOUS_INITIALIZER isStatic=false - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String? visibility:private [final]' type=kotlin.Unit origin=null - receiver: GET_VAR ': .C declared in .C' type=.C origin=null - value: CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String? origin=null - $this: GET_VAR 'x: kotlin.Any? declared in .C.' type=kotlin.Any? origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/temporaryInInitBlock.kt b/compiler/testData/ir/irText/expressions/temporaryInInitBlock.kt index f1f965c0be3..d27485192f1 100644 --- a/compiler/testData/ir/irText/expressions/temporaryInInitBlock.kt +++ b/compiler/testData/ir/irText/expressions/temporaryInInitBlock.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class C(x: Any?) { val s: String? init { diff --git a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt index 430c896a235..bebcbf1e438 100644 --- a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt +++ b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt @@ -31,6 +31,28 @@ FILE fqName: fileName:/variableAsFunctionCall.kt VALUE_PARAMETER name:ns index:0 type:kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (ns: kotlin.String?): kotlin.String? declared in ' - CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.String? origin=INVOKE - $this: CALL 'public final fun k (): kotlin.Function0 declared in ' type=kotlin.Function0? origin=null - $receiver: GET_VAR 'ns: kotlin.String? declared in .test4' type=kotlin.String? origin=null + BLOCK type=kotlin.String? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Function0? [val] + BLOCK type=kotlin.Function0? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.String? [val] + GET_VAR 'ns: kotlin.String? declared in .test4' type=kotlin.String? origin=null + WHEN type=kotlin.Function0? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: kotlin.String? [val] declared in .test4' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun k (): kotlin.Function0 declared in ' type=kotlin.Function0 origin=null + $receiver: GET_VAR 'val tmp_1: kotlin.String? [val] declared in .test4' type=kotlin.String? origin=null + WHEN type=kotlin.String? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Function0? [val] declared in .test4' type=kotlin.Function0? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.String origin=INVOKE + $this: GET_VAR 'val tmp_0: kotlin.Function0? [val] declared in .test4' type=kotlin.Function0? origin=null