[IR] Use deepCopyWithSymbols in IrTypeOperatorCall

This commit is contained in:
Ilya Goncharov
2021-03-26 16:20:12 +03:00
committed by TeamCityServer
parent 7046f9badd
commit 084d824984
3 changed files with 7 additions and 13 deletions
@@ -269,8 +269,12 @@ class TypeOperatorLowering(val context: JsIrBackendContext) : BodyLoweringPass {
// assert(!typeParameter.isReified) { "reified parameters have to be lowered before" }
return typeParameter.superTypes.fold<IrType, IrExpression?>(null) { r, t ->
require(argument is IrExpressionWithCopy) { "Not a copyable expression: ${argument.render()}" }
val check = generateTypeCheckNonNull(argument.copy(), t.makeNotNull())
val copy = if (argument is IrExpressionWithCopy) {
argument.copy()
} else {
argument.deepCopyWithSymbols()
}
val check = generateTypeCheckNonNull(copy, t.makeNotNull())
if (r == null) {
check
@@ -66,7 +66,7 @@ enum class IrTypeOperator {
REINTERPRET_CAST;
}
abstract class IrTypeOperatorCall : IrExpression(), IrExpressionWithCopy {
abstract class IrTypeOperatorCall : IrExpression() {
abstract val operator: IrTypeOperator
abstract var argument: IrExpression
abstract var typeOperand: IrType
@@ -46,14 +46,4 @@ class IrTypeOperatorCallImpl(
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
argument = argument.transform(transformer, data)
}
override fun copy(): IrExpression =
IrTypeOperatorCallImpl(
startOffset,
endOffset,
type,
operator,
typeOperand,
argument
)
}