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

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

Issue 8394018: Report an error if a constructor initializer calls a setter method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updates based on Fabio's review Created 9 years, 2 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 | tests/language/language.status » ('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 ce0efddfe091eb86f0c5dd8d542272307348a4cc..389057e15c41f8d870dafe3750e7b5d05cd682e9 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -1056,6 +1056,13 @@ public class Resolver {
FieldElement field = (FieldElement) element;
if (field.isStatic()) {
resolutionError(x, DartCompilerErrorCode.CANNOT_INIT_STATIC_FIELD_IN_INITIALIZER);
+ } else if (field.getModifiers().isAbstractField()) {
+ /*
+ * If we get here then we know that this is a property accessor and not a true field.
+ * If there was a field and property accessor with the same name a name collision error
+ * would keep us from reaching this point.
+ */
+ resolutionError(x, DartCompilerErrorCode.CANNOT_RESOLVE_FIELD, name);
} else {
resolutionError(x, DartCompilerErrorCode.CANNOT_INIT_FIELD_FROM_SUPERCLASS);
}
@@ -1090,7 +1097,7 @@ public class Resolver {
// Make sure the identifier is a local instance field.
FieldElement element = Elements.lookupLocalField(
(ClassElement) currentHolder, x.getName().getTargetName());
- if (element == null || element.isStatic()) {
+ if (element == null || element.isStatic() || element.getModifiers().isAbstractField()) {
diagnoseErrorInInitializer(x.getName());
}
recordElement(x.getName(), element);
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698