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; |