[FIR2IR] Simplify generateWhen
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
24c8eb43a2
commit
68b84722c4
@@ -616,8 +616,8 @@ class Fir2IrVisitor(
|
|||||||
|
|
||||||
generateWhen(
|
generateWhen(
|
||||||
startOffset, endOffset, IrStatementOrigin.ELVIS,
|
startOffset, endOffset, IrStatementOrigin.ELVIS,
|
||||||
subjectVariable, irBranches, true,
|
subjectVariable, irBranches,
|
||||||
elvisCall.typeRef
|
elvisCall.typeRef.toIrType()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -660,10 +660,10 @@ class Fir2IrVisitor(
|
|||||||
generateWhen(
|
generateWhen(
|
||||||
startOffset, endOffset, origin,
|
startOffset, endOffset, origin,
|
||||||
subjectVariable, irBranches,
|
subjectVariable, irBranches,
|
||||||
whenExpression.isExhaustive && whenExpression.branches.none {
|
if (whenExpression.isExhaustive && whenExpression.branches.none {
|
||||||
it.condition is FirElseIfTrueCondition && it.result.statements.isEmpty()
|
it.condition is FirElseIfTrueCondition && it.result.statements.isEmpty()
|
||||||
},
|
}
|
||||||
whenExpression.typeRef
|
) whenExpression.typeRef.toIrType() else irBuiltIns.unitType
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -675,14 +675,9 @@ class Fir2IrVisitor(
|
|||||||
origin: IrStatementOrigin?,
|
origin: IrStatementOrigin?,
|
||||||
subjectVariable: IrVariable?,
|
subjectVariable: IrVariable?,
|
||||||
branches: List<IrBranch>,
|
branches: List<IrBranch>,
|
||||||
isEffectivelyExhaustive: Boolean,
|
resultType: IrType
|
||||||
resultTypeRef: FirTypeRef
|
|
||||||
): IrExpression {
|
): IrExpression {
|
||||||
val irWhen = IrWhenImpl(
|
val irWhen = IrWhenImpl(startOffset, endOffset, resultType, origin, branches)
|
||||||
startOffset, endOffset,
|
|
||||||
if (isEffectivelyExhaustive) resultTypeRef.toIrType() else irBuiltIns.unitType,
|
|
||||||
origin, branches
|
|
||||||
)
|
|
||||||
return if (subjectVariable == null) {
|
return if (subjectVariable == null) {
|
||||||
irWhen
|
irWhen
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user