Index: pkg/smoke/lib/mirrors.dart |
diff --git a/pkg/smoke/lib/mirrors.dart b/pkg/smoke/lib/mirrors.dart |
index bcaa42ab99ae4cfebfb2314b2a53c83e16a0ac38..27a526ee87a71b270de191a69adfc5c1c5ac41b4 100644 |
--- a/pkg/smoke/lib/mirrors.dart |
+++ b/pkg/smoke/lib/mirrors.dart |
@@ -67,6 +67,19 @@ class ReflectiveObjectAccessorService implements ObjectAccessorService { |
/// Implements [TypeInspectorService] using mirrors. |
class ReflectiveTypeInspectorService implements TypeInspectorService { |
+ bool isSubclassOf(Type type, Type supertype) { |
+ if (type == supertype || supertype == Object) return true; |
+ // TODO(sigmund): change to mirror.isSubclassOf when it gets implemented in |
+ // dart2js. (dartbug.com/12439) |
+ var mirror = reflectClass(type); |
+ var top = reflectClass(supertype); |
+ while (mirror != _objectType) { |
+ mirror = _safeSuperclass(mirror); |
+ if (mirror == top) return true; |
+ } |
+ return false; |
+ } |
+ |
bool hasGetter(Type type, Symbol name) { |
var mirror = reflectType(type); |
if (mirror is! ClassMirror) return false; |
@@ -137,8 +150,9 @@ class ReflectiveTypeInspectorService implements TypeInspectorService { |
} |
List<Declaration> _query(ClassMirror cls, QueryOptions options) { |
- var result = (!options.includeInherited || cls.superclass == _objectType) |
- ? [] : _query(cls.superclass, options); |
+ final visitParent = options.includeInherited && cls.superclass != null && |
+ cls.superclass != reflectClass(options.includeUpTo); |
Siggi Cherem (dart-lang)
2014/02/25 23:23:23
note that for the same reasons than below (classes
Jennifer Messerly
2014/02/25 23:50:09
might be worth adding this comment (it can refer t
Siggi Cherem (dart-lang)
2014/02/26 00:09:50
Done.
|
+ var result = visitParent ? _query(cls.superclass, options) : []; |
for (var member in cls.declarations.values) { |
if (member is! VariableMirror && member is! MethodMirror) continue; |
if (member.isStatic || member.isPrivate) continue; |