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

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

Issue 103713006: Implement ClassMirror.reflectedType in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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') | no next file with comments »
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 f27c8cc054fc0ca6afb45eeaffeac8810cf3ba62..022bb59b5d9e27ce550e5ff9f4837222df00e829 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -963,7 +963,16 @@ class JsTypeBoundClassMirror extends JsDeclarationMirror
super(originalDeclaration.simpleName);
String get _prettyName => 'ClassMirror';
- String get _mangledName => '${_class._mangledName}<$_typeArguments>';
+ String get _mangledName {
+ for (TypeMirror typeArgument in typeArguments) {
+ if (typeArgument != JsMirrorSystem._dynamicType) {
+ return '${_class._mangledName}<$_typeArguments>';
+ }
+ }
+ // When all type arguments are dynamic, the canonical representation is to
+ // drop them.
+ return _class._mangledName;
+ }
List<TypeVariableMirror> get typeVariables => _class.typeVariables;
@@ -1116,8 +1125,6 @@ class JsTypeBoundClassMirror extends JsDeclarationMirror
return _cachedSuperinterfaces = _class._getSuperinterfacesWithOwner(this);
}
- bool get hasReflectedType => _class.hasReflectedType;
-
bool get isPrivate => _class.isPrivate;
bool get isTopLevel => _class.isTopLevel;
@@ -1128,7 +1135,9 @@ class JsTypeBoundClassMirror extends JsDeclarationMirror
Symbol get qualifiedName => _class.qualifiedName;
- Type get reflectedType => _class.reflectedType;
+ bool get hasReflectedType => true;
+
+ Type get reflectedType => createRuntimeType(_mangledName);
Symbol get simpleName => _class.simpleName;
@@ -1498,6 +1507,16 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
List<TypeMirror> get typeArguments => const <TypeMirror>[];
+ bool get hasReflectedType => typeVariables.length == 0;
+
+ Type get reflectedType {
+ if (!hasReflectedType) {
+ throw new UnsupportedError(
+ "Declarations of generics have no reflected type");
+ }
+ return createRuntimeType(_mangledName);
+ }
+
// TODO(ahe): Implement this.
Map<Symbol, MethodMirror> get instanceMembers
=> throw new UnimplementedError();
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698