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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 1406573003: Fix for issue 22379246 makes the API consistent between Dart_New and Dart_InvokeConstructor. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-comments Created 5 years, 2 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/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 55a352f9ac73ed455f1b0b2b3f162ba7621eb4f8..9186ce6af3d28f43941a7b1af74a64e9fa81e7f1 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -4011,10 +4011,6 @@ DART_EXPORT Dart_Handle Dart_InvokeConstructor(Dart_Handle object,
"%s expects argument 'number_of_arguments' to be non-negative.",
CURRENT_FUNC);
}
- const String& constructor_name = Api::UnwrapStringHandle(Z, name);
- if (constructor_name.IsNull()) {
- RETURN_TYPE_ERROR(Z, name, String);
- }
const Instance& instance = Api::UnwrapInstanceHandle(Z, object);
if (instance.IsNull()) {
RETURN_TYPE_ERROR(Z, object, Instance);
@@ -4026,13 +4022,18 @@ DART_EXPORT Dart_Handle Dart_InvokeConstructor(Dart_Handle object,
// once for the same object.
// Construct name of the constructor to invoke.
+ const String& constructor_name = Api::UnwrapStringHandle(Z, name);
const Type& type_obj = Type::Handle(Z, instance.GetType());
const Class& cls = Class::Handle(Z, type_obj.type_class());
const String& class_name = String::Handle(Z, cls.Name());
const Array& strings = Array::Handle(Z, Array::New(3));
strings.SetAt(0, class_name);
strings.SetAt(1, Symbols::Dot());
- strings.SetAt(2, constructor_name);
+ if (constructor_name.IsNull()) {
+ strings.SetAt(2, Symbols::Empty());
+ } else {
+ strings.SetAt(2, constructor_name);
+ }
const String& dot_name = String::Handle(Z, String::ConcatAll(strings));
const TypeArguments& type_arguments =
TypeArguments::Handle(Z, type_obj.arguments());
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698