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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 23983026: Fill in type arguments when creating an object from the mirrors or embedding API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: RareType 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 c70064b47d889142eac26551cc0f78d79c82e8af..7a673f913b86f93b3aec09d7b24d034f0e9e0013 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -2846,13 +2846,18 @@ DART_EXPORT Dart_Handle Dart_New(Dart_Handle type,
RETURN_TYPE_ERROR(isolate, type, Type);
}
Class& cls = Class::Handle(isolate);
+ AbstractTypeArguments& type_arguments =
+ AbstractTypeArguments::Handle(isolate);
+
if (result.IsType()) {
cls = Type::Cast(result).type_class();
+ type_arguments = Type::Cast(result).arguments();
} else if (result.IsClass()) {
// For backwards compatibility we allow class objects to be passed in
// for now. This needs to be removed once all code that uses class
// objects to invoke Dart_New is removed.
cls ^= result.raw();
+ type_arguments = Type::Handle(cls.RareType()).arguments();
} else {
RETURN_TYPE_ERROR(isolate, type, Type);
}
@@ -2913,12 +2918,18 @@ DART_EXPORT Dart_Handle Dart_New(Dart_Handle type,
Array::Handle(isolate, Array::New(number_of_arguments + extra_args));
if (constructor.IsConstructor()) {
// Constructors get the uninitialized object and a constructor phase.
+ if (!type_arguments.IsNull()) {
+ // The type arguments will be null if the class has no type parameters, in
+ // which case the following call would fail because there is no slot
+ // reserved in the object for the type vector.
+ new_object.SetTypeArguments(type_arguments);
+ }
args.SetAt(arg_index++, new_object);
args.SetAt(arg_index++,
Smi::Handle(isolate, Smi::New(Function::kCtorPhaseAll)));
} else {
// Factories get type arguments.
- args.SetAt(arg_index++, TypeArguments::Handle(isolate));
+ args.SetAt(arg_index++, type_arguments);
}
Object& argument = Object::Handle(isolate);
for (int i = 0; i < number_of_arguments; i++) {
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/object.h » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698