diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt index 83b93eea5b3..56f57ba0154 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt @@ -157,7 +157,7 @@ class Fir2IrImplicitCastInserter( override fun visitDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: IrElement): IrElement { val loop = data as IrDoWhileLoop (loop.body as? IrContainerExpression)?.let { - loop.body = it.insertImplicitCasts() + loop.body = it.insertImplicitCasts(coerceLastExpressionToUnit = true) } return data } @@ -165,7 +165,7 @@ class Fir2IrImplicitCastInserter( override fun visitWhileLoop(whileLoop: FirWhileLoop, data: IrElement): IrElement { val loop = data as IrWhileLoop (loop.body as? IrContainerExpression)?.let { - loop.body = it.insertImplicitCasts() + loop.body = it.insertImplicitCasts(coerceLastExpressionToUnit = true) } return data } @@ -339,7 +339,7 @@ class Fir2IrImplicitCastInserter( ) } - private fun coerceToUnitIfNeeded(original: IrExpression, irBuiltIns: IrBuiltIns): IrExpression { + internal fun coerceToUnitIfNeeded(original: IrExpression, irBuiltIns: IrBuiltIns): IrExpression { val valueType = original.type return if (valueType.isUnit() || valueType.isNothing()) original 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 52aa2fd7f6f..dd6cb1837fb 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 @@ -45,6 +45,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.IrErrorClassImpl import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl +import org.jetbrains.kotlin.ir.util.coerceToUnit import org.jetbrains.kotlin.ir.util.constructors import org.jetbrains.kotlin.ir.util.defaultConstructor import org.jetbrains.kotlin.lexer.KtTokens @@ -1295,7 +1296,10 @@ class Fir2IrVisitor( loopMap[doWhileLoop] = this label = doWhileLoop.label?.name body = runUnless(doWhileLoop.block is FirEmptyExpressionBlock) { - doWhileLoop.block.convertToIrExpressionOrBlock(origin) + Fir2IrImplicitCastInserter.coerceToUnitIfNeeded( + doWhileLoop.block.convertToIrExpressionOrBlock(origin), + irBuiltIns + ) } condition = convertToIrExpression(doWhileLoop.condition) loopMap.remove(doWhileLoop) @@ -1360,7 +1364,10 @@ class Fir2IrVisitor( ) } } else { - firLoopBody.convertToIrExpressionOrBlock(origin) + Fir2IrImplicitCastInserter.coerceToUnitIfNeeded( + firLoopBody.convertToIrExpressionOrBlock(origin), + irBuiltIns + ) } } 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 46216174670..912b12f7a6b 100644 --- a/compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.fir.ir.txt +++ b/compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.fir.ir.txt @@ -84,13 +84,14 @@ 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 - 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 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + 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/expressions/breakContinueInLoopHeader.fir.ir.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt index 0472dbeec7f..7c94afa773e 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt @@ -111,11 +111,12 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt BLOCK type=kotlin.Unit origin=null DO_WHILE label=Inner origin=DO_WHILE_LOOP 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 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + 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 75420e322d0..7503d0f8b85 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt @@ -69,7 +69,7 @@ fun test5() { { // BLOCK j = j.inc() j - } + } /*~> Unit */ // } while (when { greaterOrEqual(arg0 = j, arg1 = 3) -> false else -> break@Inner diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt index b52ce387718..f8a166dadbf 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt @@ -11,25 +11,27 @@ 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=5 - body: BLOCK type=kotlin.Int origin=POSTFIX_INCR - VAR IR_TEMPORARY_VARIABLE name:tmp_0 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_0: kotlin.Int declared in .test' type=kotlin.Int origin=null - GET_VAR 'val tmp_0: kotlin.Int declared in .test' type=kotlin.Int origin=null + body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + BLOCK type=kotlin.Int origin=POSTFIX_INCR + VAR IR_TEMPORARY_VARIABLE name:tmp_0 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_0: kotlin.Int declared in .test' type=kotlin.Int origin=null + GET_VAR 'val tmp_0: kotlin.Int declared in .test' type=kotlin.Int origin=null WHILE label=null origin=WHILE_LOOP 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.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 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + 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 condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT @@ -43,26 +45,28 @@ FILE fqName: fileName:/whileDoWhile.kt arg1: CONST Int type=kotlin.Int value=7 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_2 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_2: kotlin.Int declared in .test' type=kotlin.Int origin=null - GET_VAR 'val tmp_2: kotlin.Int declared in .test' type=kotlin.Int origin=null + body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + BLOCK type=kotlin.Int origin=POSTFIX_INCR + VAR IR_TEMPORARY_VARIABLE name:tmp_2 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_2: kotlin.Int declared in .test' type=kotlin.Int origin=null + GET_VAR 'val tmp_2: 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=15 BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP 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 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + 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 diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt index e54a49e9050..754b310c572 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt @@ -5,13 +5,13 @@ fun test() { val tmp_0: Int = x x = tmp_0.inc() tmp_0 - } + } /*~> Unit */ while (less(arg0 = x, arg1 = 10)) { // BLOCK { // BLOCK val tmp_1: Int = x x = tmp_1.inc() tmp_1 - } + } /*~> Unit */ } { // BLOCK do while (less(arg0 = x, arg1 = 0)) @@ -25,7 +25,7 @@ fun test() { val tmp_2: Int = x x = tmp_2.inc() tmp_2 - } while (less(arg0 = x, arg1 = 15)) + } /*~> Unit */ while (less(arg0 = x, arg1 = 15)) } { // BLOCK do// COMPOSITE { @@ -33,7 +33,7 @@ fun test() { val tmp_3: Int = x x = tmp_3.inc() tmp_3 - } + } /*~> Unit */ // } while (less(arg0 = x, arg1 = 20)) } } diff --git a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt index 06af0eeeb78..786ad03444a 100644 --- a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt @@ -545,15 +545,16 @@ FILE fqName: fileName:/ArrayMap.kt BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP 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 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + 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 diff --git a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt index 82c55d12e13..a706e8c60a8 100644 --- a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt @@ -235,7 +235,7 @@ internal class ArrayMapImpl : ArrayMap { val tmp_1: Int = .() .( = tmp_1.inc()) tmp_1 - } + } /*~> Unit */ // } while (when { less(arg0 = .(), arg1 = .().()) -> EQEQ(arg0 = .().get(index = .()), arg1 = null) else -> false diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.ir.txt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.ir.txt index 3643f63a5dc..f7b6420adbe 100644 --- a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.ir.txt @@ -187,24 +187,25 @@ 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 - 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 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + 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 e7d784c9c07..8e87b413755 100644 --- a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.kt.txt @@ -64,7 +64,7 @@ class DeepCopyIrTreeWithSymbols { return .().remapType(type = it) } ) - } + } /*~> Unit */ } } } diff --git a/compiler/testData/ir/irText/regressions/coercionInLoop.fir.ir.txt b/compiler/testData/ir/irText/regressions/coercionInLoop.fir.ir.txt index 5154619f5e6..abc83805d5e 100644 --- a/compiler/testData/ir/irText/regressions/coercionInLoop.fir.ir.txt +++ b/compiler/testData/ir/irText/regressions/coercionInLoop.fir.ir.txt @@ -26,12 +26,13 @@ FILE fqName: fileName:/coercionInLoop.kt STRING_CONCATENATION type=kotlin.String CONST String type=kotlin.String value="Fail " GET_VAR 'var i: kotlin.Int declared in .box' type=kotlin.Int origin=null - BLOCK type=kotlin.Int origin=POSTFIX_INCR - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] - GET_VAR 'var i: kotlin.Int declared in .box' type=kotlin.Int origin=null - SET_VAR 'var i: kotlin.Int declared in .box' 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_0: kotlin.Int declared in .box' type=kotlin.Int origin=null - GET_VAR 'val tmp_0: kotlin.Int declared in .box' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + BLOCK type=kotlin.Int origin=POSTFIX_INCR + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + GET_VAR 'var i: kotlin.Int declared in .box' type=kotlin.Int origin=null + SET_VAR 'var i: kotlin.Int declared in .box' 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_0: kotlin.Int declared in .box' type=kotlin.Int origin=null + GET_VAR 'val tmp_0: kotlin.Int declared in .box' type=kotlin.Int origin=null RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/ir/irText/regressions/coercionInLoop.fir.kt.txt b/compiler/testData/ir/irText/regressions/coercionInLoop.fir.kt.txt index 704c147c204..f66e62099da 100644 --- a/compiler/testData/ir/irText/regressions/coercionInLoop.fir.kt.txt +++ b/compiler/testData/ir/irText/regressions/coercionInLoop.fir.kt.txt @@ -10,7 +10,7 @@ fun box(): String { val tmp_0: Int = i i = tmp_0.inc() tmp_0 - } + } /*~> Unit */ } return "OK" }