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

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

Issue 88473002: Support reflection on generics with dynamic types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 002865d56e9cbba0c43b4502b35e0f461118022f..c62ffd2fc21c945e3032eac7f042c1e67c7f2866 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -278,9 +278,12 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
var result = new Map();
for (String className in _classes) {
var cls = reflectClassByMangledName(className);
- if (cls is JsClassMirror) {
- result[cls.simpleName] = cls;
- cls._owner = this;
+ if (cls is ClassMirror) {
+ cls = cls.originalDeclaration;
+ if (cls is JsClassMirror) {
+ result[cls.simpleName] = cls;
+ cls._owner = this;
+ }
}
}
return _cachedClasses =
@@ -479,6 +482,7 @@ TypeMirror reflectType(Type key) {
TypeMirror reflectClassByMangledName(String mangledName) {
String unmangledName = mangledGlobalNames[mangledName];
+ if (mangledName == 'dynamic') return JsMirrorSystem._dynamicType;
if (unmangledName == null) unmangledName = mangledName;
return reflectClassByName(s(unmangledName), mangledName);
}
@@ -492,8 +496,8 @@ TypeMirror reflectClassByName(Symbol symbol, String mangledName) {
disableTreeShaking();
int typeArgIndex = mangledName.indexOf("<");
if (typeArgIndex != -1) {
- mirror = new JsTypeBoundClassMirror(
- reflectClassByMangledName(mangledName.substring(0, typeArgIndex)),
+ mirror = new JsTypeBoundClassMirror(reflectClassByMangledName(
+ mangledName.substring(0, typeArgIndex)).originalDeclaration,
// Remove the angle brackets enclosing the type arguments.
mangledName.substring(typeArgIndex + 1, mangledName.length - 1));
JsCache.update(classMirrors, mangledName, mirror);
@@ -539,8 +543,19 @@ TypeMirror reflectClassByName(Symbol symbol, String mangledName) {
if (mixins.length > 1 && mangledGlobalNames[mangledName] == null) {
mirror = reflectMixinApplication(mixins, mangledName);
} else {
- mirror = new JsClassMirror(
+ ClassMirror classMirror = new JsClassMirror(
symbol, mangledName, constructorOrInterceptor, fields, fieldsMetadata);
+ List typeVariables =
+ JS('JSExtendableArray|Null', '#.prototype["<>"]', constructor);
+ if (typeVariables == null || typeVariables.length == 0) {
+ mirror = classMirror;
+ } else {
+ String typeArguments = 'dynamic';
+ for (int i = 1; i < typeVariables.length; i++) {
+ typeArguments += ',dynamic';
+ }
+ mirror = new JsTypeBoundClassMirror(classMirror, typeArguments);
+ }
}
JsCache.update(classMirrors, mangledName, mirror);
« 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