| Index: compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
|
| diff --git a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
|
| index a57418f8dd9d9d0f54af561be7fbe69badd37f8c..bfe7a3b95ae7afc7fc1489e938762c231e17f13f 100644
|
| --- a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
|
| +++ b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
|
| @@ -215,19 +215,22 @@ public class CompileTimeConstantAnalyzer {
|
|
|
| case ADD:
|
| if (lhsType.equals(stringType)) {
|
| + // TODO(zundel): remove this when + no longer acceptable as string concat operator
|
| if (checkString(rhs, rhsType)) {
|
| rememberInferredType(x, stringType);
|
| }
|
| - } else if (checkNumber(lhs, lhsType) && checkNumber(rhs, rhsType)) {
|
| - rememberInferredType(x, numType);
|
| + } else {
|
| + checkMathExpression(x, lhs, rhs, lhsType, rhsType);
|
| }
|
| break;
|
| case SUB:
|
| case MUL:
|
| case DIV:
|
| + checkMathExpression(x, lhs, rhs, lhsType, rhsType);
|
| + break;
|
| case MOD:
|
| if (checkNumber(lhs, lhsType) && checkNumber(rhs, rhsType)) {
|
| - rememberInferredType(x, numType);
|
| + rememberInferredType(x, intType);
|
| }
|
| break;
|
| case LT:
|
| @@ -246,6 +249,23 @@ public class CompileTimeConstantAnalyzer {
|
| return null;
|
| }
|
|
|
| + private void checkMathExpression(DartBinaryExpression x,
|
| + DartExpression lhs, DartExpression rhs,
|
| + Type lhsType, Type rhsType) {
|
| + if (checkNumber(lhs, lhsType) && checkNumber(rhs, rhsType)) {
|
| + if (lhsType.equals(intType) && rhsType.equals(intType)) {
|
| + rememberInferredType(x, intType);
|
| + } else if (lhsType.equals(doubleType) && rhsType.equals(doubleType)) {
|
| + rememberInferredType(x, doubleType);
|
| + } else if (lhsType.equals(doubleType) && rhsType.equals(intType)
|
| + || lhsType.equals(intType) && rhsType.equals(doubleType)) {
|
| + rememberInferredType(x, doubleType);
|
| + } else {
|
| + rememberInferredType(x, numType);
|
| + }
|
| + }
|
| + }
|
| +
|
| @Override
|
| public Void visitBooleanLiteral(DartBooleanLiteral x) {
|
| rememberInferredType(x, boolType);
|
|
|