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

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

Issue 10943034: Issue 5162. Report error when initializing already initialized final field (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.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/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 a7360f25456b561142c12c23ada99636e83d5d38..7df44654da231f1fc7fbfd6e4828e8f42e0c1dda 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -628,6 +628,19 @@ public class Resolver {
DartFunction functionNode = node.getFunction();
List<DartParameter> parameters = functionNode.getParameters();
Set<FieldElement> initializedFields = Sets.newHashSet();
+
+ // remember field with initializers
+ if (previousEnclosingElement instanceof ClassElement) {
+ ClassElement classElement = (ClassElement) previousEnclosingElement;
+ for (Element classMember : classElement.getMembers()) {
+ if (ElementKind.of(classMember) == ElementKind.FIELD) {
+ FieldElement fieldMember = (FieldElement) classMember;
+ if (fieldMember.getModifiers().isFinal() && fieldMember.getModifiers().isInitialized()) {
+ initializedFields.add(fieldMember);
+ }
+ }
+ }
+ }
// First declare all normal parameters in the scope, putting them in the
// scope of the default expressions so we can report better errors.
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698