[JS IR BE] Fix type for lowered cast expression

Safe cast result type is different from its type operand.
This commit is contained in:
Svyatoslav Kuzmich
2019-05-04 21:55:31 +03:00
parent fc0a0f41d2
commit feeb6e9862
@@ -109,10 +109,10 @@ class TypeOperatorLowering(val context: JsIrBackendContext) : FileLoweringPass {
val argument = cacheValue(expression.argument, newStatements, declaration)
val check = generateTypeCheck(argument, toType)
newStatements += JsIrBuilder.buildIfElse(toType, check, argument(), failResult)
newStatements += JsIrBuilder.buildIfElse(expression.type, check, argument(), failResult)
return expression.run {
IrCompositeImpl(startOffset, endOffset, toType, null, newStatements)
IrCompositeImpl(startOffset, endOffset, expression.type, null, newStatements)
}
}