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

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

Issue 8624001: Don't allow invoking a constructor as 'const' if it wasn't declared 'const'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Self-review Created 9 years, 1 month 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 | compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantResolver.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2b00c88ef7291a4d8aad98b946ce45d519bec292..6a6e2953a5273d92ff9368623963c95fbd1ab9df 100644
--- a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
@@ -35,6 +35,7 @@ import com.google.dart.compiler.ast.DartPropertyAccess;
import com.google.dart.compiler.ast.DartRedirectConstructorInvocation;
import com.google.dart.compiler.ast.DartStringInterpolation;
import com.google.dart.compiler.ast.DartStringLiteral;
+import com.google.dart.compiler.ast.DartSuperConstructorInvocation;
import com.google.dart.compiler.ast.DartSuperExpression;
import com.google.dart.compiler.ast.DartThisExpression;
import com.google.dart.compiler.ast.DartUnaryExpression;
@@ -428,8 +429,9 @@ public class CompileTimeConstantAnalyzer {
@Override
public Void visitSuperExpression(DartSuperExpression x) {
- // No need to traverse further - super() expressions are never constant
- expectedConstant(x);
+ if (!x.getSymbol().getModifiers().isConstant()) {
+ expectedConstant(x);
+ }
return null;
}
@@ -468,6 +470,12 @@ public class CompileTimeConstantAnalyzer {
}
@Override
+ public Void visitSuperConstructorInvocation(DartSuperConstructorInvocation x) {
+ x.visitChildren(this);
+ return null;
+ }
+
+ @Override
public Void visitUnqualifiedInvocation(DartUnqualifiedInvocation x) {
// No need to traverse, always disallowed.
expectedConstant(x);
@@ -520,6 +528,18 @@ public class CompileTimeConstantAnalyzer {
}
return null;
}
+
+ @Override
+ public Void visitRedirectConstructorInvocation(DartRedirectConstructorInvocation node) {
+ // Don't evaluate now, wait until it is referenced and evaluate as part of the expression
+ return null;
+ }
+
+ @Override
+ public Void visitSuperConstructorInvocation(DartSuperConstructorInvocation node) {
+ // Don't evaluate now, wait until it is referenced and evaluate as part of the expression
+ return null;
+ }
}
public static class Phase implements DartCompilationPhase {
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantResolver.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698