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

Unified Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 930093002: Support positional optional parameters even if stubs are missing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | tests/corelib/apply4_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
index b1705388bd0b3cd0032f832cf4e66c74dea001a6..a481ff77c4656a9ff81a6a4b78b298adb4e85970 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
@@ -1077,11 +1077,22 @@ class Primitives {
String selectorName = '${JS_GET_NAME("CALL_PREFIX")}\$$argumentCount';
var jsFunction = JS('var', '#[#]', function, selectorName);
if (jsFunction == null) {
+ var interceptor = getInterceptor(function);
+ jsFunction = JS('', '#["call*"]', interceptor);
- // TODO(ahe): This might occur for optional arguments if there is no call
- // selector with that many arguments.
-
- return functionNoSuchMethod(function, positionalArguments, null);
+ if (jsFunction == null) {
+ return functionNoSuchMethod(function, positionalArguments, null);
+ }
+ ReflectionInfo info = new ReflectionInfo(jsFunction);
+ int maxArgumentCount = info.requiredParameterCount +
+ info.optionalParameterCount;
+ if (info.areOptionalParametersNamed || maxArgumentCount < argumentCount) {
+ return functionNoSuchMethod(function, positionalArguments, null);
+ }
+ arguments = new List.from(arguments);
+ for (int pos = argumentCount; pos < maxArgumentCount; pos++) {
+ arguments.add(info.defaultValue(pos));
+ }
}
// We bound 'this' to [function] because of how we compile
// closures: escaped local variables are stored and accessed through
« no previous file with comments | « no previous file | tests/corelib/apply4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698