Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Unified Diff: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart

Issue 167003004: Use the dart2js type system for isSubtypeOf and isSubclassOf. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart
index 3f5bfddffac18ba3a947c8ac4ad12b81746ae734..2145f92533580c9b22c52a7a0d5f35e245c3dad4 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart
@@ -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}';
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698