casts to a primitive types are coercion methods instead

This commit is contained in:
Dmitry Jemerov
2012-06-01 18:29:45 +02:00
committed by Pavel V. Talanov
parent 152d214870
commit 12603cdd81
2 changed files with 12 additions and 3 deletions
@@ -269,8 +269,17 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
public override fun visitTypeCastExpression(expression: PsiTypeCastExpression?): Unit {
val castType: PsiTypeElement? = expression?.getCastType()
if (castType != null) {
myResult = TypeCastExpression(getConverter().typeToType(castType.getType()),
getConverter().expressionToExpression(expression?.getOperand()))
val operand = expression?.getOperand()
val operandType = operand?.getType()
val typeText = castType.getType().getCanonicalText()
val typeConversion = Converter.PRIMITIVE_TYPE_CONVERSIONS[typeText]
if (operandType is PsiPrimitiveType && typeConversion != null) {
myResult = MethodCallExpression.build(getConverter().expressionToExpression(operand), typeConversion)
}
else {
myResult = TypeCastExpression(getConverter().typeToType(castType.getType()),
getConverter().expressionToExpression(operand))
}
}
}
@@ -1 +1 @@
(100.00 as Int)
100.00.toInt()