IR: remove .toKotlinType() usage from coerceToUnit calls in lowerings

This commit is contained in:
Georgy Bronnikov
2020-09-11 13:04:49 +03:00
parent 6a55475392
commit 3c0fbd5f45
2 changed files with 22 additions and 28 deletions
@@ -19,8 +19,6 @@ import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.utils.DFS
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -156,23 +154,8 @@ fun IrExpression.isFalseConst() = this is IrConst<*> && this.kind == IrConstKind
fun IrExpression.isIntegerConst(value: Int) = this is IrConst<*> && this.kind == IrConstKind.Int && this.value == value
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun IrExpression.coerceToUnit(builtins: IrBuiltIns): IrExpression {
return coerceToUnitIfNeeded(type.toKotlinType(), builtins)
}
@ObsoleteDescriptorBasedAPI
fun IrExpression.coerceToUnitIfNeeded(valueType: KotlinType, irBuiltIns: IrBuiltIns): IrExpression {
return if (KotlinTypeChecker.DEFAULT.isSubtypeOf(valueType, irBuiltIns.unitType.toKotlinType()))
this
else
IrTypeOperatorCallImpl(
startOffset, endOffset,
irBuiltIns.unitType,
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT,
irBuiltIns.unitType,
this
)
return coerceToUnitIfNeeded(type, builtins)
}
fun IrExpression.coerceToUnitIfNeeded(valueType: IrType, irBuiltIns: IrBuiltIns): IrExpression {