diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index c9a6d1385bc..fe289407c75 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -599,7 +599,10 @@ class ExpressionCodegen( SwitchGenerator(expression, data, this).generate()?.let { return it } val endLabel = Label() - val exhaustive = expression.branches.any { it.condition.isTrueConst() } + val exhaustive = expression.branches.any { it.condition.isTrueConst() } && !expression.type.isUnit() + assert(exhaustive || expression.type.isUnit()) { + "non-exhaustive conditional should return Unit: ${expression.dump()}" + } for (branch in expression.branches) { val elseLabel = Label() if (branch.condition.isFalseConst() || branch.condition.isTrueConst()) { @@ -614,26 +617,21 @@ class ExpressionCodegen( } else { branch.condition.accept(this, data).coerceToBoolean().jumpIfFalse(elseLabel) } - val result = branch.result.accept(this, data).coerce(expression.type).materialized + val result = branch.result.accept(this, data) if (!exhaustive) { result.discard() - } else if (branch.condition.isTrueConst()) { - // The rest of the expression is dead code. - mv.mark(endLabel) - return result + } else { + val materializedResult = result.coerce(expression.type).materialized + if (branch.condition.isTrueConst()) { + // The rest of the expression is dead code. + mv.mark(endLabel) + return materializedResult + } } mv.goTo(endLabel) mv.mark(elseLabel) } mv.mark(endLabel) - // NOTE: using a non-exhaustive if/when as an expression is invalid, so it should theoretically - // always return Unit. However, with the current frontend this is not always the case. - // Most notably, 1. when all branches return/break/continue, the type is Nothing; - // 2. the frontend may sometimes infer Any instead of Unit, probably due to a bug - // (see compiler/testData/codegen/box/controlStructures/ifIncompatibleBranches.kt). - // It should still be safe to produce a soon-to-be-discarded Unit. (What is not ok is - // inserting *any* code here, though, as its line number will be that of the last line - // of the last branch.) return immaterialUnitValue } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt index d80fca3b353..10288c9999e 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.psi2ir.generators -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.builders.buildStatement import org.jetbrains.kotlin.ir.builders.irIfThenMaybeElse @@ -38,8 +37,6 @@ import org.jetbrains.kotlin.utils.SmartList class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) { fun generateIfExpression(expression: KtIfExpression): IrExpression { - val resultType = getInferredTypeWithImplicitCastsOrFail(expression).toIrType() - var ktLastIf: KtIfExpression = expression val irBranches = SmartList() var irElseBranch: IrExpression? = null @@ -61,7 +58,7 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta } } - return createIrWhen(expression, irBranches, irElseBranch, resultType) + return createIrWhen(expression, irBranches, irElseBranch, getExpressionTypeWithCoercionToUnitOrFail(expression).toIrType()) } private fun generateEmptyBlockForMissingBranch(ktLastIf: KtIfExpression) = @@ -100,16 +97,10 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta fun generateWhenExpression(expression: KtWhenExpression): IrExpression { val irSubject = generateWhenSubject(expression) - val inferredType = getInferredTypeWithImplicitCastsOrFail(expression) - - val resultType = when { - // Non-exhaustive when can only be used as statement. - expression.isExhaustiveWhen() -> inferredType.toIrType() - KotlinBuiltIns.isNothing(inferredType) -> inferredType.toIrType() - else -> context.irBuiltIns.unitType - } - - val irWhen = IrWhenImpl(expression.startOffsetSkippingComments, expression.endOffset, resultType, IrStatementOrigin.WHEN) + val irWhen = IrWhenImpl( + expression.startOffsetSkippingComments, expression.endOffset, + getExpressionTypeWithCoercionToUnitOrFail(expression).toIrType(), IrStatementOrigin.WHEN + ) for (ktEntry in expression.entries) { if (ktEntry.isElse) { @@ -170,12 +161,22 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta private fun generateWhenBody(expression: KtWhenExpression, irSubject: IrVariable?, irWhen: IrWhen): IrExpression = if (irSubject == null) { if (irWhen.branches.isEmpty()) - IrBlockImpl(expression.startOffsetSkippingComments, expression.endOffset, context.irBuiltIns.unitType, IrStatementOrigin.WHEN) + IrBlockImpl( + expression.startOffsetSkippingComments, + expression.endOffset, + context.irBuiltIns.unitType, + IrStatementOrigin.WHEN + ) else irWhen } else { if (irWhen.branches.isEmpty()) { - val irBlock = IrBlockImpl(expression.startOffsetSkippingComments, expression.endOffset, context.irBuiltIns.unitType, IrStatementOrigin.WHEN) + val irBlock = IrBlockImpl( + expression.startOffsetSkippingComments, + expression.endOffset, + context.irBuiltIns.unitType, + IrStatementOrigin.WHEN + ) irBlock.statements.add(irSubject) irBlock } else { @@ -253,4 +254,4 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta context.bindingContext[BindingContext.PRIMITIVE_NUMERIC_COMPARISON_INFO, ktExpression] ) } -} \ No newline at end of file +} diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt index b06f73bc49f..de242280a8d 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt @@ -173,7 +173,7 @@ class ClassGenerator( delegatedMembers: List ) { val ktDelegateExpression = ktEntry.delegateExpression!! - val delegateType = getInferredTypeWithImplicitCastsOrFail(ktDelegateExpression) + val delegateType = getTypeInferredByFrontendOrFail(ktDelegateExpression) val superType = getOrFail(BindingContext.TYPE, ktEntry.typeReference!!) val superTypeConstructorDescriptor = superType.constructor.declarationDescriptor val superClass = superTypeConstructorDescriptor as? ClassDescriptor diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DelegatedPropertyGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DelegatedPropertyGenerator.kt index 35b4d4337ad..ad6e22bcb78 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DelegatedPropertyGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DelegatedPropertyGenerator.kt @@ -306,7 +306,7 @@ class DelegatedPropertyGenerator(declarationGenerator: DeclarationGenerator) : D return if (provideDelegateResolvedCall != null) provideDelegateResolvedCall.resultingDescriptor.returnType!! else - getInferredTypeWithImplicitCastsOrFail(ktDelegate.expression!!) + getTypeInferredByFrontendOrFail(ktDelegate.expression!!) } private fun generateInitializerForLocalDelegatedPropertyDelegate( diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ErrorExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ErrorExpressionGenerator.kt index 9ebd63d4307..4b405e91ad5 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ErrorExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ErrorExpressionGenerator.kt @@ -66,7 +66,7 @@ class ErrorExpressionGenerator(statementGenerator: StatementGenerator) : Stateme } private fun getErrorExpressionType(ktExpression: KtExpression) = - getInferredTypeWithImplicitCasts(ktExpression) ?: ErrorUtils.createErrorType("") + getTypeInferredByFrontend(ktExpression) ?: ErrorUtils.createErrorType("") fun generateErrorSimpleName(ktName: KtSimpleNameExpression): IrExpression = generateErrorExpression(ktName) { val type = getErrorExpressionType(ktName).toIrType() diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt index cfd541d0b4d..bd89e336a27 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.ir.builders.IrGenerator import org.jetbrains.kotlin.ir.builders.IrGeneratorWithScope import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.types.KotlinType @@ -44,11 +45,20 @@ fun Generator.getOrFail(slice: ReadOnlySlice, key: K): V = inline fun Generator.getOrFail(slice: ReadOnlySlice, key: K, message: (K) -> String): V = context.bindingContext[slice, key] ?: throw RuntimeException(message(key)) -fun Generator.getInferredTypeWithImplicitCasts(key: KtExpression): KotlinType? = +fun Generator.getTypeInferredByFrontend(key: KtExpression): KotlinType? = context.bindingContext.getType(key) -fun Generator.getInferredTypeWithImplicitCastsOrFail(key: KtExpression): KotlinType = - getInferredTypeWithImplicitCasts(key) ?: throw RuntimeException("No type for expression: ${key.text}") +fun Generator.getTypeInferredByFrontendOrFail(key: KtExpression): KotlinType = + getTypeInferredByFrontend(key) ?: throw RuntimeException("No type for expression: ${key.text}") + +fun Generator.getExpressionTypeWithCoercionToUnit(key: KtExpression): KotlinType? = + if (key.isUsedAsExpression(context.bindingContext)) + getTypeInferredByFrontend(key) + else + context.builtIns.unitType + +fun Generator.getExpressionTypeWithCoercionToUnitOrFail(key: KtExpression): KotlinType = + getExpressionTypeWithCoercionToUnit(key) ?: throw RuntimeException("No type for expression: ${key.text}") fun Generator.getResolvedCall(key: KtElement): ResolvedCall? = key.getResolvedCall(context.bindingContext) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalClassGenerator.kt index d52f76cb145..0782ad3e755 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalClassGenerator.kt @@ -29,7 +29,7 @@ class LocalClassGenerator(statementGenerator: StatementGenerator) : StatementGen fun generateObjectLiteral(ktObjectLiteral: KtObjectLiteralExpression): IrStatement { val startOffset = ktObjectLiteral.startOffsetSkippingComments val endOffset = ktObjectLiteral.endOffset - val objectLiteralType = getInferredTypeWithImplicitCastsOrFail(ktObjectLiteral).toIrType() + val objectLiteralType = getTypeInferredByFrontendOrFail(ktObjectLiteral).toIrType() val irBlock = IrBlockImpl(startOffset, endOffset, objectLiteralType, IrStatementOrigin.OBJECT_LITERAL) val irClass = DeclarationGenerator(statementGenerator.context).generateClassOrObjectDeclaration(ktObjectLiteral.objectDeclaration) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt index 4e502517874..0711cb889d6 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt @@ -28,7 +28,7 @@ class LocalFunctionGenerator(statementGenerator: StatementGenerator) : Statement fun generateLambda(ktLambda: KtLambdaExpression): IrStatement { val ktFun = ktLambda.functionLiteral - val lambdaExpressionType = getInferredTypeWithImplicitCastsOrFail(ktLambda).toIrType() + val lambdaExpressionType = getTypeInferredByFrontendOrFail(ktLambda).toIrType() val irLambdaFunction = FunctionGenerator(context).generateLambdaFunctionDeclaration(ktFun) return IrFunctionExpressionImpl( @@ -43,7 +43,7 @@ class LocalFunctionGenerator(statementGenerator: StatementGenerator) : Statement val irFun = generateFunctionDeclaration(ktFun) if (ktFun.name != null) return irFun - val funExpressionType = getInferredTypeWithImplicitCastsOrFail(ktFun).toIrType() + val funExpressionType = getTypeInferredByFrontendOrFail(ktFun).toIrType() return IrFunctionExpressionImpl( ktFun.startOffset, ktFun.endOffset, funExpressionType, diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt index 41a004b95c7..b12a0397604 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt @@ -37,7 +37,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St fun generateClassLiteral(ktClassLiteral: KtClassLiteralExpression): IrExpression { val ktArgument = ktClassLiteral.receiverExpression!! val lhs = getOrFail(BindingContext.DOUBLE_COLON_LHS, ktArgument) - val resultType = getInferredTypeWithImplicitCastsOrFail(ktClassLiteral).toIrType() + val resultType = getTypeInferredByFrontendOrFail(ktClassLiteral).toIrType() return if (lhs is DoubleColonLHS.Expression && !lhs.isObjectQualifier) { IrGetClassImpl( @@ -69,7 +69,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St ).call { dispatchReceiverValue, extensionReceiverValue -> generateCallableReference( ktCallableReference, - getInferredTypeWithImplicitCastsOrFail(ktCallableReference), + getTypeInferredByFrontendOrFail(ktCallableReference), callBuilder.descriptor, callBuilder.typeArguments ).also { irCallableReference -> diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt index f3ac40ca083..168a8b9e5fb 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt @@ -161,7 +161,7 @@ class StatementGenerator( val isBlockBody = expression.parent is KtDeclarationWithBody && expression.parent !is KtFunctionLiteral if (isBlockBody) throw AssertionError("Use IrBlockBody and corresponding body generator to generate blocks as function bodies") - val returnType = getInferredTypeWithImplicitCasts(expression) ?: context.builtIns.unitType + val returnType = getExpressionTypeWithCoercionToUnitOrFail(expression) val irBlock = IrBlockImpl(expression.startOffsetSkippingComments, expression.endOffset, returnType.toIrType()) expression.statements.forEach { @@ -226,14 +226,14 @@ class StatementGenerator( context.constantValueGenerator.generateConstantValueAsExpression( expression.startOffsetSkippingComments, expression.endOffset, - constant.toConstantValue(getInferredTypeWithImplicitCastsOrFail(expression)) + constant.toConstantValue(getTypeInferredByFrontendOrFail(expression)) ) override fun visitStringTemplateExpression(expression: KtStringTemplateExpression, data: Nothing?): IrStatement { val startOffset = expression.startOffsetSkippingComments val endOffset = expression.endOffset - val resultType = getInferredTypeWithImplicitCastsOrFail(expression).toIrType() + val resultType = getTypeInferredByFrontendOrFail(expression).toIrType() val entries = expression.entries.map { it.genExpr() }.postprocessStringTemplateEntries() return when (entries.size) { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TryCatchExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TryCatchExpressionGenerator.kt index bb44d39cc14..3588bfc2290 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TryCatchExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TryCatchExpressionGenerator.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.BindingContext class TryCatchExpressionGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) { fun generateTryCatch(ktTry: KtTryExpression): IrExpression { - val resultType = getInferredTypeWithImplicitCastsOrFail(ktTry).toIrType() + val resultType = getExpressionTypeWithCoercionToUnitOrFail(ktTry).toIrType() val irTryCatch = IrTryImpl(ktTry.startOffsetSkippingComments, ktTry.endOffset, resultType) irTryCatch.tryResult = ktTry.tryBlock.genExpr() diff --git a/compiler/testData/ir/irCfg/when/whenReturn.txt b/compiler/testData/ir/irCfg/when/whenReturn.txt index 168f72b0179..8068c49704b 100644 --- a/compiler/testData/ir/irCfg/when/whenReturn.txt +++ b/compiler/testData/ir/irCfg/when/whenReturn.txt @@ -2,10 +2,10 @@ // FUN: toString BB 0 CONTENT - 1 FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String + 1 FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String 2 GET_VAR 'grade: kotlin.String declared in .toString' type=kotlin.String origin=null - 3 VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.String [val] - 4 WHEN type=kotlin.Nothing origin=WHEN + 3 VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.String [val] + 4 WHEN type=kotlin.Unit origin=WHEN 5 GET_VAR 'val tmp0_subject: kotlin.String [val] declared in .toString' type=kotlin.String origin=null 6 CONST String type=kotlin.String value="A" OUTGOING -> BB 1, 5 @@ -47,7 +47,7 @@ CONTENT 1 CONST String type=kotlin.String value="Excellent" 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String + Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String BB 6 INCOMING <- BB 1 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ @@ -55,7 +55,7 @@ CONTENT 1 CONST String type=kotlin.String value="Good" 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String + Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String BB 7 INCOMING <- BB 2 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ @@ -63,7 +63,7 @@ CONTENT 1 CONST String type=kotlin.String value="Mediocre" 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String + Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String BB 8 INCOMING <- BB 3 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ @@ -71,7 +71,7 @@ CONTENT 1 CONST String type=kotlin.String value="Fair" 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String + Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String BB 9 INCOMING <- BB 4 CONST Boolean type=kotlin.Boolean value=true @@ -79,7 +79,7 @@ CONTENT 1 CONST String type=kotlin.String value="Failure" 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String + Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String BB 10 INCOMING <- BB 4 CONST Boolean type=kotlin.Boolean value=true @@ -87,7 +87,7 @@ CONTENT 1 CONST String type=kotlin.String value="???" 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String + Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String // END FUN: toString diff --git a/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.txt b/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.txt index ecb8e162fa4..8a9e0a92831 100644 --- a/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.txt +++ b/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.txt @@ -23,15 +23,15 @@ FILE fqName: fileName:/useNextParamInLambda.kt BLOCK_BODY VAR name:result type:kotlin.String [var] CONST String type=kotlin.String value="fail" - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - TRY type=kotlin.Any - try: BLOCK type=kotlin.String origin=null + TRY type=kotlin.Unit + try: BLOCK type=kotlin.Unit origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun f (f1: kotlin.Function0, f2: kotlin.Function0): kotlin.String declared in ' type=kotlin.String origin=null - CATCH parameter=val e: java.lang.Exception{ kotlin.Exception } [val] declared in .box - VAR CATCH_PARAMETER name:e type:java.lang.Exception{ kotlin.Exception } [val] - BLOCK type=kotlin.Unit origin=null - SET_VAR 'var result: kotlin.String [var] declared in .box' type=kotlin.Unit origin=EQ - CONST String type=kotlin.String value="OK" + CATCH parameter=val e: java.lang.Exception{ kotlin.Exception } [val] declared in .box + VAR CATCH_PARAMETER name:e type:java.lang.Exception{ kotlin.Exception } [val] + BLOCK type=kotlin.Unit origin=null + SET_VAR 'var result: kotlin.String [var] declared in .box' type=kotlin.Unit origin=EQ + CONST String type=kotlin.String value="OK" RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS $this: CALL 'public final fun f (f1: kotlin.Function0, f2: kotlin.Function0): kotlin.String declared in ' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.txt index 1f2d1d91c27..e42fb09954c 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInWhen.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.txt @@ -23,8 +23,8 @@ 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 tmp0_iterator: kotlin.collections.IntIterator [val] declared in .testBreakFor' type=kotlin.collections.IntIterator origin=null - BLOCK type=kotlin.Nothing origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 [var] declared in .testBreakFor' type=kotlin.Int origin=null @@ -39,7 +39,7 @@ FILE fqName: fileName:/breakContinueInWhen.kt arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakWhile' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=10 body: BLOCK type=kotlin.Unit origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 [var] declared in .testBreakWhile' type=kotlin.Int origin=null @@ -52,7 +52,7 @@ FILE fqName: fileName:/breakContinueInWhen.kt BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP body: COMPOSITE type=kotlin.Unit origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null @@ -85,8 +85,8 @@ 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 tmp0_iterator: kotlin.collections.IntIterator [val] declared in .testContinueFor' type=kotlin.collections.IntIterator origin=null - BLOCK type=kotlin.Nothing origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 [var] declared in .testContinueFor' type=kotlin.Int origin=null @@ -101,7 +101,7 @@ FILE fqName: fileName:/breakContinueInWhen.kt arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueWhile' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=10 body: BLOCK type=kotlin.Unit origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 [var] declared in .testContinueWhile' type=kotlin.Int origin=null @@ -122,7 +122,7 @@ FILE fqName: fileName:/breakContinueInWhen.kt CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PREFIX_INCR $this: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=PREFIX_INCR GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=PREFIX_INCR - WHEN type=kotlin.Nothing origin=WHEN + 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 [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/catchParameterAccess.txt b/compiler/testData/ir/irText/expressions/catchParameterAccess.txt index 233740df33d..b0ca8357105 100644 --- a/compiler/testData/ir/irText/expressions/catchParameterAccess.txt +++ b/compiler/testData/ir/irText/expressions/catchParameterAccess.txt @@ -9,6 +9,6 @@ FILE fqName: fileName:/catchParameterAccess.kt $this: GET_VAR 'f: kotlin.Function0 declared in .test' type=kotlin.Function0 origin=VARIABLE_AS_FUNCTION CATCH parameter=val e: java.lang.Exception{ kotlin.Exception } [val] declared in .test VAR CATCH_PARAMETER name:e type:java.lang.Exception{ kotlin.Exception } [val] - BLOCK type=kotlin.Nothing origin=null + BLOCK type=kotlin.Unit origin=null THROW type=kotlin.Nothing GET_VAR 'val e: java.lang.Exception{ kotlin.Exception } [val] declared in .test' type=java.lang.Exception{ kotlin.Exception } origin=null diff --git a/compiler/testData/ir/irText/expressions/forWithBreakContinue.txt b/compiler/testData/ir/irText/expressions/forWithBreakContinue.txt index c22f5187334..9ec89b726c5 100644 --- a/compiler/testData/ir/irText/expressions/forWithBreakContinue.txt +++ b/compiler/testData/ir/irText/expressions/forWithBreakContinue.txt @@ -13,7 +13,7 @@ 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 tmp0_iterator: kotlin.collections.Iterator [val] declared in .testForBreak1' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Nothing origin=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 @@ -29,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 tmp0_iterator: kotlin.collections.Iterator [val] 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:tmp1_iterator 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 @@ -41,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 tmp1_iterator: kotlin.collections.Iterator [val] 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=null loop.label=INNER @@ -60,7 +60,7 @@ 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 tmp0_iterator: kotlin.collections.Iterator [val] declared in .testForContinue1' type=kotlin.collections.Iterator origin=null - BLOCK type=kotlin.Nothing origin=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 @@ -76,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 tmp0_iterator: kotlin.collections.Iterator [val] 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:tmp1_iterator 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 @@ -88,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 tmp1_iterator: kotlin.collections.Iterator [val] 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=null loop.label=INNER diff --git a/compiler/testData/ir/irText/expressions/ifElseIf.txt b/compiler/testData/ir/irText/expressions/ifElseIf.txt index 85f3074cfd9..adf897bdd58 100644 --- a/compiler/testData/ir/irText/expressions/ifElseIf.txt +++ b/compiler/testData/ir/irText/expressions/ifElseIf.txt @@ -36,22 +36,22 @@ FILE fqName: fileName:/ifElseIf.kt FUN name:testEmptyBranches2 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - WHEN type=kotlin.Any origin=IF - BRANCH - if: GET_VAR 'flag: kotlin.Boolean declared in .testEmptyBranches2' type=kotlin.Boolean origin=null - then: BLOCK type=kotlin.Unit origin=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CONST Boolean type=kotlin.Boolean value=true - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - WHEN type=kotlin.Any origin=IF - BRANCH - if: GET_VAR 'flag: kotlin.Boolean declared in .testEmptyBranches2' type=kotlin.Boolean origin=null - then: CONST Boolean type=kotlin.Boolean value=true - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: GET_VAR 'flag: kotlin.Boolean declared in .testEmptyBranches2' type=kotlin.Boolean origin=null + then: BLOCK type=kotlin.Unit origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=IF + BRANCH + if: GET_VAR 'flag: kotlin.Boolean declared in .testEmptyBranches2' type=kotlin.Boolean origin=null + then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONST Boolean type=kotlin.Boolean value=true + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null FUN name:testEmptyBranches3 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/throw.txt b/compiler/testData/ir/irText/expressions/throw.txt index 3632cf95143..0ac43ccde73 100644 --- a/compiler/testData/ir/irText/expressions/throw.txt +++ b/compiler/testData/ir/irText/expressions/throw.txt @@ -10,7 +10,7 @@ FILE fqName: fileName:/throw.kt 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: BLOCK type=kotlin.Nothing origin=null + then: BLOCK type=kotlin.Unit origin=null 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/tryCatch.txt b/compiler/testData/ir/irText/expressions/tryCatch.txt index 6d53c564aa5..241dc83315b 100644 --- a/compiler/testData/ir/irText/expressions/tryCatch.txt +++ b/compiler/testData/ir/irText/expressions/tryCatch.txt @@ -22,7 +22,7 @@ FILE fqName: fileName:/tryCatch.kt BLOCK type=kotlin.Int origin=null CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null CONST Int type=kotlin.Int value=24 - finally: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - BLOCK type=kotlin.Int origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + finally: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CONST Int type=kotlin.Int value=555 diff --git a/compiler/testData/ir/irText/expressions/whenReturn.txt b/compiler/testData/ir/irText/expressions/whenReturn.txt index 242b93dd25a..cc2e18af0e4 100644 --- a/compiler/testData/ir/irText/expressions/whenReturn.txt +++ b/compiler/testData/ir/irText/expressions/whenReturn.txt @@ -2,10 +2,10 @@ FILE fqName: fileName:/whenReturn.kt FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String VALUE_PARAMETER name:grade index:0 type:kotlin.String BLOCK_BODY - BLOCK type=kotlin.Nothing origin=WHEN + BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.String [val] GET_VAR 'grade: kotlin.String declared in .toString' type=kotlin.String origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 tmp0_subject: kotlin.String [val] declared in .toString' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/expressions/whenReturnUnit.txt b/compiler/testData/ir/irText/expressions/whenReturnUnit.txt index bb41f5a63c8..f4ab25a0559 100644 --- a/compiler/testData/ir/irText/expressions/whenReturnUnit.txt +++ b/compiler/testData/ir/irText/expressions/whenReturnUnit.txt @@ -10,10 +10,10 @@ FILE fqName: fileName:/whenReturnUnit.kt block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - BLOCK type=kotlin.Nothing origin=WHEN + BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val] GET_VAR 'x: kotlin.Int declared in .branch' type=kotlin.Int origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 tmp0_subject: kotlin.Int [val] declared in .branch.' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/whenUnusedExpression.txt b/compiler/testData/ir/irText/expressions/whenUnusedExpression.txt index 6ea59049af9..995ceff8284 100644 --- a/compiler/testData/ir/irText/expressions/whenUnusedExpression.txt +++ b/compiler/testData/ir/irText/expressions/whenUnusedExpression.txt @@ -3,23 +3,25 @@ FILE fqName: fileName:/whenUnusedExpression.kt VALUE_PARAMETER name:b index:0 type:kotlin.Boolean VALUE_PARAMETER name:i index:1 type:kotlin.Int BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - 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=null - BLOCK type=kotlin.Int? origin=WHEN - VAR IR_TEMPORARY_VARIABLE name:tmp0_subject 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 tmp0_subject: kotlin.Int [val] 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 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: GET_VAR 'b: kotlin.Boolean declared in .test' type=kotlin.Boolean origin=null + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val] + GET_VAR 'i: kotlin.Int declared in .test' 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 tmp0_subject: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONST Int type=kotlin.Int value=1 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/regressions/kt24114.txt b/compiler/testData/ir/irText/regressions/kt24114.txt index 86b41dcbcb2..705b14fa14c 100644 --- a/compiler/testData/ir/irText/regressions/kt24114.txt +++ b/compiler/testData/ir/irText/regressions/kt24114.txt @@ -12,19 +12,19 @@ FILE fqName: fileName:/kt24114.kt WHILE label=null origin=WHILE_LOOP condition: CONST Boolean type=kotlin.Boolean value=true body: BLOCK type=kotlin.Unit origin=null - BLOCK type=kotlin.Nothing origin=WHEN + BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val] CALL 'public final fun one (): kotlin.Int declared in ' type=kotlin.Int origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 tmp0_subject: kotlin.Int [val] declared in .test1' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=1 - then: BLOCK type=kotlin.Nothing origin=null - BLOCK type=kotlin.Nothing origin=WHEN + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp1_subject type:kotlin.Int [val] CALL 'public final fun two (): kotlin.Int declared in ' type=kotlin.Int origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 tmp1_subject: kotlin.Int [val] declared in .test1' type=kotlin.Int origin=null @@ -40,18 +40,18 @@ FILE fqName: fileName:/kt24114.kt WHILE label=null origin=WHILE_LOOP condition: CONST Boolean type=kotlin.Boolean value=true body: BLOCK type=kotlin.Unit origin=null - BLOCK type=kotlin.Nothing origin=WHEN + BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val] CALL 'public final fun one (): kotlin.Int declared in ' type=kotlin.Int origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 tmp0_subject: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=1 - then: BLOCK type=kotlin.Nothing origin=WHEN + then: BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp1_subject type:kotlin.Int [val] CALL 'public final fun two (): kotlin.Int declared in ' type=kotlin.Int origin=null - WHEN type=kotlin.Nothing origin=WHEN + 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 tmp1_subject: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null