[JS IR] Type operator call pureness

This commit is contained in:
Ilya Goncharov
2021-03-09 19:02:01 +03:00
parent 47d050c420
commit 8ac8dbdab8
2 changed files with 8 additions and 1 deletions
@@ -661,6 +661,12 @@ fun IrExpression?.isPure(
if (valueDeclaration is IrVariable) !valueDeclaration.isVar
else true
}
is IrTypeOperatorCall ->
(
operator == IrTypeOperator.INSTANCEOF ||
operator == IrTypeOperator.REINTERPRET_CAST ||
operator == IrTypeOperator.NOT_INSTANCEOF
) && argument.isPure(anyVariable, checkFields, context)
is IrCall -> if (context?.isSideEffectFree(this) == true) {
for (i in 0 until valueArgumentsCount) {
val valueArgument = getValueArgument(i)
@@ -61,7 +61,8 @@ class JsIrBackendContext(
override fun isSideEffectFree(call: IrCall): Boolean =
call.symbol in intrinsics.primitiveToLiteralConstructor.values ||
call.symbol == intrinsics.arrayLiteral
call.symbol == intrinsics.arrayLiteral ||
call.symbol == intrinsics.arrayConcat
val devMode = configuration[JSConfigurationKeys.DEVELOPER_MODE] ?: false
val errorPolicy = configuration[JSConfigurationKeys.ERROR_TOLERANCE_POLICY] ?: ErrorTolerancePolicy.DEFAULT