Chromium Code Reviews| Index: dart/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java |
| diff --git a/dart/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java b/dart/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java |
| index d84849e7ceed2cc87f3de9c2a7bc3a264ec723f3..e872845e24149b7e60405a918b3caf1638337432 100644 |
| --- a/dart/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java |
| +++ b/dart/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java |
| @@ -87,6 +87,17 @@ public class CompileTimeConstantAnalyzer { |
| return true; |
| } |
| + private boolean checkString(DartNode x, Type type) { |
| + if (!type.equals(stringType)) { |
| + context |
| + .onError(new DartCompilationError(x, |
| + ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION_STRING, type |
| + .toString())); |
| + return false; |
| + } |
| + return true; |
| + } |
| + |
| private boolean checkNumber(DartNode x, Type type) { |
| if (!(type.equals(numType) || type.equals(intType) || type |
| .equals(doubleType))) { |
| @@ -209,6 +220,14 @@ public class CompileTimeConstantAnalyzer { |
| break; |
| case ADD: |
| + if (lhsType.equals(stringType)) { |
| + if (checkString(lhs, lhsType) && checkString(rhs, rhsType)) { |
|
ngeoffray
2012/01/31 13:17:40
You don't need to check lhs is string again.
ahe
2012/01/31 13:21:37
Done.
|
| + rememberInferredType(x, stringType); |
| + } |
| + } else if (checkNumber(lhs, lhsType) && checkNumber(rhs, rhsType)) { |
| + rememberInferredType(x, numType); |
| + } |
| + break; |
| case SUB: |
| case MUL: |
| case DIV: |