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

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

Issue 9982003: Make sure toplevel final fields are initialized (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
Index: compiler/java/com/google/dart/compiler/resolver/Resolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
index 40277e8b6a1b7a17856d29b96412a2e0d1bad9e6..d40f3b7059096dac47ab5dad75d48cfdedb4b019 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -634,13 +634,9 @@ public class Resolver {
public Element visitField(DartField node) {
DartExpression expression = node.getValue();
Modifiers modifiers = node.getModifiers();
- boolean isStatic = modifiers.isStatic();
boolean isFinal = modifiers.isFinal();
boolean isTopLevel = ElementKind.of(currentHolder).equals(ElementKind.LIBRARY);
-
- if (isTopLevel && isFinal) {
- modifiers.makeStatic();
scheglov 2012/04/04 15:21:04 We don't set static flag anymore. I don't know if
zundel 2012/04/04 17:49:31 That's just the thing. This code didn't set anyth
- }
+ boolean isStatic = modifiers.isStatic();
if (expression != null) {
resolve(expression);
@@ -653,6 +649,8 @@ public class Resolver {
} else if (isFinal) {
if (isStatic) {
onError(node, ResolverErrorCode.STATIC_FINAL_REQUIRES_VALUE);
+ } else if (isTopLevel) {
+ onError(node, ResolverErrorCode.TOPLEVEL_FINAL_REQUIRES_VALUE);
} else {
// If a final instance field wasn't initialized at declaration, we must check
// at construction time.

Powered by Google App Engine
This is Rietveld 408576698