FIR2IR: standardize expression with smart cast conversion

To convert smart cast expression, now we just convert
original expression in standard way and wrap it with TYPE_OP.
Before this commit original expression was converted in different way,
that led to errors e.g. for this expression casting.
This commit is contained in:
Mikhail Glukhikh
2020-02-25 12:12:48 +03:00
parent d1fac6dce1
commit 522eeae062
12 changed files with 9 additions and 13 deletions
@@ -936,7 +936,7 @@ class Fir2IrVisitor(
override fun visitExpressionWithSmartcast(expressionWithSmartcast: FirExpressionWithSmartcast, data: Any?): IrElement {
// Generate the expression with the original type and then cast it to the smart cast type.
val value = expressionWithSmartcast.toIrExpression(expressionWithSmartcast.originalType).applyReceivers(expressionWithSmartcast)
val value = expressionWithSmartcast.originalExpression.toIrExpression()
val castType = expressionWithSmartcast.typeRef.toIrType(session, declarationStorage)
if (value.type == castType) return value
return IrTypeOperatorCallImpl(