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

Unified Diff: runtime/lib/invocation_mirror_patch.dart

Issue 22918025: Make Invocation.positionalArguments and .namedArguments never be null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. 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 | sdk/lib/_internal/lib/js_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/invocation_mirror_patch.dart
diff --git a/runtime/lib/invocation_mirror_patch.dart b/runtime/lib/invocation_mirror_patch.dart
index cce75f433e11077532f8779e0a7904a281f0f74f..9669626d906908cc8da76d258c55798276333959 100644
--- a/runtime/lib/invocation_mirror_patch.dart
+++ b/runtime/lib/invocation_mirror_patch.dart
@@ -60,6 +60,10 @@ class _InvocationMirror implements Invocation {
List get positionalArguments {
if (_positionalArguments == null) {
int numPositionalArguments = _argumentsDescriptor[1];
+ // Don't count receiver.
+ if (numPositionalArguments == 1) {
+ return _positionalArguments = const [];
+ }
// Exclude receiver.
_positionalArguments = _arguments.sublist(1, numPositionalArguments);
}
@@ -68,10 +72,13 @@ class _InvocationMirror implements Invocation {
Map<Symbol, dynamic> get namedArguments {
if (_namedArguments == null) {
- _namedArguments = new Map<Symbol, dynamic>();
int numArguments = _argumentsDescriptor[0] - 1; // Exclude receiver.
int numPositionalArguments = _argumentsDescriptor[1] - 1;
int numNamedArguments = numArguments - numPositionalArguments;
+ if (numNamedArguments == 0) {
+ return _namedArguments = const <Symbol, dynamic>{};
+ }
+ _namedArguments = new Map<Symbol, dynamic>();
for (int i = 0; i < numNamedArguments; i++) {
String arg_name = _argumentsDescriptor[2 + 2*i];
var arg_value = _arguments[_argumentsDescriptor[3 + 2*i]];
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698