From 9a2eff6487e6fb20fdc11ea4b7342d63ccce5bb5 Mon Sep 17 00:00:00 2001 From: Vladimir Sukharev Date: Mon, 18 Sep 2023 15:27:19 +0000 Subject: [PATCH] [FIR2IR] Don't replace `while loop` and `when branch` body blocks with single expression. Skip some empty blocks. https://youtrack.jetbrains.com/issue/KT-60264/K2-while-loop-body-block-sometimes-replaced-with-single-expression Merge-request: KT-MR-12035 Merged-by: Vladimir Sukharev --- .../kotlin/fir/backend/Fir2IrVisitor.kt | 52 +++--- .../noSymbolForIntRangeIterator.fir.ir.txt | 13 +- .../contextReceivers/fromKEEP/dp.fir.ir.txt | 83 --------- .../contextReceivers/fromKEEP/dp.fir.kt.txt | 30 ---- .../contextReceivers/fromKEEP/dp.kt | 1 + .../declarations/localVarInDoWhile.fir.ir.txt | 12 -- .../declarations/localVarInDoWhile.fir.kt.txt | 7 - .../irText/declarations/localVarInDoWhile.kt | 1 + .../expressions/breakContinue.fir.ir.txt | 53 ------ .../expressions/breakContinue.fir.kt.txt | 38 ---- .../ir/irText/expressions/breakContinue.kt | 1 + .../breakContinueInLoopHeader.fir.ir.txt | 13 +- .../breakContinueInLoopHeader.fir.kt.txt | 10 +- .../breakContinueInWhen.fir.ir.txt | 67 +++---- .../breakContinueInWhen.fir.kt.txt | 31 ++-- .../exhaustiveWhenElseBranch.fir.ir.txt | 75 ++++---- .../exhaustiveWhenElseBranch.fir.kt.txt | 31 ++-- .../ir/irText/expressions/for.fir.ir.txt | 7 +- .../ir/irText/expressions/for.fir.kt.txt | 8 +- .../forWithBreakContinue.fir.ir.txt | 14 +- .../forWithBreakContinue.fir.kt.txt | 9 +- .../forWithImplicitReceivers.fir.ir.txt | 5 +- .../forWithImplicitReceivers.fir.kt.txt | 5 +- .../samConversionInVarargsMixed.fir.ir.txt | 40 ----- .../samConversionInVarargsMixed.fir.kt.txt | 16 -- .../samConversionInVarargsMixed.kt | 1 + .../samConversionsWithSmartCasts.fir.ir.txt | 36 ++-- .../samConversionsWithSmartCasts.fir.kt.txt | 17 +- .../ir/irText/expressions/kt48708.fir.ir.txt | 20 --- .../ir/irText/expressions/kt48708.fir.kt.txt | 13 -- .../testData/ir/irText/expressions/kt48708.kt | 1 + .../ir/irText/expressions/kt50028.fir.ir.txt | 13 +- .../ir/irText/expressions/kt50028.fir.kt.txt | 13 +- .../sam/genericSamSmartcast.fir.ir.txt | 25 +-- .../sam/genericSamSmartcast.fir.kt.txt | 9 +- .../samConversionsWithSmartCasts.fir.ir.txt | 51 +++--- .../samConversionsWithSmartCasts.fir.kt.txt | 21 ++- .../ir/irText/expressions/throw.fir.ir.txt | 15 -- .../ir/irText/expressions/throw.fir.kt.txt | 9 - .../testData/ir/irText/expressions/throw.kt | 1 + .../whenSmartCastToEnum.fir.ir.txt | 102 +++++------ .../whenSmartCastToEnum.fir.kt.txt | 41 +++-- .../whenUnusedExpression.fir.ir.txt | 25 +-- .../whenUnusedExpression.fir.kt.txt | 11 +- .../expressions/whileDoWhile.fir.ir.txt | 34 ++-- .../expressions/whileDoWhile.fir.kt.txt | 15 +- .../ir/irText/firProblems/ArrayMap.fir.ir.txt | 76 ++++---- .../ir/irText/firProblems/ArrayMap.fir.kt.txt | 35 ++-- .../firProblems/DeepCopyIrTree.fir.ir.txt | 35 ++-- .../firProblems/DeepCopyIrTree.fir.kt.txt | 8 +- .../ir/irText/firProblems/Modality.fir.ir.txt | 168 ------------------ .../ir/irText/firProblems/Modality.fir.kt.txt | 69 ------- .../ir/irText/firProblems/Modality.kt | 1 + .../ir/irText/firProblems/OutBox.fir.ir.txt | 11 +- .../ir/irText/firProblems/OutBox.fir.kt.txt | 5 +- .../reflectGetOnNullableTypeAlias.fir.ir.txt | 50 ------ .../reflectGetOnNullableTypeAlias.fir.kt.txt | 21 --- .../reflectGetOnNullableTypeAlias.kt | 1 + .../regressions/coercionInLoop.fir.ir.txt | 2 +- .../ir/irText/regressions/kt24114.fir.ir.txt | 91 +++++----- .../ir/irText/regressions/kt24114.fir.kt.txt | 35 ++-- 61 files changed, 601 insertions(+), 1102 deletions(-) delete mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/breakContinue.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/expressions/breakContinue.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/kt48708.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/expressions/kt48708.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/throw.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/expressions/throw.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/firProblems/Modality.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.kt.txt 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 6017acdd1f6..50f5b09a918 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 @@ -6,10 +6,7 @@ package org.jetbrains.kotlin.fir.backend import com.intellij.psi.tree.IElementType -import org.jetbrains.kotlin.KtFakeSourceElementKind -import org.jetbrains.kotlin.KtNodeTypes -import org.jetbrains.kotlin.KtPsiSourceElement -import org.jetbrains.kotlin.KtSourceElement +import org.jetbrains.kotlin.* import org.jetbrains.kotlin.contracts.description.LogicOperationKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities @@ -26,6 +23,7 @@ import org.jetbrains.kotlin.fir.deserialization.toQualifiedPropertyAccessExpress import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.FirContractCallBlock import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition +import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyExpressionBlock import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression import org.jetbrains.kotlin.fir.extensions.extensionService import org.jetbrains.kotlin.fir.references.* @@ -59,6 +57,7 @@ import org.jetbrains.kotlin.psi.KtBinaryExpression import org.jetbrains.kotlin.psi.KtForExpression import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.util.OperatorNameConventions +import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance import org.jetbrains.kotlin.utils.addToStdlib.runUnless @@ -1077,6 +1076,10 @@ class Fir2IrVisitor( return it } } + if (source?.kind is KtRealSourceElementKind) { + val lastStatementHasNothingType = (statements.lastOrNull() as? FirExpression)?.resolvedType?.isNothing == true + return statements.convertToIrBlock(source, origin, forceUnitType = origin?.isLoop == true || lastStatementHasNothingType) + } return statements.convertToIrExpressionOrBlock(source, origin) } @@ -1111,18 +1114,19 @@ class Fir2IrVisitor( return source.convertWithOffsets { startOffset, endOffset -> if (origin == IrStatementOrigin.DO_WHILE_LOOP) { IrCompositeImpl( - startOffset, endOffset, type, origin, + startOffset, endOffset, type, null, mapToIrStatements(recognizePostfixIncDec = false).filterNotNull() ) } else { val irStatements = mapToIrStatements() val singleStatement = irStatements.singleOrNull() - if (singleStatement is IrBlock && + if (origin?.isLoop != true && singleStatement is IrBlock && (singleStatement.origin == IrStatementOrigin.POSTFIX_INCR || singleStatement.origin == IrStatementOrigin.POSTFIX_DECR) ) { singleStatement } else { - IrBlockImpl(startOffset, endOffset, type, origin, irStatements.filterNotNull()) + val blockOrigin = if (forceUnitType && origin != IrStatementOrigin.FOR_LOOP) null else origin + IrBlockImpl(startOffset, endOffset, type, blockOrigin, irStatements.filterNotNull()) } } } @@ -1322,32 +1326,35 @@ class Fir2IrVisitor( condition = convertToIrExpression(whileLoop.condition) body = if (isForLoop) { /* - * for loops in IR should have specific for of their body, because some of lowerings (e.g. `ForLoopLowering`) expects - * exactly that shape: + * for loops in IR must have their body in the exact following form + * because some of the lowerings (e.g. `ForLoopLowering`) expect it: * * for (x in list) { ...body...} * * IR (loop body): * IrBlock: * x = .next() + * ... possible destructured loop variables, in case iterator is a tuple: `for ((a,b,c) in list) { ...body...}` ... * IrBlock: * ...body... */ firLoopBody.convertWithOffsets { innerStartOffset, innerEndOffset -> val loopBodyStatements = firLoopBody.statements - if (loopBodyStatements.isEmpty()) { - error("Unexpected shape of body of for loop") + val firLoopVarStmt = loopBodyStatements.firstOrNull() + ?: error("Unexpected shape of for loop body: missing body statements") + + val (destructuredLoopVariables, realStatements) = loopBodyStatements.drop(1).partition { + it is FirProperty && it.initializer is FirComponentCall } - val loopVariables = mutableListOf() - var loopVariableIndex = 0 - for (loopBodyStatement in loopBodyStatements) { - if (loopVariableIndex > 0) { - if (loopBodyStatement !is FirProperty || loopBodyStatement.initializer !is FirComponentCall) { - break - } + val firExpression = realStatements.singleOrNull() as? FirExpression + ?: error("Unexpected shape of for loop body: must be single real loop statement, but got ${realStatements.size}") + + val irStatements = buildList { + addIfNotNull(firLoopVarStmt.toIrStatement()) + destructuredLoopVariables.forEach { addIfNotNull(it.toIrStatement()) } + if (firExpression !is FirEmptyExpressionBlock) { + add(convertToIrExpression(firExpression)) } - loopBodyStatement.toIrStatement()?.let { loopVariables.add(it) } - loopVariableIndex++ } IrBlockImpl( @@ -1355,12 +1362,11 @@ class Fir2IrVisitor( innerEndOffset, irBuiltIns.unitType, origin, - loopVariables + - loopBodyStatements.drop(loopVariableIndex).convertToIrExpressionOrBlock(firLoopBody.source, null) + irStatements, ) } } else { - firLoopBody.convertToIrExpressionOrBlock() + firLoopBody.convertToIrExpressionOrBlock(origin) } loopMap.remove(whileLoop) } diff --git a/compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.fir.ir.txt b/compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.fir.ir.txt index d5ed1ab232a..46216174670 100644 --- a/compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.fir.ir.txt +++ b/compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.fir.ir.txt @@ -84,12 +84,13 @@ FILE fqName: fileName:/noSymbolForIntRangeIterator.kt VAR FOR_LOOP_VARIABLE name:j type:kotlin.Int [val] CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_2: kotlin.collections.IntIterator declared in .test.localFunc.' type=kotlin.collections.IntIterator origin=null - CALL 'public final fun appendLine (value: kotlin.String?): java.lang.StringBuilder declared in kotlin.text' type=java.lang.StringBuilder origin=null - $receiver: GET_VAR '$this$buildString: java.lang.StringBuilder declared in .test.localFunc.' type=java.lang.StringBuilder origin=null - value: STRING_CONCATENATION type=kotlin.String - CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=MUL - $this: GET_VAR 'val i: kotlin.Int declared in .test.localFunc' type=kotlin.Int origin=null - other: GET_VAR 'val j: kotlin.Int declared in .test.localFunc.' type=kotlin.Int origin=null + BLOCK type=java.lang.StringBuilder origin=null + CALL 'public final fun appendLine (value: kotlin.String?): java.lang.StringBuilder declared in kotlin.text' type=java.lang.StringBuilder origin=null + $receiver: GET_VAR '$this$buildString: java.lang.StringBuilder declared in .test.localFunc.' type=java.lang.StringBuilder origin=null + value: STRING_CONCATENATION type=kotlin.String + CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=MUL + $this: GET_VAR 'val i: kotlin.Int declared in .test.localFunc' type=kotlin.Int origin=null + other: GET_VAR 'val j: kotlin.Int declared in .test.localFunc.' type=kotlin.Int origin=null CALL 'public final fun takeString (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: GET_VAR 'val s: kotlin.String declared in .test.localFunc' type=kotlin.String origin=null CALL 'local final fun localFunc (): kotlin.Unit declared in .test' type=kotlin.Unit origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.ir.txt deleted file mode 100644 index 31bafd35324..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.ir.txt +++ /dev/null @@ -1,83 +0,0 @@ -FILE fqName: fileName:/dp.kt - CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.View - CONSTRUCTOR visibility:public <> () returnType:.View [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:coefficient visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - CONST Int type=kotlin.Int value=42 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.View) returnType:kotlin.Int - correspondingProperty: PROPERTY name:coefficient visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.View - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .View' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .View declared in .View.' type=.View 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 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 - PROPERTY name:dp visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($receiver:kotlin.Int, $context_receiver_0:.View) returnType:kotlin.Int - correspondingProperty: PROPERTY name:dp visibility:public modality:FINAL [val] - contextReceiverParametersCount: 1 - $receiver: VALUE_PARAMETER name: type:kotlin.Int - VALUE_PARAMETER name:$context_receiver_0 index:0 type:.View - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun ($context_receiver_0: .View): kotlin.Int declared in ' - CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=MUL - $this: CALL 'public final fun (): kotlin.Int declared in .View' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR '$context_receiver_0: .View declared in .' type=.View origin=null - other: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null - FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - CALL 'public final fun with (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.with declared in kotlin' type=kotlin.Nothing origin=null - : .View - : kotlin.Nothing - receiver: CONSTRUCTOR_CALL 'public constructor () declared in .View' type=.View origin=null - block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.View, kotlin.Nothing> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.View) returnType:kotlin.Nothing - $receiver: VALUE_PARAMETER name:$this$with type:.View - BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - 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: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List origin=null - : kotlin.Int - : kotlin.Int - $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.listOf): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List origin=null - : kotlin.Int - elements: VARARG type=kotlin.Array varargElementType=kotlin.Int - CONST Int type=kotlin.Int value=1 - CONST Int type=kotlin.Int value=2 - CONST Int type=kotlin.Int value=10 - transform: FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:it index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Int): kotlin.Int declared in .box.' - CALL 'public final fun ($context_receiver_0: .View): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY - $receiver: GET_VAR 'it: kotlin.Int declared in .box..' type=kotlin.Int origin=null - $context_receiver_0: GET_VAR '$this$with: .View declared in .box.' type=.View origin=null - arg1: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.listOf): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List origin=null - : kotlin.Int - elements: VARARG type=kotlin.Array varargElementType=kotlin.Int - CONST Int type=kotlin.Int value=42 - CONST Int type=kotlin.Int value=84 - CONST Int type=kotlin.Int value=420 - then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' - CONST String type=kotlin.String value="OK" - RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' - CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.kt.txt deleted file mode 100644 index 8da93b8b9d6..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.kt.txt +++ /dev/null @@ -1,30 +0,0 @@ -class View { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - val coefficient: Int - field = 42 - get - -} - -val Int.dp: Int - get($context_receiver_0: View): Int { - return $context_receiver_0.().times(other = ) - } - -fun box(): String { - with(receiver = View(), block = local fun View.(): Nothing { - when { - EQEQ(arg0 = listOf(elements = [1, 2, 10]).map(transform = local fun (it: Int): Int { - return it.($context_receiver_0 = $this$with) - } -), arg1 = listOf(elements = [42, 84, 420])) -> return "OK" - } - return "fail" - } -) -} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt index 1ee4a789db3..4156bff2e67 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ContextReceivers // WITH_STDLIB class View { diff --git a/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.ir.txt b/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.ir.txt deleted file mode 100644 index 3257665a44e..00000000000 --- a/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.ir.txt +++ /dev/null @@ -1,12 +0,0 @@ -FILE fqName: fileName:/localVarInDoWhile.kt - FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - BLOCK type=kotlin.Unit origin=null - DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP - VAR name:x type:kotlin.Int [val] - CONST Int type=kotlin.Int value=42 - condition: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ - $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ - arg0: GET_VAR 'val x: kotlin.Int declared in .foo' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=42 diff --git a/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.kt.txt b/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.kt.txt deleted file mode 100644 index 27c61f6134f..00000000000 --- a/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.kt.txt +++ /dev/null @@ -1,7 +0,0 @@ -fun foo() { - { // BLOCK - do// COMPOSITE { - val x: Int = 42 - // } while (EQEQ(arg0 = x, arg1 = 42).not()) - } -} diff --git a/compiler/testData/ir/irText/declarations/localVarInDoWhile.kt b/compiler/testData/ir/irText/declarations/localVarInDoWhile.kt index 7d7d7ad1b1b..c35ae290307 100644 --- a/compiler/testData/ir/irText/declarations/localVarInDoWhile.kt +++ b/compiler/testData/ir/irText/declarations/localVarInDoWhile.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun foo() { do { val x = 42 diff --git a/compiler/testData/ir/irText/expressions/breakContinue.fir.ir.txt b/compiler/testData/ir/irText/expressions/breakContinue.fir.ir.txt deleted file mode 100644 index ca397655a53..00000000000 --- a/compiler/testData/ir/irText/expressions/breakContinue.fir.ir.txt +++ /dev/null @@ -1,53 +0,0 @@ -FILE fqName: fileName:/breakContinue.kt - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - WHILE label=null origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: BREAK label=null loop.label=null - BLOCK type=kotlin.Unit origin=null - DO_WHILE label=null origin=DO_WHILE_LOOP - body: BREAK label=null loop.label=null - condition: CONST Boolean type=kotlin.Boolean value=true - WHILE label=null origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: CONTINUE label=null loop.label=null - BLOCK type=kotlin.Unit origin=null - DO_WHILE label=null origin=DO_WHILE_LOOP - body: CONTINUE label=null loop.label=null - condition: CONST Boolean type=kotlin.Boolean value=true - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - WHILE label=OUTER origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: BLOCK type=kotlin.Nothing origin=null - WHILE label=INNER origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: BLOCK type=kotlin.Nothing origin=null - BREAK label=INNER loop.label=INNER - BREAK label=OUTER loop.label=OUTER - BREAK label=OUTER loop.label=OUTER - WHILE label=OUTER origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: BLOCK type=kotlin.Nothing origin=null - WHILE label=INNER origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: BLOCK type=kotlin.Nothing origin=null - CONTINUE label=INNER loop.label=INNER - CONTINUE label=OUTER loop.label=OUTER - CONTINUE label=OUTER loop.label=OUTER - FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - WHILE label=L origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: BLOCK type=kotlin.Nothing origin=null - WHILE label=L origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: BREAK label=L loop.label=L - BREAK label=L loop.label=L - WHILE label=L origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: BLOCK type=kotlin.Nothing origin=null - WHILE label=L origin=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value=true - body: CONTINUE label=L loop.label=L - CONTINUE label=L loop.label=L diff --git a/compiler/testData/ir/irText/expressions/breakContinue.fir.kt.txt b/compiler/testData/ir/irText/expressions/breakContinue.fir.kt.txt deleted file mode 100644 index 55a145d4f9a..00000000000 --- a/compiler/testData/ir/irText/expressions/breakContinue.fir.kt.txt +++ /dev/null @@ -1,38 +0,0 @@ -fun test1() { - while (true) break - { // BLOCK - dobreak while (true) - } - while (true) continue - { // BLOCK - docontinue while (true) - } -} - -fun test2() { - OUTER@ while (true) { // BLOCK - INNER@ while (true) { // BLOCK - break@INNER - break@OUTER - } - break@OUTER - } - OUTER@ while (true) { // BLOCK - INNER@ while (true) { // BLOCK - continue@INNER - continue@OUTER - } - continue@OUTER - } -} - -fun test3() { - L@ while (true) { // BLOCK - L@ while (true) break@L - break@L - } - L@ while (true) { // BLOCK - L@ while (true) continue@L - continue@L - } -} diff --git a/compiler/testData/ir/irText/expressions/breakContinue.kt b/compiler/testData/ir/irText/expressions/breakContinue.kt index c501aa0b3f9..3c240397792 100644 --- a/compiler/testData/ir/irText/expressions/breakContinue.kt +++ b/compiler/testData/ir/irText/expressions/breakContinue.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun test1() { while (true) { break } do { break } while (true) diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt index c7baf11a721..2ad7074b260 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt @@ -67,7 +67,6 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_2: kotlin.collections.Iterator declared in .test3' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Unit origin=null FUN name:test4 visibility:public modality:FINAL <> (ss:kotlin.collections.List?) returnType:kotlin.Unit VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List? BLOCK_BODY @@ -96,7 +95,6 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_4: kotlin.collections.Iterator declared in .test4' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Unit origin=null FUN name:test5 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:i type:kotlin.Int [var] @@ -114,11 +112,12 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt CONST Int type=kotlin.Int value=0 BLOCK type=kotlin.Unit origin=null DO_WHILE label=Inner origin=DO_WHILE_LOOP - body: BLOCK type=kotlin.Int origin=null - SET_VAR 'var j: kotlin.Int declared in .test5' type=kotlin.Unit origin=PREFIX_INCR - CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'var j: kotlin.Int declared in .test5' type=kotlin.Int origin=null - GET_VAR 'var j: kotlin.Int declared in .test5' type=kotlin.Int origin=null + body: COMPOSITE type=kotlin.Unit origin=null + BLOCK type=kotlin.Int origin=null + SET_VAR 'var j: kotlin.Int declared in .test5' type=kotlin.Unit origin=PREFIX_INCR + CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var j: kotlin.Int declared in .test5' type=kotlin.Int origin=null + GET_VAR 'var j: kotlin.Int declared in .test5' type=kotlin.Int origin=null condition: WHEN type=kotlin.Boolean origin=IF BRANCH if: CALL 'public final fun greaterOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt index ca09f0d0113..8ef7c7157d0 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt @@ -36,8 +36,6 @@ fun test3(ss: List?) { }.iterator() L2@ while (.hasNext()) { // BLOCK val s: String = .next() - { // BLOCK - } } } } @@ -55,8 +53,6 @@ fun test4(ss: List?) { }.iterator() L2@ while (.hasNext()) { // BLOCK val s: String = .next() - { // BLOCK - } } } } @@ -71,10 +67,12 @@ fun test5() { } /*~> Unit */ var j: Int = 0 { // BLOCK - Inner@ do{ // BLOCK + Inner@ do// COMPOSITE { + { // BLOCK j = j.inc() j - } while (when { + } + // } while (when { greaterOrEqual(arg0 = j, arg1 = 3) -> false else -> break@Inner }) diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.ir.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.ir.txt index 959a5dbae77..67300c4ebc8 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.ir.txt @@ -23,12 +23,13 @@ FILE fqName: fileName:/breakContinueInWhen.kt VAR FOR_LOOP_VARIABLE name:x type:kotlin.Int [val] CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_0: kotlin.collections.IntIterator declared in .testBreakFor' type=kotlin.collections.IntIterator origin=null - WHEN type=kotlin.Unit origin=WHEN - BRANCH - if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT - arg0: GET_VAR 'var k: kotlin.Int declared in .testBreakFor' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: BREAK label=null loop.label=null + BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int declared in .testBreakFor' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null FUN name:testBreakWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:k type:kotlin.Int [var] @@ -37,24 +38,26 @@ FILE fqName: fileName:/breakContinueInWhen.kt condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT arg0: GET_VAR 'var k: kotlin.Int declared in .testBreakWhile' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=10 - body: WHEN type=kotlin.Unit origin=WHEN - BRANCH - if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT - arg0: GET_VAR 'var k: kotlin.Int declared in .testBreakWhile' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: BREAK label=null loop.label=null + body: BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int declared in .testBreakWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null FUN name:testBreakDoWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:k type:kotlin.Int [var] CONST Int type=kotlin.Int value=0 BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - body: WHEN type=kotlin.Unit origin=WHEN - BRANCH - if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT - arg0: GET_VAR 'var k: kotlin.Int declared in .testBreakDoWhile' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: BREAK label=null loop.label=null + body: COMPOSITE type=kotlin.Unit origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int declared in .testBreakDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT arg0: GET_VAR 'var k: kotlin.Int declared in .testBreakDoWhile' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=10 @@ -82,12 +85,13 @@ FILE fqName: fileName:/breakContinueInWhen.kt VAR FOR_LOOP_VARIABLE name:x type:kotlin.Int [val] CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_1: kotlin.collections.IntIterator declared in .testContinueFor' type=kotlin.collections.IntIterator origin=null - WHEN type=kotlin.Unit origin=WHEN - BRANCH - if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT - arg0: GET_VAR 'var k: kotlin.Int declared in .testContinueFor' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: CONTINUE label=null loop.label=null + BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int declared in .testContinueFor' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null FUN name:testContinueWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:k type:kotlin.Int [var] @@ -96,12 +100,13 @@ FILE fqName: fileName:/breakContinueInWhen.kt condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT arg0: GET_VAR 'var k: kotlin.Int declared in .testContinueWhile' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=10 - body: WHEN type=kotlin.Unit origin=WHEN - BRANCH - if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT - arg0: GET_VAR 'var k: kotlin.Int declared in .testContinueWhile' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: CONTINUE label=null loop.label=null + body: BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int declared in .testContinueWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null FUN name:testContinueDoWhile visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:k type:kotlin.Int [var] @@ -110,7 +115,7 @@ FILE fqName: fileName:/breakContinueInWhen.kt CONST String type=kotlin.String value="" BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int origin=null SET_VAR 'var k: kotlin.Int declared in .testContinueDoWhile' type=kotlin.Unit origin=PREFIX_INCR diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt index 02f03b8d174..1ff539b50f4 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt @@ -8,8 +8,10 @@ fun testBreakFor() { val : IntIterator = xs.iterator() while (.hasNext()) { // BLOCK val x: Int = .next() - when { - greater(arg0 = k, arg1 = 2) -> break + { // BLOCK + when { + greater(arg0 = k, arg1 = 2) -> break + } } } } @@ -17,17 +19,21 @@ fun testBreakFor() { fun testBreakWhile() { var k: Int = 0 - while (less(arg0 = k, arg1 = 10)) when { - greater(arg0 = k, arg1 = 2) -> break + while (less(arg0 = k, arg1 = 10)) { // BLOCK + when { + greater(arg0 = k, arg1 = 2) -> break + } } } fun testBreakDoWhile() { var k: Int = 0 { // BLOCK - dowhen { + do// COMPOSITE { + when { greater(arg0 = k, arg1 = 2) -> break - } while (less(arg0 = k, arg1 = 10)) + } + // } while (less(arg0 = k, arg1 = 10)) } } @@ -41,8 +47,10 @@ fun testContinueFor() { val : IntIterator = xs.iterator() while (.hasNext()) { // BLOCK val x: Int = .next() - when { - greater(arg0 = k, arg1 = 2) -> continue + { // BLOCK + when { + greater(arg0 = k, arg1 = 2) -> continue + } } } } @@ -50,8 +58,10 @@ fun testContinueFor() { fun testContinueWhile() { var k: Int = 0 - while (less(arg0 = k, arg1 = 10)) when { - greater(arg0 = k, arg1 = 2) -> continue + while (less(arg0 = k, arg1 = 10)) { // BLOCK + when { + greater(arg0 = k, arg1 = 2) -> continue + } } } @@ -74,3 +84,4 @@ fun testContinueDoWhile() { EQEQ(arg0 = s, arg1 = "1;2;").not() -> throw AssertionError(p0 = s) } } + diff --git a/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.ir.txt b/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.ir.txt index 7c2e76f9dfe..083c58b52fa 100644 --- a/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.ir.txt @@ -159,18 +159,19 @@ FILE fqName: fileName:/exhaustiveWhenElseBranch.kt then: CONST Int type=kotlin.Int value=0 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: BLOCK type=kotlin.Int origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:.A [val] - GET_VAR 'a: .A declared in .testIfTheElseStatement_empty' type=.A origin=null - WHEN type=kotlin.Int origin=WHEN - 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: .A declared in .testIfTheElseStatement_empty' type=.A origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:V1' type=.A - then: CONST Int type=kotlin.Int value=1 - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null + then: BLOCK type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:.A [val] + GET_VAR 'a: .A declared in .testIfTheElseStatement_empty' type=.A origin=null + WHEN type=kotlin.Int origin=WHEN + 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: .A declared in .testIfTheElseStatement_empty' type=.A origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:V1' type=.A + then: CONST Int type=kotlin.Int value=1 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null FUN name:testIfTheElseParenthesized_throwsJvm visibility:public modality:FINAL <> (a:.A, flag:kotlin.Boolean) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A VALUE_PARAMETER name:flag index:1 type:kotlin.Boolean @@ -182,18 +183,19 @@ FILE fqName: fileName:/exhaustiveWhenElseBranch.kt then: CONST Int type=kotlin.Int value=0 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: BLOCK type=kotlin.Int origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:.A [val] - GET_VAR 'a: .A declared in .testIfTheElseParenthesized_throwsJvm' type=.A origin=null - WHEN type=kotlin.Int origin=WHEN - 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_6: .A declared in .testIfTheElseParenthesized_throwsJvm' type=.A origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:V1' type=.A - then: CONST Int type=kotlin.Int value=1 - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null + then: BLOCK type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:.A [val] + GET_VAR 'a: .A declared in .testIfTheElseParenthesized_throwsJvm' type=.A origin=null + WHEN type=kotlin.Int origin=WHEN + 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_6: .A declared in .testIfTheElseParenthesized_throwsJvm' type=.A origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:V1' type=.A + then: CONST Int type=kotlin.Int value=1 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null FUN name:testIfTheElseAnnotated_throwsJvm visibility:public modality:FINAL <> (a:.A, flag:kotlin.Boolean) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A VALUE_PARAMETER name:flag index:1 type:kotlin.Boolean @@ -205,18 +207,19 @@ FILE fqName: fileName:/exhaustiveWhenElseBranch.kt then: CONST Int type=kotlin.Int value=0 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: BLOCK type=kotlin.Int origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:.A [val] - GET_VAR 'a: .A declared in .testIfTheElseAnnotated_throwsJvm' type=.A origin=null - WHEN type=kotlin.Int origin=WHEN - 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_7: .A declared in .testIfTheElseAnnotated_throwsJvm' type=.A origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:V1' type=.A - then: CONST Int type=kotlin.Int value=1 - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null + then: BLOCK type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:.A [val] + GET_VAR 'a: .A declared in .testIfTheElseAnnotated_throwsJvm' type=.A origin=null + WHEN type=kotlin.Int origin=WHEN + 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_7: .A declared in .testIfTheElseAnnotated_throwsJvm' type=.A origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:V1' type=.A + then: CONST Int type=kotlin.Int value=1 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null FUN name:testLambdaResultExpression_throws visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.kt.txt b/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.kt.txt index 79807772048..579adeb7073 100644 --- a/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.kt.txt @@ -73,10 +73,12 @@ fun testIfTheElseStatement_empty(a: A, flag: Boolean) { when { flag -> 0 else -> { // BLOCK - val tmp5_subject: A = a - when { - EQEQ(arg0 = tmp5_subject, arg1 = A.V1) -> 1 - else -> noWhenBranchMatchedException() + { // BLOCK + val tmp5_subject: A = a + when { + EQEQ(arg0 = tmp5_subject, arg1 = A.V1) -> 1 + else -> noWhenBranchMatchedException() + } } } } /*~> Unit */ @@ -86,10 +88,12 @@ fun testIfTheElseParenthesized_throwsJvm(a: A, flag: Boolean) { when { flag -> 0 else -> { // BLOCK - val tmp6_subject: A = a - when { - EQEQ(arg0 = tmp6_subject, arg1 = A.V1) -> 1 - else -> noWhenBranchMatchedException() + { // BLOCK + val tmp6_subject: A = a + when { + EQEQ(arg0 = tmp6_subject, arg1 = A.V1) -> 1 + else -> noWhenBranchMatchedException() + } } } } /*~> Unit */ @@ -99,10 +103,12 @@ fun testIfTheElseAnnotated_throwsJvm(a: A, flag: Boolean) { when { flag -> 0 else -> { // BLOCK - val tmp7_subject: A = a - when { - EQEQ(arg0 = tmp7_subject, arg1 = A.V1) -> 1 - else -> noWhenBranchMatchedException() + { // BLOCK + val tmp7_subject: A = a + when { + EQEQ(arg0 = tmp7_subject, arg1 = A.V1) -> 1 + else -> noWhenBranchMatchedException() + } } } } /*~> Unit */ @@ -120,3 +126,4 @@ fun testLambdaResultExpression_throws(a: A) { } .invoke() /*~> Unit */ } + diff --git a/compiler/testData/ir/irText/expressions/for.fir.ir.txt b/compiler/testData/ir/irText/expressions/for.fir.ir.txt index dd0d86b3a47..317288ca2c4 100644 --- a/compiler/testData/ir/irText/expressions/for.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/for.fir.ir.txt @@ -13,7 +13,6 @@ FILE fqName: fileName:/for.kt VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_0: kotlin.collections.Iterator declared in .testEmpty' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Unit origin=null FUN name:testIterable visibility:public modality:FINAL <> (ss:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List BLOCK_BODY @@ -28,8 +27,9 @@ FILE fqName: fileName:/for.kt VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_1: kotlin.collections.Iterator declared in .testIterable' type=kotlin.collections.Iterator origin=null - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit declared in kotlin.io' type=kotlin.Unit origin=null - message: GET_VAR 'val s: kotlin.String declared in .testIterable' type=kotlin.String origin=null + BLOCK type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit declared in kotlin.io' type=kotlin.Unit origin=null + message: GET_VAR 'val s: kotlin.String declared in .testIterable' type=kotlin.String origin=null FUN name:testDestructuring visibility:public modality:FINAL <> (pp:kotlin.collections.List>) returnType:kotlin.Unit VALUE_PARAMETER name:pp index:0 type:kotlin.collections.List> BLOCK_BODY @@ -70,4 +70,3 @@ FILE fqName: fileName:/for.kt VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_4: kotlin.collections.IntIterator declared in .testRange' type=kotlin.collections.IntIterator origin=null - BLOCK type=kotlin.Unit origin=null diff --git a/compiler/testData/ir/irText/expressions/for.fir.kt.txt b/compiler/testData/ir/irText/expressions/for.fir.kt.txt index f0869efd75f..866d31d9226 100644 --- a/compiler/testData/ir/irText/expressions/for.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/for.fir.kt.txt @@ -3,8 +3,6 @@ fun testEmpty(ss: List) { val : Iterator = ss.iterator() while (.hasNext()) { // BLOCK val s: String = .next() - { // BLOCK - } } } } @@ -14,7 +12,9 @@ fun testIterable(ss: List) { val : Iterator = ss.iterator() while (.hasNext()) { // BLOCK val s: String = .next() - println(message = s) + { // BLOCK + println(message = s) + } } } } @@ -39,8 +39,6 @@ fun testRange() { val : IntIterator = 1.rangeTo(other = 10).iterator() while (.hasNext()) { // BLOCK val i: Int = .next() - { // BLOCK - } } } } diff --git a/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.ir.txt b/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.ir.txt index 61440440409..4eba8f4963f 100644 --- a/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.ir.txt @@ -13,7 +13,8 @@ FILE fqName: fileName:/forWithBreakContinue.kt VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_0: kotlin.collections.Iterator declared in .testForBreak1' type=kotlin.collections.Iterator origin=null - BREAK label=null loop.label=null + BLOCK type=kotlin.Unit origin=null + BREAK label=null loop.label=null FUN name:testForBreak2 visibility:public modality:FINAL <> (ss:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List BLOCK_BODY @@ -28,7 +29,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt VAR FOR_LOOP_VARIABLE name:s1 type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_1: kotlin.collections.Iterator declared in .testForBreak2' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Nothing origin=null + BLOCK type=kotlin.Unit origin=null BLOCK type=kotlin.Unit origin=FOR_LOOP VAR FOR_LOOP_ITERATOR name:tmp_2 type:kotlin.collections.Iterator [val] CALL 'public abstract fun iterator (): kotlin.collections.Iterator declared in kotlin.collections.List' type=kotlin.collections.Iterator origin=FOR_LOOP_ITERATOR @@ -40,7 +41,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt VAR FOR_LOOP_VARIABLE name:s2 type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_2: kotlin.collections.Iterator declared in .testForBreak2' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Nothing origin=null + BLOCK type=kotlin.Unit origin=null BREAK label=OUTER loop.label=OUTER BREAK label=INNER loop.label=INNER BREAK label=INNER loop.label=INNER @@ -59,7 +60,8 @@ FILE fqName: fileName:/forWithBreakContinue.kt VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator declared in .testForContinue1' type=kotlin.collections.Iterator origin=null - CONTINUE label=null loop.label=null + BLOCK type=kotlin.Unit origin=null + CONTINUE label=null loop.label=null FUN name:testForContinue2 visibility:public modality:FINAL <> (ss:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List BLOCK_BODY @@ -74,7 +76,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt VAR FOR_LOOP_VARIABLE name:s1 type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_4: kotlin.collections.Iterator declared in .testForContinue2' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Nothing origin=null + BLOCK type=kotlin.Unit origin=null BLOCK type=kotlin.Unit origin=FOR_LOOP VAR FOR_LOOP_ITERATOR name:tmp_5 type:kotlin.collections.Iterator [val] CALL 'public abstract fun iterator (): kotlin.collections.Iterator declared in kotlin.collections.List' type=kotlin.collections.Iterator origin=FOR_LOOP_ITERATOR @@ -86,7 +88,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt VAR FOR_LOOP_VARIABLE name:s2 type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator declared in .testForContinue2' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Nothing origin=null + BLOCK type=kotlin.Unit origin=null CONTINUE label=OUTER loop.label=OUTER CONTINUE label=INNER loop.label=INNER CONTINUE label=INNER loop.label=INNER diff --git a/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.kt.txt b/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.kt.txt index de10555b4bd..44b90fd6d2c 100644 --- a/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.kt.txt @@ -3,7 +3,9 @@ fun testForBreak1(ss: List) { val : Iterator = ss.iterator() while (.hasNext()) { // BLOCK val s: String = .next() - break + { // BLOCK + break + } } } } @@ -36,7 +38,9 @@ fun testForContinue1(ss: List) { val : Iterator = ss.iterator() while (.hasNext()) { // BLOCK val s: String = .next() - continue + { // BLOCK + continue + } } } } @@ -63,3 +67,4 @@ fun testForContinue2(ss: List) { } } } + diff --git a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.ir.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.ir.txt index 9d812de9f40..f278d16d4fc 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.ir.txt @@ -119,5 +119,6 @@ FILE fqName: fileName:/forWithImplicitReceivers.kt CALL 'public open fun next (): kotlin.Int declared in .IReceiver' type=kotlin.Int origin=null $this: GET_VAR ': .IReceiver declared in .test' type=.IReceiver origin=null $receiver: GET_VAR 'val tmp_1: .IntCell declared in .test' type=.IntCell origin=null - CALL 'public final fun println (message: kotlin.Int): kotlin.Unit declared in kotlin.io' type=kotlin.Unit origin=null - message: GET_VAR 'val i: kotlin.Int declared in .test' type=kotlin.Int origin=null + BLOCK type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit declared in kotlin.io' type=kotlin.Unit origin=null + message: GET_VAR 'val i: kotlin.Int declared in .test' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.kt.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.kt.txt index 713711ed6f5..2d4520661de 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.kt.txt @@ -45,7 +45,10 @@ fun IReceiver.test() { val : IntCell = (, FiveTimes).iterator() while ((, ).hasNext()) { // BLOCK val i: Int = (, ).next() - println(message = i) + { // BLOCK + println(message = i) + } } } } + diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.fir.ir.txt deleted file mode 100644 index 612d7d0b2d0..00000000000 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.fir.ir.txt +++ /dev/null @@ -1,40 +0,0 @@ -FILE fqName: fileName:/samConversionInVarargsMixed.kt - CLASS INTERFACE name:MyRunnable modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyRunnable - FUN name:run visibility:public modality:ABSTRACT <> ($this:.MyRunnable) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.MyRunnable - 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 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 <> (a:kotlin.Any, r:.MyRunnable) returnType:kotlin.Unit - VALUE_PARAMETER name:a index:0 type:kotlin.Any - VALUE_PARAMETER name:r index:1 type:.MyRunnable - BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - BRANCH - if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.MyRunnable - GET_VAR 'a: kotlin.Any declared in .test' type=kotlin.Any origin=null - then: CALL 'public final fun foo (vararg rs: .MyRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - rs: VARARG type=kotlin.Array.MyRunnable> varargElementType=.MyRunnable - TYPE_OP type=.MyRunnable origin=SAM_CONVERSION typeOperand=.MyRunnable - FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - GET_VAR 'r: .MyRunnable declared in .test' type=.MyRunnable origin=null - TYPE_OP type=.MyRunnable origin=IMPLICIT_CAST typeOperand=.MyRunnable - GET_VAR 'a: kotlin.Any declared in .test' type=kotlin.Any origin=null - FUN name:foo visibility:public modality:FINAL <> (rs:kotlin.Array.MyRunnable>) returnType:kotlin.Unit - VALUE_PARAMETER name:rs index:0 type:kotlin.Array.MyRunnable> varargElementType:.MyRunnable [vararg] - BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.fir.kt.txt deleted file mode 100644 index 4e96e4a9a78..00000000000 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.fir.kt.txt +++ /dev/null @@ -1,16 +0,0 @@ -fun interface MyRunnable { - abstract fun run() - -} - -fun test(a: Any, r: MyRunnable) { - when { - a is MyRunnable -> foo(rs = [local fun () { - return Unit - } - /*-> MyRunnable */, r, a /*as MyRunnable */]) - } -} - -fun foo(vararg rs: MyRunnable) { -} diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.kt b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.kt index 84091c2dbbc..3ec8aeda4c9 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.kt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun interface MyRunnable { fun run() } diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt index 25d6bb1249e..91bc92d0cba 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt @@ -42,9 +42,10 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.KRunnable GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null - then: CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable - GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null + r: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null FUN name:test2 visibility:public modality:FINAL <> (a:.KRunnable) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.KRunnable BLOCK_BODY @@ -61,11 +62,12 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.KRunnable GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null - then: CALL 'public final fun run2 (r1: .KRunnable, r2: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r1: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable - GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null - r2: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable - GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun run2 (r1: .KRunnable, r2: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null + r1: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null + r2: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0, b:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 VALUE_PARAMETER name:b index:1 type:kotlin.Function0 @@ -74,11 +76,12 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.KRunnable GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null - then: CALL 'public final fun run2 (r1: .KRunnable, r2: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r1: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable - GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null - r2: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - GET_VAR 'b: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun run2 (r1: .KRunnable, r2: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null + r1: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null + r2: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + GET_VAR 'b: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY @@ -86,9 +89,10 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.KRunnable GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null - then: CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable - GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null + r: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null FUN name:test5x visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt index 26d81660bf5..956c6d898e8 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt @@ -19,7 +19,9 @@ fun test0(a: T) where T : KRunnable, T : Function0 { fun test1(a: Function0) { when { - a is KRunnable -> run1(r = a /*as KRunnable */) + a is KRunnable -> { // BLOCK + run1(r = a /*as KRunnable */) + } } } @@ -30,19 +32,25 @@ fun test2(a: KRunnable) { fun test3(a: Function0) { when { - a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */) + a is KRunnable -> { // BLOCK + run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */) + } } } fun test4(a: Function0, b: Function0) { when { - a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */) + a is KRunnable -> { // BLOCK + run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */) + } } } fun test5(a: Any) { when { - a is KRunnable -> run1(r = a /*as KRunnable */) + a is KRunnable -> { // BLOCK + run1(r = a /*as KRunnable */) + } } } @@ -89,3 +97,4 @@ fun test8(a: Function0) { fun test9() { run1(r = ::test9 /*-> KRunnable */) } + diff --git a/compiler/testData/ir/irText/expressions/kt48708.fir.ir.txt b/compiler/testData/ir/irText/expressions/kt48708.fir.ir.txt deleted file mode 100644 index 6eb5ee4b6a6..00000000000 --- a/compiler/testData/ir/irText/expressions/kt48708.fir.ir.txt +++ /dev/null @@ -1,20 +0,0 @@ -FILE fqName: fileName:/kt48708.kt - FUN name:test visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.Unit - VALUE_PARAMETER name:b index:0 type:kotlin.Boolean - BLOCK_BODY - VAR name:x type:kotlin.Int [val] - WHEN type=kotlin.Int origin=IF - BRANCH - if: GET_VAR 'b: kotlin.Boolean declared in .test' type=kotlin.Boolean origin=null - then: CONST Int type=kotlin.Int value=3 - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: BLOCK type=kotlin.Int origin=null - THROW type=kotlin.Nothing - CONSTRUCTOR_CALL 'public constructor () declared in java.lang.Exception' type=java.lang.Exception origin=null - CONST Int type=kotlin.Int value=0 - CALL 'public final fun takeInt (x: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null - x: GET_VAR 'val x: kotlin.Int declared in .test' type=kotlin.Int origin=null - FUN name:takeInt visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:x index:0 type:kotlin.Int - BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/kt48708.fir.kt.txt b/compiler/testData/ir/irText/expressions/kt48708.fir.kt.txt deleted file mode 100644 index d90d76d152a..00000000000 --- a/compiler/testData/ir/irText/expressions/kt48708.fir.kt.txt +++ /dev/null @@ -1,13 +0,0 @@ -fun test(b: Boolean) { - val x: Int = when { - b -> 3 - else -> { // BLOCK - throw Exception() - 0 - } - } - takeInt(x = x) -} - -fun takeInt(x: Int) { -} diff --git a/compiler/testData/ir/irText/expressions/kt48708.kt b/compiler/testData/ir/irText/expressions/kt48708.kt index b873222931e..559e4428c17 100644 --- a/compiler/testData/ir/irText/expressions/kt48708.kt +++ b/compiler/testData/ir/irText/expressions/kt48708.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS_IR_ES6 // ISSUE: KT-48708 diff --git a/compiler/testData/ir/irText/expressions/kt50028.fir.ir.txt b/compiler/testData/ir/irText/expressions/kt50028.fir.ir.txt index 16efe35cd31..7623a2cbe78 100644 --- a/compiler/testData/ir/irText/expressions/kt50028.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/kt50028.fir.ir.txt @@ -5,8 +5,9 @@ FILE fqName: fileName:/kt50028.kt WHEN type=kotlin.Nothing origin=WHEN BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: RETURN type=kotlin.Nothing from='public final fun test_1 (): kotlin.String declared in ' - CONST String type=kotlin.String value="" + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun test_1 (): kotlin.String declared in ' + CONST String type=kotlin.String value="" FUN name:test_2 visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.Boolean VALUE_PARAMETER name:b index:0 type:kotlin.Boolean BLOCK_BODY @@ -14,8 +15,10 @@ FILE fqName: fileName:/kt50028.kt WHEN type=kotlin.Boolean origin=IF BRANCH if: GET_VAR 'b: kotlin.Boolean declared in .test_2' type=kotlin.Boolean origin=null - then: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Boolean origin=null + CONST Boolean type=kotlin.Boolean value=true BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: THROW type=kotlin.Nothing - CONSTRUCTOR_CALL 'public constructor (message: kotlin.String) declared in kotlin.NotImplementedError' type=kotlin.NotImplementedError origin=null + then: BLOCK type=kotlin.Unit origin=null + THROW type=kotlin.Nothing + CONSTRUCTOR_CALL 'public constructor (message: kotlin.String) declared in kotlin.NotImplementedError' type=kotlin.NotImplementedError origin=null diff --git a/compiler/testData/ir/irText/expressions/kt50028.fir.kt.txt b/compiler/testData/ir/irText/expressions/kt50028.fir.kt.txt index 5a8fc697c85..7658f87627c 100644 --- a/compiler/testData/ir/irText/expressions/kt50028.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/kt50028.fir.kt.txt @@ -1,12 +1,19 @@ fun test_1(): String { return when { - else -> return "" + else -> { // BLOCK + return "" + } } } fun test_2(b: Boolean): Boolean { return when { - b -> true - else -> throw NotImplementedError() + b -> { // BLOCK + true + } + else -> { // BLOCK + throw NotImplementedError() + } } } + diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.ir.txt b/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.ir.txt index 684e953e1eb..711f6eafd1f 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.ir.txt @@ -6,17 +6,18 @@ FILE fqName: fileName:/genericSamSmartcast.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.A<*> GET_VAR 'x: kotlin.Any declared in .f' type=kotlin.Any origin=null - then: RETURN type=kotlin.Nothing from='public final fun f (x: kotlin.Any): kotlin.String declared in ' - TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun call (block: @[FlexibleNullability] .A.I<@[FlexibleNullability] T of .A?>?): @[FlexibleNullability] kotlin.String? declared in .A' type=@[FlexibleNullability] kotlin.String? origin=null - $this: TYPE_OP type=.A<*> origin=IMPLICIT_CAST typeOperand=.A<*> - GET_VAR 'x: kotlin.Any declared in .f' type=kotlin.Any origin=null - block: TYPE_OP type=@[FlexibleNullability] .A.I? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] .A.I? - FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (y:kotlin.Any?) returnType:@[FlexibleNullability] kotlin.String? - VALUE_PARAMETER name:y index:0 type:kotlin.Any? - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (y: kotlin.Any?): @[FlexibleNullability] kotlin.String? declared in .f' - CONST String type=kotlin.String value="OK" + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun f (x: kotlin.Any): kotlin.String declared in ' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun call (block: @[FlexibleNullability] .A.I<@[FlexibleNullability] T of .A?>?): @[FlexibleNullability] kotlin.String? declared in .A' type=@[FlexibleNullability] kotlin.String? origin=null + $this: TYPE_OP type=.A<*> origin=IMPLICIT_CAST typeOperand=.A<*> + GET_VAR 'x: kotlin.Any declared in .f' type=kotlin.Any origin=null + block: TYPE_OP type=@[FlexibleNullability] .A.I? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] .A.I? + FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (y:kotlin.Any?) returnType:@[FlexibleNullability] kotlin.String? + VALUE_PARAMETER name:y index:0 type:kotlin.Any? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (y: kotlin.Any?): @[FlexibleNullability] kotlin.String? declared in .f' + CONST String type=kotlin.String value="OK" RETURN type=kotlin.Nothing from='public final fun f (x: kotlin.Any): kotlin.String declared in ' CONST String type=kotlin.String value="Fail" diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.kt.txt index a944a16e833..24c1db00ef8 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.kt.txt @@ -1,9 +1,12 @@ fun f(x: Any): String { when { - x is A<*> -> return x /*as A<*> */.call(block = local fun (y: Any?): @FlexibleNullability String? { - return "OK" - } + x is A<*> -> { // BLOCK + return x /*as A<*> */.call(block = local fun (y: Any?): @FlexibleNullability String? { + return "OK" + } /*-> @FlexibleNullability I? */) /*!! String */ + } } return "Fail" } + diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt index 9f99fd178cc..63b0932d477 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt @@ -6,9 +6,10 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null - then: CALL 'public open fun runStatic (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable - GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public open fun runStatic (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 BLOCK_BODY @@ -16,10 +17,11 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable GET_VAR 'a: kotlin.Function0 declared in .test2' type=kotlin.Function0 origin=null - then: CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable - GET_VAR 'a: kotlin.Function0 declared in .test2' type=kotlin.Function0 origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null + r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test2' type=kotlin.Function0 origin=null FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 BLOCK_BODY @@ -27,12 +29,13 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null - then: CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable - GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null - r2: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable - GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null + r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null + r2: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0, b:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 VALUE_PARAMETER name:b index:1 type:kotlin.Function0 @@ -41,12 +44,13 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null - then: CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable - GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null - r2: TYPE_OP type=@[FlexibleNullability] java.lang.Runnable? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.lang.Runnable? - GET_VAR 'b: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null + r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null + r2: TYPE_OP type=@[FlexibleNullability] java.lang.Runnable? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.lang.Runnable? + GET_VAR 'b: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY @@ -54,10 +58,11 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null - then: CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable - GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null + r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null FUN name:test5x visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt index 3ff8dc7041b..425f721ed07 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt @@ -1,30 +1,40 @@ fun test1(a: Function0) { when { - a is Runnable -> runStatic(r = a /*as Runnable */) + a is Runnable -> { // BLOCK + runStatic(r = a /*as Runnable */) + } } } fun test2(a: Function0) { when { - a is Runnable -> J().run1(r = a /*as Runnable */) + a is Runnable -> { // BLOCK + J().run1(r = a /*as Runnable */) + } } } fun test3(a: Function0) { when { - a is Runnable -> J().run2(r1 = a /*as Runnable */, r2 = a /*as Runnable */) + a is Runnable -> { // BLOCK + J().run2(r1 = a /*as Runnable */, r2 = a /*as Runnable */) + } } } fun test4(a: Function0, b: Function0) { when { - a is Runnable -> J().run2(r1 = a /*as Runnable */, r2 = b /*-> @FlexibleNullability Runnable? */) + a is Runnable -> { // BLOCK + J().run2(r1 = a /*as Runnable */, r2 = b /*-> @FlexibleNullability Runnable? */) + } } } fun test5(a: Any) { when { - a is Runnable -> J().run1(r = a /*as Runnable */) + a is Runnable -> { // BLOCK + J().run1(r = a /*as Runnable */) + } } } @@ -54,3 +64,4 @@ fun test8(a: Function0) { fun test9() { J().run1(r = ::test9 /*-> @FlexibleNullability Runnable? */) } + diff --git a/compiler/testData/ir/irText/expressions/throw.fir.ir.txt b/compiler/testData/ir/irText/expressions/throw.fir.ir.txt deleted file mode 100644 index 6a4041e0814..00000000000 --- a/compiler/testData/ir/irText/expressions/throw.fir.ir.txt +++ /dev/null @@ -1,15 +0,0 @@ -FILE fqName: fileName:/throw.kt - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - THROW type=kotlin.Nothing - CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Throwable' type=kotlin.Throwable origin=null - FUN name:testImplicitCast visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit - VALUE_PARAMETER name:a index:0 type:kotlin.Any - BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - BRANCH - if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Throwable - GET_VAR 'a: kotlin.Any declared in .testImplicitCast' type=kotlin.Any origin=null - then: THROW type=kotlin.Nothing - TYPE_OP type=kotlin.Throwable origin=IMPLICIT_CAST typeOperand=kotlin.Throwable - GET_VAR 'a: kotlin.Any declared in .testImplicitCast' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/throw.fir.kt.txt b/compiler/testData/ir/irText/expressions/throw.fir.kt.txt deleted file mode 100644 index 76bd6339f87..00000000000 --- a/compiler/testData/ir/irText/expressions/throw.fir.kt.txt +++ /dev/null @@ -1,9 +0,0 @@ -fun test1() { - throw Throwable() -} - -fun testImplicitCast(a: Any) { - when { - a is Throwable -> throw a /*as Throwable */ - } -} diff --git a/compiler/testData/ir/irText/expressions/throw.kt b/compiler/testData/ir/irText/expressions/throw.kt index 91011f81990..b6d974d1c0e 100644 --- a/compiler/testData/ir/irText/expressions/throw.kt +++ b/compiler/testData/ir/irText/expressions/throw.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun test1() { throw Throwable() } diff --git a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.ir.txt b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.ir.txt index 409996a573c..6127cea77cf 100644 --- a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.ir.txt @@ -82,59 +82,61 @@ FILE fqName: fileName:/whenSmartCastToEnum.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.En GET_VAR 'val x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null - then: BLOCK type=kotlin.Unit origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.En [val] - TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En - GET_VAR 'val x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null - WHEN type=kotlin.Unit origin=WHEN - 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: .En declared in .test' type=.En origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:A' type=.En - then: BLOCK type=kotlin.Unit origin=null - SET_VAR 'var r: kotlin.String declared in .test' type=kotlin.Unit origin=EQ - CONST String type=kotlin.String value="when1" - 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: .En declared in .test' type=.En origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:B' type=.En - then: BLOCK 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: .En declared in .test' type=.En origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:C' type=.En - then: BLOCK type=kotlin.Unit origin=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.En [val] + TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En + GET_VAR 'val x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=WHEN + 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: .En declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:A' type=.En + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var r: kotlin.String declared in .test' type=kotlin.Unit origin=EQ + CONST String type=kotlin.String value="when1" + 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: .En declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:B' type=.En + then: BLOCK 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: .En declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:C' type=.En + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null VAR name:y type:kotlin.Any [val] GET_ENUM 'ENUM_ENTRY name:A' type=.En WHEN type=kotlin.Unit origin=IF BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.En GET_VAR 'val y: kotlin.Any declared in .test' type=kotlin.Any origin=null - then: BLOCK type=kotlin.Unit origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.En [val] - TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En - GET_VAR 'val y: kotlin.Any declared in .test' type=kotlin.Any origin=null - WHEN type=kotlin.Unit origin=WHEN - 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: .En declared in .test' type=.En origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:A' type=.En - then: BLOCK type=kotlin.Unit origin=null - SET_VAR 'var r: kotlin.String declared in .test' type=kotlin.Unit origin=EQ - CONST String type=kotlin.String value="when2" - 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: .En declared in .test' type=.En origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:B' type=.En - then: BLOCK 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: .En declared in .test' type=.En origin=null - arg1: GET_ENUM 'ENUM_ENTRY name:C' type=.En - then: BLOCK type=kotlin.Unit origin=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.En [val] + TYPE_OP type=.En origin=IMPLICIT_CAST typeOperand=.En + GET_VAR 'val y: kotlin.Any declared in .test' type=kotlin.Any origin=null + WHEN type=kotlin.Unit origin=WHEN + 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: .En declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:A' type=.En + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var r: kotlin.String declared in .test' type=kotlin.Unit origin=EQ + CONST String type=kotlin.String value="when2" + 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: .En declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:B' type=.En + then: BLOCK 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: .En declared in .test' type=.En origin=null + arg1: GET_ENUM 'ENUM_ENTRY name:C' type=.En + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null diff --git a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.kt.txt b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.kt.txt index 5352cf38614..392b37d01b9 100644 --- a/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/whenSmartCastToEnum.fir.kt.txt @@ -25,33 +25,38 @@ fun test() { val x: Any? = En.A when { x is En -> { // BLOCK - val tmp0_subject: En = x /*as En */ - when { - EQEQ(arg0 = tmp0_subject, arg1 = En.A) -> { // BLOCK - r = "when1" + { // BLOCK + val tmp0_subject: En = x /*as En */ + when { + EQEQ(arg0 = tmp0_subject, arg1 = En.A) -> { // BLOCK + r = "when1" + } + EQEQ(arg0 = tmp0_subject, arg1 = En.B) -> { // BLOCK + } + EQEQ(arg0 = tmp0_subject, arg1 = En.C) -> { // BLOCK + } + else -> noWhenBranchMatchedException() } - EQEQ(arg0 = tmp0_subject, arg1 = En.B) -> { // BLOCK - } - EQEQ(arg0 = tmp0_subject, arg1 = En.C) -> { // BLOCK - } - else -> noWhenBranchMatchedException() } } } val y: Any = En.A when { y is En -> { // BLOCK - val tmp1_subject: En = y /*as En */ - when { - EQEQ(arg0 = tmp1_subject, arg1 = En.A) -> { // BLOCK - r = "when2" + { // BLOCK + val tmp1_subject: En = y /*as En */ + when { + EQEQ(arg0 = tmp1_subject, arg1 = En.A) -> { // BLOCK + r = "when2" + } + EQEQ(arg0 = tmp1_subject, arg1 = En.B) -> { // BLOCK + } + EQEQ(arg0 = tmp1_subject, arg1 = En.C) -> { // BLOCK + } + else -> noWhenBranchMatchedException() } - EQEQ(arg0 = tmp1_subject, arg1 = En.B) -> { // BLOCK - } - EQEQ(arg0 = tmp1_subject, arg1 = En.C) -> { // BLOCK - } - else -> noWhenBranchMatchedException() } } } } + diff --git a/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.ir.txt b/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.ir.txt index a09e200f0c9..927fd77e8fe 100644 --- a/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.ir.txt @@ -7,18 +7,19 @@ FILE fqName: fileName:/whenUnusedExpression.kt WHEN type=kotlin.Int? origin=IF BRANCH if: GET_VAR 'b: kotlin.Boolean declared in .test' type=kotlin.Boolean origin=null - then: BLOCK type=kotlin.Int? origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] - GET_VAR 'i: kotlin.Int declared in .test' type=kotlin.Int origin=null - WHEN type=kotlin.Int? origin=WHEN - 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 declared in .test' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=0 - then: CONST Int type=kotlin.Int value=1 - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CONST Null type=kotlin.Nothing? value=null + then: BLOCK type=kotlin.Int? origin=null + BLOCK type=kotlin.Int? origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + GET_VAR 'i: kotlin.Int declared in .test' type=kotlin.Int origin=null + WHEN type=kotlin.Int? origin=WHEN + 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 declared in .test' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: CONST Int type=kotlin.Int value=1 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Null type=kotlin.Nothing? value=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.kt.txt b/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.kt.txt index 30614dd0e9f..a8fab9b1d9a 100644 --- a/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.kt.txt @@ -1,12 +1,15 @@ fun test(b: Boolean, i: Int) { when { b -> { // BLOCK - val tmp0_subject: Int = i - when { - EQEQ(arg0 = tmp0_subject, arg1 = 0) -> 1 - else -> null + { // BLOCK + val tmp0_subject: Int = i + when { + EQEQ(arg0 = tmp0_subject, arg1 = 0) -> 1 + else -> null + } } } else -> null } /*~> Unit */ } + diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt index 5f9b8c16ff1..011e6184aee 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt @@ -23,16 +23,17 @@ FILE fqName: fileName:/whileDoWhile.kt condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT arg0: GET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=10 - body: BLOCK type=kotlin.Int origin=POSTFIX_INCR - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] - GET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Int origin=null - SET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Unit origin=POSTFIX_INCR - CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_1: kotlin.Int declared in .test' type=kotlin.Int origin=null - GET_VAR 'val tmp_1: kotlin.Int declared in .test' type=kotlin.Int origin=null + body: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Int origin=POSTFIX_INCR + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + GET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Int origin=null + SET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Unit origin=POSTFIX_INCR + CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_1: kotlin.Int declared in .test' type=kotlin.Int origin=null + GET_VAR 'val tmp_1: kotlin.Int declared in .test' type=kotlin.Int origin=null BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT arg0: GET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=0 @@ -50,13 +51,14 @@ FILE fqName: fileName:/whileDoWhile.kt arg1: CONST Int type=kotlin.Int value=15 BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - body: BLOCK type=kotlin.Int origin=POSTFIX_INCR - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] - GET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Int origin=null - SET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Unit origin=POSTFIX_INCR - CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_3: kotlin.Int declared in .test' type=kotlin.Int origin=null - GET_VAR 'val tmp_3: kotlin.Int declared in .test' type=kotlin.Int origin=null + body: COMPOSITE type=kotlin.Unit origin=null + BLOCK type=kotlin.Int origin=POSTFIX_INCR + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + GET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Int origin=null + SET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Unit origin=POSTFIX_INCR + CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_3: kotlin.Int declared in .test' type=kotlin.Int origin=null + GET_VAR 'val tmp_3: kotlin.Int declared in .test' type=kotlin.Int origin=null condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT arg0: GET_VAR 'var x: kotlin.Int declared in .test' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=20 @@ -75,6 +77,6 @@ FILE fqName: fileName:/whileDoWhile.kt body: BLOCK type=kotlin.Unit origin=null BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean GET_VAR 'val a: kotlin.Any? declared in .testSmartcastInCondition' type=kotlin.Any? origin=null diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt index 316a1860a0a..f03923ad4d4 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt @@ -8,9 +8,11 @@ fun test() { } while (less(arg0 = x, arg1 = 10)) { // BLOCK - val : Int = x - x = .inc() - + { // BLOCK + val : Int = x + x = .inc() + + } } { // BLOCK do// COMPOSITE { @@ -24,11 +26,13 @@ fun test() { } while (less(arg0 = x, arg1 = 15)) } { // BLOCK - do{ // BLOCK + do// COMPOSITE { + { // BLOCK val : Int = x x = .inc() - } while (less(arg0 = x, arg1 = 20)) + } + // } while (less(arg0 = x, arg1 = 20)) } } @@ -45,3 +49,4 @@ fun testSmartcastInCondition() { } } } + diff --git a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt index 95dcafafb6d..06af0eeeb78 100644 --- a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt @@ -284,7 +284,7 @@ FILE fqName: fileName:/ArrayMap.kt BRANCH if: CALL 'private final fun (): kotlin.Boolean declared in .OneElementArrayMap.iterator.' type=kotlin.Boolean origin=GET_PROPERTY $this: GET_VAR ': .OneElementArrayMap.iterator..OneElementArrayMap> declared in .OneElementArrayMap.iterator..next' type=.OneElementArrayMap.iterator..OneElementArrayMap> origin=null - then: BLOCK type=kotlin.Nothing origin=null + then: BLOCK type=kotlin.Unit origin=null CALL 'private final fun (: kotlin.Boolean): kotlin.Unit declared in .OneElementArrayMap.iterator.' type=kotlin.Unit origin=EQ $this: GET_VAR ': .OneElementArrayMap.iterator..OneElementArrayMap> declared in .OneElementArrayMap.iterator..next' type=.OneElementArrayMap.iterator..OneElementArrayMap> origin=null : CONST Boolean type=kotlin.Boolean value=false @@ -293,8 +293,9 @@ FILE fqName: fileName:/ArrayMap.kt $this: GET_VAR ': .OneElementArrayMap.OneElementArrayMap> declared in .OneElementArrayMap.iterator' type=.OneElementArrayMap.OneElementArrayMap> origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: THROW type=kotlin.Nothing - CONSTRUCTOR_CALL 'public constructor () declared in java.util.NoSuchElementException' type=java.util.NoSuchElementException origin=null + then: BLOCK type=kotlin.Unit origin=null + THROW type=kotlin.Nothing + CONSTRUCTOR_CALL 'public constructor () declared in java.util.NoSuchElementException' type=java.util.NoSuchElementException 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 declared in kotlin.collections.Iterator @@ -464,14 +465,15 @@ FILE fqName: fileName:/ArrayMap.kt arg1: CONST Null type=kotlin.Nothing? value=null then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] - CALL 'public open fun (): kotlin.Int declared in .ArrayMapImpl' type=kotlin.Int origin=GET_PROPERTY + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + CALL 'public open fun (): kotlin.Int declared in .ArrayMapImpl' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.set' type=.ArrayMapImpl.ArrayMapImpl> origin=null + CALL 'private open fun (: kotlin.Int): kotlin.Unit declared in .ArrayMapImpl' type=kotlin.Unit origin=EQ $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.set' type=.ArrayMapImpl.ArrayMapImpl> origin=null - CALL 'private open fun (: kotlin.Int): kotlin.Unit declared in .ArrayMapImpl' type=kotlin.Unit origin=EQ - $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.set' type=.ArrayMapImpl.ArrayMapImpl> origin=null - : CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_0: kotlin.Int declared in .ArrayMapImpl.set' type=kotlin.Int origin=null - GET_VAR 'val tmp_0: kotlin.Int declared in .ArrayMapImpl.set' type=kotlin.Int origin=null + : CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: kotlin.Int declared in .ArrayMapImpl.set' type=kotlin.Int origin=null + GET_VAR 'val tmp_0: kotlin.Int declared in .ArrayMapImpl.set' type=kotlin.Int origin=null CALL 'public final fun set (index: kotlin.Int, value: T of kotlin.Array): kotlin.Unit declared in kotlin.Array' type=kotlin.Unit origin=null $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.set' type=.ArrayMapImpl.ArrayMapImpl> origin=null @@ -542,15 +544,16 @@ FILE fqName: fileName:/ArrayMap.kt BLOCK_BODY BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - body: BLOCK type=kotlin.Int origin=POSTFIX_INCR - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] - CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY + body: COMPOSITE type=kotlin.Unit origin=null + BLOCK type=kotlin.Int origin=POSTFIX_INCR + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null + CALL 'private final fun (: kotlin.Int): kotlin.Unit declared in .ArrayMapImpl.iterator.' type=kotlin.Unit origin=POSTFIX_INCR $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null - CALL 'private final fun (: kotlin.Int): kotlin.Unit declared in .ArrayMapImpl.iterator.' type=kotlin.Unit origin=POSTFIX_INCR - $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null - : CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_1: kotlin.Int declared in .ArrayMapImpl.iterator..computeNext' type=kotlin.Int origin=null - GET_VAR 'val tmp_1: kotlin.Int declared in .ArrayMapImpl.iterator..computeNext' type=kotlin.Int origin=null + : CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_1: kotlin.Int declared in .ArrayMapImpl.iterator..computeNext' type=kotlin.Int origin=null + GET_VAR 'val tmp_1: kotlin.Int declared in .ArrayMapImpl.iterator..computeNext' type=kotlin.Int origin=null condition: WHEN type=kotlin.Boolean origin=ANDAND BRANCH if: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT @@ -577,18 +580,20 @@ FILE fqName: fileName:/ArrayMap.kt arg1: CALL 'public final fun (): kotlin.Int declared in kotlin.Array' type=kotlin.Int origin=GET_PROPERTY $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.iterator' type=.ArrayMapImpl.ArrayMapImpl> origin=null - then: CALL 'protected final fun done (): kotlin.Unit declared in .ArrayMapImpl.iterator.' type=kotlin.Unit origin=null - $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'protected final fun done (): kotlin.Unit declared in .ArrayMapImpl.iterator.' type=kotlin.Unit origin=null + $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'protected final fun setNext (value: T of .ArrayMapImpl): kotlin.Unit declared in .ArrayMapImpl.iterator.' type=kotlin.Unit origin=null - $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null - value: TYPE_OP type=T of .ArrayMapImpl origin=CAST typeOperand=T of .ArrayMapImpl - CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=kotlin.Any? origin=null - $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY - $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.iterator' type=.ArrayMapImpl.ArrayMapImpl> origin=null - index: CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null + then: BLOCK type=kotlin.Unit origin=null + CALL 'protected final fun setNext (value: T of .ArrayMapImpl): kotlin.Unit declared in .ArrayMapImpl.iterator.' type=kotlin.Unit origin=null + $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null + value: TYPE_OP type=T of .ArrayMapImpl origin=CAST typeOperand=T of .ArrayMapImpl + CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=kotlin.Any? origin=null + $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY + $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.iterator' type=.ArrayMapImpl.ArrayMapImpl> origin=null + index: CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null FUN FAKE_OVERRIDE name:done visibility:protected modality:FINAL <> ($this:kotlin.collections.AbstractIterator.ArrayMapImpl>) returnType:kotlin.Unit [fake_override] overridden: protected final fun done (): kotlin.Unit declared in kotlin.collections.AbstractIterator @@ -635,14 +640,15 @@ FILE fqName: fileName:/ArrayMap.kt arg1: CONST Null type=kotlin.Nothing? value=null then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] - CALL 'public open fun (): kotlin.Int declared in .ArrayMapImpl' type=kotlin.Int origin=GET_PROPERTY + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + CALL 'public open fun (): kotlin.Int declared in .ArrayMapImpl' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.remove' type=.ArrayMapImpl.ArrayMapImpl> origin=null + CALL 'private open fun (: kotlin.Int): kotlin.Unit declared in .ArrayMapImpl' type=kotlin.Unit origin=EQ $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.remove' type=.ArrayMapImpl.ArrayMapImpl> origin=null - CALL 'private open fun (: kotlin.Int): kotlin.Unit declared in .ArrayMapImpl' type=kotlin.Unit origin=EQ - $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.remove' type=.ArrayMapImpl.ArrayMapImpl> origin=null - : CALL 'public final fun dec (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_2: kotlin.Int declared in .ArrayMapImpl.remove' type=kotlin.Int origin=null - GET_VAR 'val tmp_2: kotlin.Int declared in .ArrayMapImpl.remove' type=kotlin.Int origin=null + : CALL 'public final fun dec (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_2: kotlin.Int declared in .ArrayMapImpl.remove' type=kotlin.Int origin=null + GET_VAR 'val tmp_2: kotlin.Int declared in .ArrayMapImpl.remove' type=kotlin.Int origin=null CALL 'public final fun set (index: kotlin.Int, value: T of kotlin.Array): kotlin.Unit declared in kotlin.Array' type=kotlin.Unit origin=null $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.remove' type=.ArrayMapImpl.ArrayMapImpl> origin=null diff --git a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt index 0fbfec89089..7808418ba90 100644 --- a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt @@ -132,7 +132,9 @@ internal class OneElementArrayMap : ArrayMap { .( = false) return .() } - else -> throw NoSuchElementException() + else -> { // BLOCK + throw NoSuchElementException() + } } } @@ -194,9 +196,11 @@ internal class ArrayMapImpl : ArrayMap { .ensureCapacity(index = index) when { EQEQ(arg0 = .().get(index = index), arg1 = null) -> { // BLOCK - val : Int = .() - .( = .inc()) - + { // BLOCK + val : Int = .() + .( = .inc()) + + } } /*~> Unit */ } .().set(index = index, value = value) @@ -226,18 +230,24 @@ internal class ArrayMapImpl : ArrayMap { protected override fun computeNext() { { // BLOCK - do{ // BLOCK + do// COMPOSITE { + { // BLOCK val : Int = .() .( = .inc()) - } while (when { + } + // } while (when { less(arg0 = .(), arg1 = .().()) -> EQEQ(arg0 = .().get(index = .()), arg1 = null) else -> false }) } when { - greaterOrEqual(arg0 = .(), arg1 = .().()) -> .done() - else -> .setNext(value = .().get(index = .()) as T) + greaterOrEqual(arg0 = .(), arg1 = .().()) -> { // BLOCK + .done() + } + else -> { // BLOCK + .setNext(value = .().get(index = .()) as T) + } } } @@ -250,9 +260,11 @@ internal class ArrayMapImpl : ArrayMap { fun remove(index: Int) { when { EQEQ(arg0 = .().get(index = index), arg1 = null).not() -> { // BLOCK - val : Int = .() - .( = .dec()) - + { // BLOCK + val : Int = .() + .( = .dec()) + + } } /*~> Unit */ } .().set(index = index, value = null) @@ -328,3 +340,4 @@ internal class ArrayMapImpl : ArrayMap { } } + diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.ir.txt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.ir.txt index 0c284318a73..3643f63a5dc 100644 --- a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.ir.txt @@ -187,23 +187,24 @@ FILE fqName: fileName:/DeepCopyIrTree.kt VAR name:otherTypeParameter type:.IrTypeParameter [val] CALL 'public final fun component2 (): B of kotlin.Pair declared in kotlin.Pair' type=.IrTypeParameter origin=COMPONENT_N(index=2) $this: GET_VAR 'val tmp_1: kotlin.Pair<.IrTypeParameter, .IrTypeParameter> declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=null - CALL 'public final fun mapTo (destination: C of kotlin.collections.mapTo, transform: kotlin.Function1): C of kotlin.collections.mapTo declared in kotlin.collections' type=kotlin.collections.MutableList<.IrType> origin=null - : .IrType - : .IrType - : kotlin.collections.MutableList<.IrType> - $receiver: CALL 'public abstract fun (): kotlin.collections.MutableList<.IrType> declared in .IrTypeParameter' type=kotlin.collections.MutableList<.IrType> origin=GET_PROPERTY - $this: GET_VAR 'val otherTypeParameter: .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null - destination: CALL 'public abstract fun (): kotlin.collections.MutableList<.IrType> declared in .IrTypeParameter' type=kotlin.collections.MutableList<.IrType> origin=GET_PROPERTY - $this: GET_VAR 'val thisTypeParameter: .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null - transform: FUN_EXPR type=kotlin.Function1<.IrType, .IrType> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IrType) returnType:.IrType - VALUE_PARAMETER name:it index:0 type:.IrType - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (it: .IrType): .IrType declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' - CALL 'public abstract fun remapType (type: .IrType): .IrType declared in .TypeRemapper' type=.IrType origin=null - $this: CALL 'private final fun (): .TypeRemapper declared in .DeepCopyIrTreeWithSymbols' type=.TypeRemapper origin=GET_PROPERTY - $this: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.DeepCopyIrTreeWithSymbols origin=null - type: GET_VAR 'it: .IrType declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom..' type=.IrType origin=null + BLOCK type=kotlin.collections.MutableList<.IrType> origin=null + CALL 'public final fun mapTo (destination: C of kotlin.collections.mapTo, transform: kotlin.Function1): C of kotlin.collections.mapTo declared in kotlin.collections' type=kotlin.collections.MutableList<.IrType> origin=null + : .IrType + : .IrType + : kotlin.collections.MutableList<.IrType> + $receiver: CALL 'public abstract fun (): kotlin.collections.MutableList<.IrType> declared in .IrTypeParameter' type=kotlin.collections.MutableList<.IrType> origin=GET_PROPERTY + $this: GET_VAR 'val otherTypeParameter: .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null + destination: CALL 'public abstract fun (): kotlin.collections.MutableList<.IrType> declared in .IrTypeParameter' type=kotlin.collections.MutableList<.IrType> origin=GET_PROPERTY + $this: GET_VAR 'val thisTypeParameter: .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null + transform: FUN_EXPR type=kotlin.Function1<.IrType, .IrType> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IrType) returnType:.IrType + VALUE_PARAMETER name:it index:0 type:.IrType + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .IrType): .IrType declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' + CALL 'public abstract fun remapType (type: .IrType): .IrType declared in .TypeRemapper' type=.IrType origin=null + $this: CALL 'private final fun (): .TypeRemapper declared in .DeepCopyIrTreeWithSymbols' type=.TypeRemapper origin=GET_PROPERTY + $this: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.DeepCopyIrTreeWithSymbols origin=null + type: GET_VAR 'it: .IrType declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom..' type=.IrType 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 declared in kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.kt.txt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.kt.txt index 2ddd07fcf84..66eba2cb8d0 100644 --- a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.kt.txt @@ -59,10 +59,12 @@ class DeepCopyIrTreeWithSymbols { val : Pair = .next() val thisTypeParameter: IrTypeParameter = .component1() val otherTypeParameter: IrTypeParameter = .component2() - otherTypeParameter.().mapTo>(destination = thisTypeParameter.(), transform = local fun (it: IrType): IrType { - return .().remapType(type = it) - } + { // BLOCK + otherTypeParameter.().mapTo>(destination = thisTypeParameter.(), transform = local fun (it: IrType): IrType { + return .().remapType(type = it) + } ) + } } } } diff --git a/compiler/testData/ir/irText/firProblems/Modality.fir.ir.txt b/compiler/testData/ir/irText/firProblems/Modality.fir.ir.txt deleted file mode 100644 index 0f3764319be..00000000000 --- a/compiler/testData/ir/irText/firProblems/Modality.fir.ir.txt +++ /dev/null @@ -1,168 +0,0 @@ -FILE fqName: fileName:/Modality.kt - CLASS INTERFACE name:Substitutable modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Substitutable.Substitutable> - TYPE_PARAMETER name:T index:0 variance:out superTypes:[.DeclarationDescriptorNonRoot] reified:false - 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 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 - CLASS CLASS name:ResolutionPart modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ResolutionPart - CONSTRUCTOR visibility:public <> () returnType:.ResolutionPart [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ResolutionPart modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' - FUN name:process visibility:public modality:ABSTRACT <> ($this:.ResolutionPart, $receiver:.KotlinResolutionCandidate) returnType:kotlin.String - $this: VALUE_PARAMETER name: type:.ResolutionPart - $receiver: VALUE_PARAMETER name: type:.KotlinResolutionCandidate - 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 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 - CLASS CLASS name:KotlinResolutionCandidate modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KotlinResolutionCandidate - CONSTRUCTOR visibility:public <> (resolvedCall:.Atom) returnType:.KotlinResolutionCandidate [primary] - VALUE_PARAMETER name:resolvedCall index:0 type:.Atom - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:KotlinResolutionCandidate modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:resolvedCall visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:resolvedCall type:.Atom visibility:private [final] - EXPRESSION_BODY - GET_VAR 'resolvedCall: .Atom declared in .KotlinResolutionCandidate.' type=.Atom origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.KotlinResolutionCandidate) returnType:.Atom - correspondingProperty: PROPERTY name:resolvedCall visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.KotlinResolutionCandidate - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .Atom declared in .KotlinResolutionCandidate' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resolvedCall type:.Atom visibility:private [final]' type=.Atom origin=null - receiver: GET_VAR ': .KotlinResolutionCandidate declared in .KotlinResolutionCandidate.' type=.KotlinResolutionCandidate 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 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 - CLASS CLASS name:Atom modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Atom - CONSTRUCTOR visibility:public <> (candidateDescriptor:.CallableDescriptor) returnType:.Atom [primary] - VALUE_PARAMETER name:candidateDescriptor index:0 type:.CallableDescriptor - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Atom modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:candidateDescriptor visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:candidateDescriptor type:.CallableDescriptor visibility:private [final] - EXPRESSION_BODY - GET_VAR 'candidateDescriptor: .CallableDescriptor declared in .Atom.' type=.CallableDescriptor origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Atom) returnType:.CallableDescriptor - correspondingProperty: PROPERTY name:candidateDescriptor visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Atom - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .CallableDescriptor declared in .Atom' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:candidateDescriptor type:.CallableDescriptor visibility:private [final]' type=.CallableDescriptor origin=null - receiver: GET_VAR ': .Atom declared in .Atom.' type=.Atom 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 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 - CLASS OBJECT name:Owner modality:FINAL visibility:public superTypes:[.ResolutionPart] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Owner - CONSTRUCTOR visibility:private <> () returnType:.Owner [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .ResolutionPart' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Owner modality:FINAL visibility:public superTypes:[.ResolutionPart]' - FUN name:process visibility:public modality:OPEN <> ($this:.Owner, $receiver:.KotlinResolutionCandidate) returnType:kotlin.String - overridden: - public abstract fun process (): kotlin.String declared in .ResolutionPart - $this: VALUE_PARAMETER name: type:.Owner - $receiver: VALUE_PARAMETER name: type:.KotlinResolutionCandidate - BLOCK_BODY - VAR name:candidateDescriptor type:.CallableDescriptor [val] - CALL 'public final fun (): .CallableDescriptor declared in .Atom' type=.CallableDescriptor origin=GET_PROPERTY - $this: CALL 'public final fun (): .Atom declared in .KotlinResolutionCandidate' type=.Atom origin=GET_PROPERTY - $this: GET_VAR ': .KotlinResolutionCandidate declared in .Owner.process' type=.KotlinResolutionCandidate origin=null - WHEN type=kotlin.Unit origin=IF - BRANCH - if: WHEN type=kotlin.Boolean origin=ANDAND - BRANCH - if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.MemberDescriptor - GET_VAR 'val candidateDescriptor: .CallableDescriptor declared in .Owner.process' type=.CallableDescriptor origin=null - then: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ - $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL 'public abstract fun getModality (): @[FlexibleNullability] .Modality? declared in .MemberDescriptor' type=@[FlexibleNullability] .Modality? origin=GET_PROPERTY - $this: TYPE_OP type=.MemberDescriptor origin=IMPLICIT_CAST typeOperand=.MemberDescriptor - GET_VAR 'val candidateDescriptor: .CallableDescriptor declared in .Owner.process' type=.CallableDescriptor origin=null - arg1: CONST Null type=kotlin.Nothing? value=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CONST Boolean type=kotlin.Boolean value=false - then: RETURN type=kotlin.Nothing from='public open fun process (): kotlin.String declared in .Owner' - CONST String type=kotlin.String value="OK" - RETURN type=kotlin.Nothing from='public open fun process (): kotlin.String declared in .Owner' - CONST String type=kotlin.String value="FAIL" - 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 declared in .ResolutionPart - $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 .ResolutionPart - $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 .ResolutionPart - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS OBJECT name:Final modality:FINAL visibility:public superTypes:[.Modality] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Final - CONSTRUCTOR visibility:private <> () returnType:.Final [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Final modality:FINAL visibility:public superTypes:[.Modality]' - 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 declared in .Modality - $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 .Modality - $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 .Modality - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt b/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt deleted file mode 100644 index ff8d5231e28..00000000000 --- a/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt +++ /dev/null @@ -1,69 +0,0 @@ -interface Substitutable { - -} - -abstract class ResolutionPart { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - abstract fun KotlinResolutionCandidate.process(): String - -} - -class KotlinResolutionCandidate { - constructor(resolvedCall: Atom) /* primary */ { - super/*Any*/() - /* () */ - - } - - val resolvedCall: Atom - field = resolvedCall - get - -} - -class Atom { - constructor(candidateDescriptor: CallableDescriptor) /* primary */ { - super/*Any*/() - /* () */ - - } - - val candidateDescriptor: CallableDescriptor - field = candidateDescriptor - get - -} - -object Owner : ResolutionPart { - private constructor() /* primary */ { - super/*ResolutionPart*/() - /* () */ - - } - - override fun KotlinResolutionCandidate.process(): String { - val candidateDescriptor: CallableDescriptor = .().() - when { - when { - candidateDescriptor is MemberDescriptor -> EQEQ(arg0 = candidateDescriptor /*as MemberDescriptor */.getModality(), arg1 = null).not() - else -> false - } -> return "OK" - } - return "FAIL" - } - -} - -object Final : Modality { - private constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} diff --git a/compiler/testData/ir/irText/firProblems/Modality.kt b/compiler/testData/ir/irText/firProblems/Modality.kt index ce386c20b3a..bf0d95a17c8 100644 --- a/compiler/testData/ir/irText/firProblems/Modality.kt +++ b/compiler/testData/ir/irText/firProblems/Modality.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // TARGET_BACKEND: JVM // FILE: Modality.java public interface Modality diff --git a/compiler/testData/ir/irText/firProblems/OutBox.fir.ir.txt b/compiler/testData/ir/irText/firProblems/OutBox.fir.ir.txt index 03ce68c43db..36e05e4ff7f 100644 --- a/compiler/testData/ir/irText/firProblems/OutBox.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/OutBox.fir.ir.txt @@ -30,11 +30,12 @@ FILE fqName: fileName:/Box.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.Foo.Buz GET_VAR 'var foo: .Foo declared in .Box.' type=.Foo origin=null - then: RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Box' - TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:str type:@[FlexibleNullability] kotlin.String? visibility:public' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY - receiver: TYPE_OP type=.Foo.Buz origin=IMPLICIT_CAST typeOperand=.Foo.Buz - GET_VAR 'var foo: .Foo declared in .Box.' type=.Foo origin=null + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Box' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:str type:@[FlexibleNullability] kotlin.String? visibility:public' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY + receiver: TYPE_OP type=.Foo.Buz origin=IMPLICIT_CAST typeOperand=.Foo.Buz + GET_VAR 'var foo: .Foo declared in .Box.' type=.Foo origin=null RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Box' CONST String type=kotlin.String value="" 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/firProblems/OutBox.fir.kt.txt b/compiler/testData/ir/irText/firProblems/OutBox.fir.kt.txt index 1170e902447..94902b131f3 100644 --- a/compiler/testData/ir/irText/firProblems/OutBox.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/OutBox.fir.kt.txt @@ -13,9 +13,12 @@ class Box { get(): String { var foo: Foo = .() when { - foo is Buz -> return foo /*as Buz */.#str /*!! String */ + foo is Buz -> { // BLOCK + return foo /*as Buz */.#str /*!! String */ + } } return "" } } + diff --git a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.ir.txt b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.ir.txt deleted file mode 100644 index 0634d6c4d46..00000000000 --- a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.ir.txt +++ /dev/null @@ -1,50 +0,0 @@ -FILE fqName: fileName:/reflectGetOnNullableTypeAlias.kt - TYPEALIAS name:PropAlias visibility:private expandedType:kotlin.reflect.KProperty1.PropAlias, kotlin.Any?>? - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - VAR name:backRefProp type:kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? [val] - PROPERTY_REFERENCE 'public final bar: kotlin.String' field=null getter='public final fun (): kotlin.String declared in .Foo' setter=null type=kotlin.reflect.KProperty1<.Foo, kotlin.String> origin=null - WHEN type=kotlin.Unit origin=IF - BRANCH - if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ - $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ - arg0: GET_VAR 'val backRefProp: kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? declared in .box' type=kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? origin=null - arg1: CONST Null type=kotlin.Nothing? value=null - then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' - TYPE_OP type=kotlin.String origin=CAST typeOperand=kotlin.String - CALL 'public abstract fun get (receiver: T of kotlin.reflect.KProperty1): V of kotlin.reflect.KProperty1 declared in kotlin.reflect.KProperty1' type=kotlin.Any? origin=null - $this: GET_VAR 'val backRefProp: kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? declared in .box' type=kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? origin=null - receiver: CONSTRUCTOR_CALL 'public constructor () declared in .Foo' type=.Foo origin=null - RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' - CONST String type=kotlin.String value="FAIL" - CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Foo - CONSTRUCTOR visibility:public <> () returnType:.Foo [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:bar visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.String visibility:private [final] - EXPRESSION_BODY - CONST String type=kotlin.String value="OK" - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Foo) returnType:kotlin.String - correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Foo - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Foo' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .Foo declared in .Foo.' type=.Foo 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 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/firProblems/reflectGetOnNullableTypeAlias.fir.kt.txt b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.kt.txt deleted file mode 100644 index 43fead4121b..00000000000 --- a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.kt.txt +++ /dev/null @@ -1,21 +0,0 @@ -private typealias PropAlias = KProperty1? -fun box(): String { - val backRefProp: KProperty1? = Foo::bar - when { - EQEQ(arg0 = backRefProp, arg1 = null).not() -> return backRefProp.get(receiver = Foo()) as String - } - return "FAIL" -} - -class Foo { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - val bar: String - field = "OK" - get - -} diff --git a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt index 302b9de77bb..5e62091ffae 100644 --- a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt +++ b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // SKIP_KLIB_TEST // WITH_REFLECT diff --git a/compiler/testData/ir/irText/regressions/coercionInLoop.fir.ir.txt b/compiler/testData/ir/irText/regressions/coercionInLoop.fir.ir.txt index 3b684fbe4ec..5154619f5e6 100644 --- a/compiler/testData/ir/irText/regressions/coercionInLoop.fir.ir.txt +++ b/compiler/testData/ir/irText/regressions/coercionInLoop.fir.ir.txt @@ -12,7 +12,7 @@ FILE fqName: fileName:/coercionInLoop.kt WHILE label=null origin=WHILE_LOOP condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.DoubleIterator' type=kotlin.Boolean origin=null $this: GET_VAR 'val x: kotlin.collections.DoubleIterator declared in .box' type=kotlin.collections.DoubleIterator origin=null - body: BLOCK type=kotlin.Int origin=null + body: BLOCK type=kotlin.Unit origin=null WHEN type=kotlin.Unit origin=IF BRANCH if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ diff --git a/compiler/testData/ir/irText/regressions/kt24114.fir.ir.txt b/compiler/testData/ir/irText/regressions/kt24114.fir.ir.txt index 3b919e4eb2f..a608644a446 100644 --- a/compiler/testData/ir/irText/regressions/kt24114.fir.ir.txt +++ b/compiler/testData/ir/irText/regressions/kt24114.fir.ir.txt @@ -11,51 +11,54 @@ FILE fqName: fileName:/kt24114.kt BLOCK_BODY WHILE label=null origin=WHILE_LOOP condition: CONST Boolean type=kotlin.Boolean value=true - body: BLOCK type=kotlin.Unit origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] - CALL 'public final fun one (): kotlin.Int declared in ' type=kotlin.Int origin=null - WHEN type=kotlin.Unit origin=WHEN - 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 declared in .test1' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=1 - then: BLOCK type=kotlin.Unit origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] - CALL 'public final fun two (): kotlin.Int declared in ' type=kotlin.Int origin=null - WHEN type=kotlin.Unit origin=WHEN - 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.Int declared in .test1' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=2 - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=3 + body: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + CALL 'public final fun one (): kotlin.Int declared in ' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + 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 declared in .test1' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CALL 'public final fun two (): kotlin.Int declared in ' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + 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.Int declared in .test1' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=2 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=3 FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY WHILE label=null origin=WHILE_LOOP condition: CONST Boolean type=kotlin.Boolean value=true - body: BLOCK type=kotlin.Unit origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] - CALL 'public final fun one (): kotlin.Int declared in ' type=kotlin.Int origin=null - WHEN type=kotlin.Unit origin=WHEN - 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.Int declared in .test2' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=1 - then: BLOCK type=kotlin.Unit origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] - CALL 'public final fun two (): kotlin.Int declared in ' type=kotlin.Int origin=null - WHEN type=kotlin.Unit origin=WHEN - 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.Int declared in .test2' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=2 - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Int declared in ' - CONST Int type=kotlin.Int value=3 + body: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + CALL 'public final fun one (): kotlin.Int declared in ' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + 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.Int declared in .test2' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + CALL 'public final fun two (): kotlin.Int declared in ' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + 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.Int declared in .test2' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=2 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=3 diff --git a/compiler/testData/ir/irText/regressions/kt24114.fir.kt.txt b/compiler/testData/ir/irText/regressions/kt24114.fir.kt.txt index ea17afbee5a..bfa4f4bd859 100644 --- a/compiler/testData/ir/irText/regressions/kt24114.fir.kt.txt +++ b/compiler/testData/ir/irText/regressions/kt24114.fir.kt.txt @@ -8,30 +8,37 @@ fun two(): Int { fun test1(): Int { while (true) { // BLOCK - val tmp0_subject: Int = one() - when { - EQEQ(arg0 = tmp0_subject, arg1 = 1) -> { // BLOCK - val tmp1_subject: Int = two() - when { - EQEQ(arg0 = tmp1_subject, arg1 = 2) -> return 2 + { // BLOCK + val tmp0_subject: Int = one() + when { + EQEQ(arg0 = tmp0_subject, arg1 = 1) -> { // BLOCK + { // BLOCK + val tmp1_subject: Int = two() + when { + EQEQ(arg0 = tmp1_subject, arg1 = 2) -> return 2 + } + } } + else -> return 3 } - else -> return 3 } } } fun test2(): Int { while (true) { // BLOCK - val tmp2_subject: Int = one() - when { - EQEQ(arg0 = tmp2_subject, arg1 = 1) -> { // BLOCK - val tmp3_subject: Int = two() - when { - EQEQ(arg0 = tmp3_subject, arg1 = 2) -> return 2 + { // BLOCK + val tmp2_subject: Int = one() + when { + EQEQ(arg0 = tmp2_subject, arg1 = 1) -> { // BLOCK + val tmp3_subject: Int = two() + when { + EQEQ(arg0 = tmp3_subject, arg1 = 2) -> return 2 + } } + else -> return 3 } - else -> return 3 } } } +