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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 25097005: Make ClassMirror.newInstance deal with reordered etc type arguments for redirecting factories. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: multitest Created 7 years, 3 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
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 1af8dbcfd25014a7c221bfafba055619222194bb..db59e203207a5d1fe747b02f4bfbd058160f52f0 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -2834,12 +2834,14 @@ DART_EXPORT Dart_Handle Dart_New(Dart_Handle type,
}
// Get the class to instantiate.
- const Type& type_obj = Api::UnwrapTypeHandle(isolate, type);
- if (type_obj.IsNull()) {
+ Object& unchecked_type = Object::Handle(Api::UnwrapHandle(type));
+ if (unchecked_type.IsNull() || !unchecked_type.IsType()) {
RETURN_TYPE_ERROR(isolate, type, Type);
}
+ Type& type_obj = Type::Handle();
+ type_obj ^= unchecked_type.raw();
Class& cls = Class::Handle(isolate, type_obj.type_class());
- const AbstractTypeArguments& type_arguments =
+ AbstractTypeArguments& type_arguments =
AbstractTypeArguments::Handle(isolate, type_obj.arguments());
const String& base_constructor_name = String::Handle(isolate, cls.Name());
@@ -2877,13 +2879,28 @@ DART_EXPORT Dart_Handle Dart_New(Dart_Handle type,
Instance& new_object = Instance::Handle(isolate);
if (constructor.IsRedirectingFactory()) {
ClassFinalizer::ResolveRedirectingFactory(cls, constructor);
- const Type& type = Type::Handle(constructor.RedirectionType());
+ Type& redirect_type = Type::Handle(constructor.RedirectionType());
constructor = constructor.RedirectionTarget();
if (constructor.IsNull()) {
- ASSERT(type.IsMalformed());
- return Api::NewHandle(isolate, type.malformed_error());
+ ASSERT(redirect_type.IsMalformed());
+ return Api::NewHandle(isolate, redirect_type.malformed_error());
+ }
+
+ if (!redirect_type.IsMalformed() && !redirect_type.IsInstantiated()) {
+ // The type arguments of the redirection type are instantiated from the
+ // type arguments of the parsed type of the 'new' or 'const' expression.
+ Error& malformed_error = Error::Handle();
regis 2013/10/01 18:01:53 ditto
+ redirect_type ^= redirect_type.InstantiateFrom(type_arguments,
+ &malformed_error);
+ if (!malformed_error.IsNull()) {
+ return Api::NewHandle(isolate, malformed_error.raw());
+ }
}
- cls = type.type_class();
+
+ type_obj = redirect_type.raw();
+ type_arguments = redirect_type.arguments();
+
+ cls = type_obj.type_class();
}
if (constructor.IsConstructor()) {
// Create the new object.
« runtime/lib/mirrors.cc ('K') | « runtime/lib/mirrors.cc ('k') | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698