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

Unified Diff: sdk/lib/_internal/lib/js_mirrors.dart

Issue 172353003: Implement Mirror.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/lib/lib.status » ('j') | tests/lib/mirrors/relation_subclass_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/js_mirrors.dart
diff --git a/sdk/lib/_internal/lib/js_mirrors.dart b/sdk/lib/_internal/lib/js_mirrors.dart
index b790ca9dac00bc652ffc088cd0740bb1f046adcb..da6ee8c553bf8fa74520e1caaae84d5b841e7b86 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -796,8 +796,12 @@ class JsMixinApplication extends JsTypeMirror with JsObjectMirror
bool get isAbstract => throw new UnimplementedError();
- bool isSubclassOf(ClassMirror other) => throw new UnimplementedError();
+ bool isSubclassOf(ClassMirror other) {
+ superclass.isSubclassOf(other) || mixin.isSubclassOf(other);
+ }
+
bool isSubtypeOf(TypeMirror other) => throw new UnimplementedError();
+
bool isAssignableTo(TypeMirror other) => throw new UnimplementedError();
}
@@ -1148,6 +1152,15 @@ class JsTypeBoundClassMirror extends JsDeclarationMirror
super(originalDeclaration.simpleName);
String get _prettyName => 'ClassMirror';
+
+ String toString() {
+ String result = '$_prettyName on ${n(simpleName)}';
+ if (typeArguments != null) {
+ result = "$result<${typeArguments.join(', ')}>";
+ }
+ return result;
+ }
+
String get _mangledName {
for (TypeMirror typeArgument in typeArguments) {
if (typeArgument != JsMirrorSystem._dynamicType) {
@@ -1394,6 +1407,7 @@ class JsTypeBoundClassMirror extends JsDeclarationMirror
Function operator [](Symbol name) => throw new UnimplementedError();
bool isSubtypeOf(TypeMirror other) => throw new UnimplementedError();
+
bool isAssignableTo(TypeMirror other) => throw new UnimplementedError();
}
@@ -1906,7 +1920,20 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
bool get isAbstract => throw new UnimplementedError();
- bool isSubclassOf(ClassMirror other) => throw new UnimplementedError();
+ bool isSubclassOf(JsClassMirror other) {
+ if (other is! ClassMirror) {
+ throw new ArgumentError(other);
+ }
+ if (other is JsFunctionTypeMirror) {
+ return false;
+ } if (JS('bool', '# == #', other._jsConstructor, _jsConstructor)) {
+ return true;
+ } else if (superclass == null) {
+ return false;
+ } else {
+ return superclass.isSubclassOf(other);
+ }
+ }
}
class JsVariableMirror extends JsDeclarationMirror implements VariableMirror {
@@ -2503,8 +2530,10 @@ class JsFunctionTypeMirror extends BrokenClassMirror
return _cachedToString = "$s'";
}
- bool isSubclassOf(ClassMirror other) => throw new UnimplementedError();
+ bool isSubclassOf(ClassMirror other) => false;
Johnni Winther 2014/02/26 15:44:59 Should this return true on Function?
karlklose 2014/02/27 08:41:02 I don't know, for me the predicate does not make s
Johnni Winther 2014/02/27 10:54:20 Go with the VM.
+
bool isSubtypeOf(TypeMirror other) => throw new UnimplementedError();
+
bool isAssignableTo(TypeMirror other) => throw new UnimplementedError();
// TODO(ahe): Implement this method.
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | tests/lib/mirrors/relation_subclass_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698