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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 2615943004: Reapply "reflectType() dynamic type arguments support (#26012)" (Closed)
Patch Set: Add a test. Created 3 years, 11 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 | « runtime/lib/mirrors.cc ('k') | runtime/lib/mirrors_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors_impl.dart
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
index fe1c56ecdeb2726c023103dcfe542f93f8ab8668..f152adbc7334cffa00596224455530aecd15e020 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -1645,6 +1645,8 @@ class _Mirrors {
native "Mirrors_makeLocalClassMirror";
static TypeMirror makeLocalTypeMirror(Type key)
native "Mirrors_makeLocalTypeMirror";
+ static Type instantiateGenericType(Type key, typeArguments)
+ native "Mirrors_instantiateGenericType";
static Expando<ClassMirror> _declarationCache = new Expando("ClassMirror");
static Expando<TypeMirror> _instantiationCache = new Expando("TypeMirror");
@@ -1661,7 +1663,10 @@ class _Mirrors {
return classMirror;
}
- static TypeMirror reflectType(Type key) {
+ static TypeMirror reflectType(Type key, [List<Type> typeArguments]) {
+ if (typeArguments != null) {
+ key = _instantiateType(key, typeArguments);
+ }
var typeMirror = _instantiationCache[key];
if (typeMirror == null) {
typeMirror = makeLocalTypeMirror(key);
@@ -1672,4 +1677,12 @@ class _Mirrors {
}
return typeMirror;
}
+
+ static Type _instantiateType(Type key, List<Type> typeArguments) {
+ if (typeArguments.isEmpty) {
+ throw new ArgumentError.value(
+ typeArguments, 'typeArguments', 'Type arguments list cannot be empty.');
+ }
+ return instantiateGenericType(key, typeArguments.toList(growable: false));
+ }
}
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/lib/mirrors_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698