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

Unified Diff: runtime/lib/mirrors.cc

Issue 23133003: Fix ClassMirror.typeArguments handling for dynamic only type arguments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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/mirrors/generics_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index 94812720ef564e408e28142a58f7651e16ca81c2..46e047757755b4b8b4504f420632dd7839c906ad 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -592,19 +592,30 @@ DEFINE_NATIVE_ENTRY(ClassMirror_type_variables, 1) {
DEFINE_NATIVE_ENTRY(ClassMirror_type_arguments, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0));
- const AbstractTypeArguments& args =
- AbstractTypeArguments::Handle(type.arguments());
- if (args.IsNull()) {
- return Object::empty_array().raw();
- }
-
const Class& cls = Class::Handle(type.type_class());
const intptr_t num_params = cls.NumTypeParameters();
- const intptr_t num_inherited_args = args.Length() - num_params;
+
+ if (num_params == 0) return Object::empty_array().raw();
rmacnak 2013/08/14 00:07:41 While I think this looks better, we use braces eve
Michael Lippautz (Google) 2013/08/14 00:14:09 Done.
const Array& result = Array::Handle(Array::New(num_params));
AbstractType& arg_type = AbstractType::Handle();
Instance& type_mirror = Instance::Handle();
+ const AbstractTypeArguments& args =
+ AbstractTypeArguments::Handle(type.arguments());
+
+ // Handle argument lists that have been optimized away, because either no
+ // arguments have been provided, or all arguments have been dynamic. Return a
siva 2013/08/14 00:22:09 or all arguments are dynamic
Michael Lippautz (Google) 2013/08/14 16:29:29 Done.
+ // list of typemirrors on dynamic in this case.
+ if (args.IsNull()) {
+ arg_type ^= Object::dynamic_type();
+ type_mirror ^= CreateTypeMirror(arg_type);
+ for (intptr_t i = 0; i < num_params; i++) {
+ result.SetAt(i, type_mirror);
+ }
+ return result.raw();
+ }
+
siva 2013/08/14 00:22:09 ASSERT(args.Length() >= num_params);
Michael Lippautz (Google) 2013/08/14 16:29:29 Done.
+ const intptr_t num_inherited_args = args.Length() - num_params;
for (intptr_t i = 0; i < num_params; i++) {
arg_type ^= args.TypeAt(i + num_inherited_args);
type_mirror = CreateTypeMirror(arg_type);
« no previous file with comments | « no previous file | tests/lib/mirrors/generics_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698