Index: sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart b/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart |
index cede225be99a109917dbbcaa04c9047e58434ebd..8614d9d6df1619ceb7c322a5acc65f33fb01a419 100644 |
--- a/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart |
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart |
@@ -53,14 +53,14 @@ LibraryMirror findLibrary(MemberMirror member) { |
throw new Exception('Unexpected owner: ${owner}'); |
} |
-class HierarchyIterable implements Iterable<ClassMirror> { |
+class HierarchyIterable extends Iterable<ClassMirror> { |
final bool includeType; |
final ClassMirror type; |
HierarchyIterable(this.type, {bool includeType}) |
: this.includeType = includeType; |
- Iterator<ClassMirror> iterator() => |
+ Iterator<ClassMirror> get iterator => |
new HierarchyIterator(type, includeType: includeType); |
} |
@@ -68,7 +68,7 @@ class HierarchyIterable implements Iterable<ClassMirror> { |
* [HierarchyIterator] iterates through the class hierarchy of the provided |
* type. |
* |
- * First is the superclass relation is traversed, skipping [Object], next the |
+ * First the superclass relation is traversed, skipping [Object], next the |
* superinterface relation and finally is [Object] visited. The supertypes are |
* visited in breadth first order and a superinterface is visited more than once |
* if implemented through multiple supertypes. |
@@ -76,6 +76,7 @@ class HierarchyIterable implements Iterable<ClassMirror> { |
class HierarchyIterator implements Iterator<ClassMirror> { |
final Queue<ClassMirror> queue = new Queue<ClassMirror>(); |
ClassMirror object; |
+ ClassMirror _current; |
HierarchyIterator(ClassMirror type, {bool includeType}) { |
if (includeType) { |
@@ -97,19 +98,18 @@ class HierarchyIterator implements Iterator<ClassMirror> { |
return type; |
} |
- ClassMirror next() { |
- ClassMirror type; |
+ ClassMirror get current => _current; |
+ |
+ bool moveNext() { |
+ _current = null; |
if (queue.isEmpty) { |
- if (object == null) { |
- throw new StateError("No more elements"); |
- } |
- type = object; |
+ if (object == null) return false; |
+ _current = object; |
object = null; |
- return type; |
+ return true; |
} else { |
- return push(queue.removeFirst()); |
+ _current = push(queue.removeFirst()); |
+ return true; |
} |
} |
- |
- bool get hasNext => !queue.isEmpty || object != null; |
} |