|
@@ -142,17 +142,10 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
|
|
|
public Type infer(NumericalAddSubtractExpression e) {
|
|
|
Type type1 = inferTypeDispatch(e.getLeftOperand());
|
|
|
Type type2 = inferTypeDispatch(e.getRightOperand());
|
|
|
- if (registry.isSame(type1, getType(STRING))) {
|
|
|
- assertCompatibleWithConversion(type1, type2, String.format(CAN_NOT_CONVERT, type2, type1));
|
|
|
- return getType(STRING);
|
|
|
- } else {
|
|
|
- assertCompatible(type1, type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
|
|
|
- assertIsType(type1, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2), getType(INTEGER),
|
|
|
- getType(REAL));
|
|
|
- assertIsType(type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2), getType(INTEGER),
|
|
|
- getType(REAL));
|
|
|
- return getCommonType(e.getLeftOperand(), e.getRightOperand());
|
|
|
- }
|
|
|
+ assertCompatible(type1, type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
|
|
|
+ assertIsType(type1, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2), getType(INTEGER),
|
|
|
+ getType(REAL));
|
|
|
+ return getCommonType(e.getLeftOperand(), e.getRightOperand());
|
|
|
}
|
|
|
|
|
|
public Type infer(NumericalMultiplyDivideExpression e) {
|
|
@@ -161,8 +154,6 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
|
|
|
assertCompatible(type1, type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
|
|
|
assertIsType(type1, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2), getType(INTEGER),
|
|
|
getType(REAL));
|
|
|
- assertIsType(type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2), getType(INTEGER),
|
|
|
- getType(REAL));
|
|
|
return getCommonType(type1, type2);
|
|
|
}
|
|
|
|
|
@@ -179,7 +170,7 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
|
|
|
public Type infer(TypeCastExpression e) {
|
|
|
Type type1 = inferTypeDispatch(e.getOperand());
|
|
|
Type type2 = inferTypeDispatch(e.getType());
|
|
|
- assertAssignable(type1, type2, String.format(CAST_OPERATORS, type1, type2));
|
|
|
+ assertCompatible(type1, type2, String.format(CAST_OPERATORS, type1, type2));
|
|
|
return inferTypeDispatch(e.getType());
|
|
|
}
|
|
|
|
|
@@ -254,8 +245,8 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
|
|
|
public Type infer(DoubleLiteral literal) {
|
|
|
return getType(REAL);
|
|
|
}
|
|
|
-
|
|
|
- public Type infer(FloatLiteral literal) {
|
|
|
+
|
|
|
+ public Type infer(FloatLiteral literal){
|
|
|
return getType(REAL);
|
|
|
}
|
|
|
|