casts to a primitive types are coercion methods instead
This commit is contained in:
committed by
Pavel V. Talanov
parent
152d214870
commit
12603cdd81
@@ -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()
|
||||
Reference in New Issue
Block a user