Index: lib/compiler/implementation/elements/elements.dart |
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart |
index 65b83b18441c1c3db755b9d21e3bad6899d48c81..44af75996e763f2908cf06406724b9fff96c1e2d 100644 |
--- a/lib/compiler/implementation/elements/elements.dart |
+++ b/lib/compiler/implementation/elements/elements.dart |
@@ -144,6 +144,10 @@ class Element implements Hashable { |
bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; |
bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; |
+ // TODO(johnniwinther): This breaks for libraries (for which enclosing |
+ // elements are null) and is invalid for top level variable declarations for |
+ // which the enclosing element is a VariableDeclarations and not a compilation |
+ // unit. |
bool isTopLevel() => enclosingElement.isCompilationUnit(); |
bool isAssignable() { |
@@ -212,7 +216,7 @@ class Element implements Hashable { |
String toString() { |
// TODO(johnniwinther): Test for nullness of name, or make non-nullness an |
// invariant for all element types. |
- if (!isTopLevel()) { |
+ if (enclosingElement !== null && !isTopLevel()) { |
String holderName = enclosingElement.name.slowToString(); |
return '$kind($holderName#${name.slowToString()})'; |
} else { |