diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TypeOperatorLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TypeOperatorLowering.kt index c67af92c254..a637274fa3e 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TypeOperatorLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TypeOperatorLowering.kt @@ -269,8 +269,12 @@ class TypeOperatorLowering(val context: JsIrBackendContext) : BodyLoweringPass { // assert(!typeParameter.isReified) { "reified parameters have to be lowered before" } return typeParameter.superTypes.fold(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 diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt index ece1946e6ca..f23ff69a9fe 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt @@ -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 diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt index fdcd97351b0..3f12c0a8e82 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt @@ -46,14 +46,4 @@ class IrTypeOperatorCallImpl( override fun transformChildren(transformer: IrElementTransformer, data: D) { argument = argument.transform(transformer, data) } - - override fun copy(): IrExpression = - IrTypeOperatorCallImpl( - startOffset, - endOffset, - type, - operator, - typeOperand, - argument - ) }