@@ -1146,20 +1146,47 @@ class Primitives {
1146
1146
1147
1147
static applyFunctionWithPositionalArguments (Function function,
1148
1148
List positionalArguments) {
1149
- int argumentCount = 0 ;
1150
1149
List arguments;
1151
1150
1152
1151
if (positionalArguments != null ) {
1153
1152
if (JS ('bool' , '# instanceof Array' , positionalArguments)) {
1154
- arguments = positionalArguments;
1153
+ arguments = JS ( 'JSArray' , '#' , positionalArguments) ;
1155
1154
} else {
1156
1155
arguments = new List .from (positionalArguments);
1157
1156
}
1158
- argumentCount = JS ('int' , '#.length' , arguments);
1159
1157
} else {
1160
1158
arguments = [];
1161
1159
}
1162
1160
1161
+ if (arguments.length == 0 ) {
1162
+ String selectorName = JS_GET_NAME (JsGetName .CALL_PREFIX0 );
1163
+ if (JS ('bool' , '!!#[#]' , function, selectorName)) {
1164
+ return JS ('' , '#[#]()' , function, selectorName);
1165
+ }
1166
+ } else if (arguments.length == 1 ) {
1167
+ String selectorName = JS_GET_NAME (JsGetName .CALL_PREFIX1 );
1168
+ if (JS ('bool' , '!!#[#]' , function, selectorName)) {
1169
+ return JS ('' , '#[#](#[0])' , function, selectorName, arguments);
1170
+ }
1171
+ } else if (arguments.length == 2 ) {
1172
+ String selectorName = JS_GET_NAME (JsGetName .CALL_PREFIX2 );
1173
+ if (JS ('bool' , '!!#[#]' , function, selectorName)) {
1174
+ return JS ('' , '#[#](#[0],#[1])' , function, selectorName,
1175
+ arguments, arguments);
1176
+ }
1177
+ } else if (arguments.length == 3 ) {
1178
+ String selectorName = JS_GET_NAME (JsGetName .CALL_PREFIX3 );
1179
+ if (JS ('bool' , '!!#[#]' , function, selectorName)) {
1180
+ return JS ('' , '#[#](#[0],#[1],#[2])' , function, selectorName,
1181
+ arguments, arguments, arguments);
1182
+ }
1183
+ }
1184
+ return _genericApplyFunctionWithPositionalArguments (function, arguments);
1185
+ }
1186
+
1187
+ static _genericApplyFunctionWithPositionalArguments (Function function,
1188
+ List arguments) {
1189
+ int argumentCount = arguments.length;
1163
1190
String selectorName =
1164
1191
'${JS_GET_NAME (JsGetName .CALL_PREFIX )}\$ $argumentCount ' ;
1165
1192
var jsFunction = JS ('var' , '#[#]' , function, selectorName);
@@ -1168,7 +1195,7 @@ class Primitives {
1168
1195
jsFunction = JS ('' , '#["call*"]' , interceptor);
1169
1196
1170
1197
if (jsFunction == null ) {
1171
- return functionNoSuchMethod (function, positionalArguments , null );
1198
+ return functionNoSuchMethod (function, arguments , null );
1172
1199
}
1173
1200
ReflectionInfo info = new ReflectionInfo (jsFunction);
1174
1201
int requiredArgumentCount = info.requiredParameterCount;
@@ -1177,7 +1204,7 @@ class Primitives {
1177
1204
if (info.areOptionalParametersNamed ||
1178
1205
requiredArgumentCount > argumentCount ||
1179
1206
maxArgumentCount < argumentCount) {
1180
- return functionNoSuchMethod (function, positionalArguments , null );
1207
+ return functionNoSuchMethod (function, arguments , null );
1181
1208
}
1182
1209
arguments = new List .from (arguments);
1183
1210
for (int pos = argumentCount; pos < maxArgumentCount; pos++ ) {
0 commit comments