| Index: runtime/lib/mirrors_impl.dart
|
| diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
|
| index 7a337304068e4ec82e16bfa2bbc5b2286a68145b..c30ffffd3172ac31bd2fe19cbf3953bcaed6cbfd 100644
|
| --- a/runtime/lib/mirrors_impl.dart
|
| +++ b/runtime/lib/mirrors_impl.dart
|
| @@ -108,6 +108,12 @@ String _makeSignatureString(TypeMirror returnType,
|
| List _metadata(reflectee)
|
| native 'DeclarationMirror_metadata';
|
|
|
| +bool _subtypeTest(Type a, Type b)
|
| + native 'TypeMirror_subtypeTest';
|
| +
|
| +bool _moreSpecificTest(Type a, Type b)
|
| + native 'TypeMirror_moreSpecificTest';
|
| +
|
| class _LocalMirrorSystem extends MirrorSystem {
|
| final Map<Uri, LibraryMirror> libraries;
|
| final IsolateMirror isolate;
|
| @@ -760,6 +766,31 @@ class _LocalClassMirror extends _LocalObjectMirror
|
|
|
| int get hashCode => simpleName.hashCode;
|
|
|
| + bool isSubtypeOf(TypeMirror other) {
|
| + if (other == currentMirrorSystem().dynamicType) return true;
|
| + if (other == currentMirrorSystem().voidType) return false;
|
| + return _subtypeTest(_reflectedType, other._reflectedType);
|
| + }
|
| +
|
| + bool isAssignableTo(TypeMirror other) {
|
| + if (other == currentMirrorSystem().dynamicType) return true;
|
| + if (other == currentMirrorSystem().voidType) return false;
|
| + return _moreSpecificTest(_reflectedType, other._reflectedType)
|
| + || _moreSpecificTest(other._reflectedType, _reflectedType);
|
| + }
|
| +
|
| + bool isSubclassOf(ClassMirror other) {
|
| + if (other is! ClassMirror) throw new ArgumentError(other);
|
| + ClassMirror otherDeclaration = other.originalDeclaration;
|
| + ClassMirror c = this;
|
| + while (c != null) {
|
| + c = c.originalDeclaration;
|
| + if (c == otherDeclaration) return true;
|
| + c = c.superclass;
|
| + }
|
| + return false;
|
| + }
|
| +
|
| static _library(reflectee)
|
| native "ClassMirror_library";
|
|
|
| @@ -932,7 +963,8 @@ class _LocalTypeVariableMirror extends _LocalDeclarationMirror
|
| }
|
|
|
| bool get hasReflectedType => false;
|
| - Type get reflectedType => throw new UnsupportedError() ;
|
| + Type get reflectedType => throw new UnsupportedError();
|
| + Type get _reflectedType => _reflectee;
|
|
|
| List<TypeVariableMirror> get typeVariables => emptyList;
|
| List<TypeMirror> get typeArguments => emptyList;
|
| @@ -949,6 +981,19 @@ class _LocalTypeVariableMirror extends _LocalDeclarationMirror
|
| }
|
| int get hashCode => simpleName.hashCode;
|
|
|
| + bool isSubtypeOf(TypeMirror other) {
|
| + if (other == currentMirrorSystem().dynamicType) return true;
|
| + if (other == currentMirrorSystem().voidType) return false;
|
| + return _subtypeTest(_reflectedType, other._reflectedType);
|
| + }
|
| +
|
| + bool isAssignableTo(TypeMirror other) {
|
| + if (other == currentMirrorSystem().dynamicType) return true;
|
| + if (other == currentMirrorSystem().voidType) return false;
|
| + return _moreSpecificTest(_reflectedType, other._reflectedType)
|
| + || _moreSpecificTest(other._reflectedType, _reflectedType);
|
| + }
|
| +
|
| static DeclarationMirror _TypeVariableMirror_owner(reflectee)
|
| native "TypeVariableMirror_owner";
|
|
|
| @@ -1036,6 +1081,19 @@ class _LocalTypedefMirror extends _LocalDeclarationMirror
|
|
|
| String toString() => "TypedefMirror on '${_n(simpleName)}'";
|
|
|
| + bool isSubtypeOf(TypeMirror other) {
|
| + if (other == currentMirrorSystem().dynamicType) return true;
|
| + if (other == currentMirrorSystem().voidType) return false;
|
| + return _subtypeTest(_reflectedType, other._reflectedType);
|
| + }
|
| +
|
| + bool isAssignableTo(TypeMirror other) {
|
| + if (other == currentMirrorSystem().dynamicType) return true;
|
| + if (other == currentMirrorSystem().voidType) return false;
|
| + return _moreSpecificTest(_reflectedType, other._reflectedType)
|
| + || _moreSpecificTest(other._reflectedType, _reflectedType);
|
| + }
|
| +
|
| static _nativeReferent(reflectedType)
|
| native "TypedefMirror_referent";
|
|
|
| @@ -1441,6 +1499,15 @@ class _SpecialTypeMirror extends _LocalMirror
|
| int get hashCode => simpleName.hashCode;
|
|
|
| String toString() => "TypeMirror on '${_n(simpleName)}'";
|
| +
|
| + bool isSubtypeOf(TypeMirror other) {
|
| + return this == other ||
|
| + (other is _SpecialTypeMirror && other.simpleName == #dynamic);
|
| + }
|
| +
|
| + bool isAssignableTo(TypeMirror other) {
|
| + return simpleName == #dynamic || other is _SpecialTypeMirror;
|
| + }
|
| }
|
|
|
| class _Mirrors {
|
|
|