| Index: sdk/lib/_internal/js_runtime/lib/js_helper.dart
|
| diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
|
| index f522a7703d916b017dedb9394b759673a92b219c..fd53e61d99b7ad7c47fd318e0d17b1e6c233ea5e 100644
|
| --- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
|
| +++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
|
| @@ -1256,14 +1256,16 @@ class Primitives {
|
| return functionNoSuchMethod(function, arguments, namedArguments);
|
| }
|
|
|
| - var defaultValues = JS('var', r'#[#]', function,
|
| + var defaultValuesClosure = JS('var', r'#[#]', function,
|
| JS_GET_NAME(JsGetName.DEFAULT_VALUES_PROPERTY));
|
| - if (JS('bool', 'typeof # == "function"', defaultValues)) {
|
| - // Anonymous closures return a function that returns the default values
|
| - // instead of providing the default values directly.
|
| - defaultValues = JS('', '#()', defaultValues);
|
| - }
|
| - bool acceptsOptionalArguments = defaultValues != null;
|
| +
|
| + bool acceptsOptionalArguments = defaultValuesClosure != null;
|
| +
|
| + // Default values are stored inside a JavaScript closure to avoid
|
| + // accessing them too early.
|
| + var defaultValues = acceptsOptionalArguments
|
| + ? JS('', '#()', defaultValuesClosure)
|
| + : null;
|
|
|
| var interceptor = getInterceptor(function);
|
| var jsFunction = JS('', '#[#]', interceptor,
|
|
|