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

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

Issue 12045040: Issue 7633. Report error when instance field is accessed from factory constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.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 f40cb666b9aa9fa87c9f44224695d4e92c79cd51..a9294c57db5fd3972ece39ea411dfbc5eafa2b4c 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -1395,13 +1395,18 @@ public class Resolver {
String name, Element element) {
switch (element.getKind()) {
case FIELD:
- if (!Elements.isStaticContext(element) && !element.getModifiers().isConstant()) {
- if (inInstanceVariableInitializer) {
- onError(x, ResolverErrorCode.CANNOT_USE_INSTANCE_FIELD_IN_INSTANCE_FIELD_INITIALIZER);
+ if (!Elements.isStaticContext(element)) {
+ if (!element.getModifiers().isConstant()) {
+ if (inInstanceVariableInitializer) {
+ onError(x, ResolverErrorCode.CANNOT_USE_INSTANCE_FIELD_IN_INSTANCE_FIELD_INITIALIZER);
+ }
+ }
+ if (ASTNodes.isStaticContext(x)) {
+ onError(x, ResolverErrorCode.ILLEGAL_FIELD_ACCESS_FROM_STATIC, name);
+ }
+ if (ASTNodes.isFactoryContext(x)) {
+ onError(x, ResolverErrorCode.ILLEGAL_FIELD_ACCESS_FROM_FACTORY, name);
}
- }
- if (ASTNodes.isStaticContext(x) && !Elements.isStaticContext(element)) {
- onError(x, ResolverErrorCode.ILLEGAL_FIELD_ACCESS_FROM_STATIC, name);
}
if (isIllegalPrivateAccess(x, enclosingElement, element, x.getName())) {
return null;
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698