Use the dart2js type system for isSubtypeOf and isSubclassOf.
R=johnniwinther@google.com BUG= http://dartbug.com/16737 Review URL: https://codereview.chromium.org//167003004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32741 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -4,10 +4,6 @@
|
||||
|
||||
part of dart2js.mirrors;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
abstract class ClassMirrorMixin implements ClassSourceMirror {
|
||||
bool get hasReflectedType => false;
|
||||
Type get reflectedType {
|
||||
@@ -55,11 +51,19 @@ abstract class Dart2JsTypeMirror
|
||||
bool get isDynamic => false;
|
||||
|
||||
bool isSubtypeOf(TypeMirror other) {
|
||||
return mirrorSystem.compiler.types.isSubtype(this._type, other._type);
|
||||
if (other is Dart2JsTypeMirror) {
|
||||
return mirrorSystem.compiler.types.isSubtype(this._type, other._type);
|
||||
} else {
|
||||
throw new ArgumentError(other);
|
||||
}
|
||||
}
|
||||
|
||||
bool isAssignableTo(TypeMirror other) {
|
||||
return mirrorSystem.compiler.types.isAssignable(this._type, other._type);
|
||||
if (other is Dart2JsTypeMirror) {
|
||||
return mirrorSystem.compiler.types.isAssignable(this._type, other._type);
|
||||
} else {
|
||||
throw new ArgumentError(other);
|
||||
}
|
||||
}
|
||||
|
||||
String toString() => _type.toString();
|
||||
@@ -235,15 +239,14 @@ class Dart2JsClassDeclarationMirror
|
||||
: super(system, type);
|
||||
|
||||
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;
|
||||
if (other is Dart2JsFunctionTypeMirror) {
|
||||
return false;
|
||||
} else if (other is Dart2JsClassDeclarationMirror) {
|
||||
Dart2JsClassDeclarationMirror otherDeclaration =
|
||||
other.originalDeclaration;
|
||||
return _element.isSubclassOf(otherDeclaration._element);
|
||||
}
|
||||
return false;
|
||||
throw new ArgumentError(other);
|
||||
}
|
||||
|
||||
String toString() => 'Mirror on class ${_type.name}';
|
||||
|
||||
@@ -13,8 +13,6 @@ simple_inferrer_const_closure_test: Fail # Issue 16507
|
||||
simple_inferrer_const_closure2_test: Fail # Issue 16507
|
||||
simple_inferrer_global_field_closure_test: Fail # Issue 16507
|
||||
|
||||
mirrors/relation_subclass_test: Fail # Issue 16737
|
||||
|
||||
[ $mode == debug ]
|
||||
mirror_final_field_inferrer2_test: Crash, Pass, Slow # dartbug.com/15581
|
||||
|
||||
|
||||
Reference in New Issue
Block a user