Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1726)

Unified Diff: dart/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java

Issue 9303033: Two different classes may have the same *name*. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: null.toString() is also broken Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/compiler/java/com/google/dart/compiler/resolver/Resolver.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « no previous file | dart/compiler/java/com/google/dart/compiler/resolver/Resolver.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698