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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 12038066: Change a couple of API functions to return unhandled exception errors instead of fatal errors on im… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 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 | « no previous file | 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 95d3f0c26c92e8e5a68eea139b575d3fc09a0cfd..6964ad298f2daebc9771662258cf82314dd3df83 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1989,10 +1989,9 @@ DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list,
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(list));
- if (obj.IsArray()) {
- if (obj.IsImmutableArray()) {
- return Api::NewError("Cannot modify immutable array");
- }
+ // If the list is immutable we call into Dart for the indexed setter to
+ // get the unsupported operation exception as the result.
+ if (obj.IsArray() && !obj.IsImmutableArray()) {
SET_LIST_ELEMENT(isolate, Array, obj, index, value);
} else if (obj.IsGrowableObjectArray()) {
SET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index, value);
@@ -2153,10 +2152,9 @@ DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
return Api::Success(isolate);
}
return Api::NewError("Invalid length passed in to set list elements");
- } else if (obj.IsArray()) {
- if (obj.IsImmutableArray()) {
- return Api::NewError("Cannot modify immutable array");
- }
+ } else if (obj.IsArray() && !obj.IsImmutableArray()) {
+ // If the list is immutable we call into Dart for the indexed setter to
+ // get the unsupported operation exception as the result.
SET_LIST_ELEMENT_AS_BYTES(isolate,
Array,
obj,
@@ -2173,7 +2171,7 @@ DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
} else if (obj.IsError()) {
return list;
} else {
- // Check and handle a dart object that implements the List interface.
+ // Check and handle a dart object that implements the List interface.
const Instance& instance =
Instance::Handle(isolate, GetListInstance(isolate, obj));
if (!instance.IsNull()) {
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698