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

Unified Diff: tool/input_sdk/private/ddc_runtime/operations.dart

Issue 2201973002: fix optional params to mock methods, allow all signatures (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: fix getters and setters Created 4 years, 5 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
Index: tool/input_sdk/private/ddc_runtime/operations.dart
diff --git a/tool/input_sdk/private/ddc_runtime/operations.dart b/tool/input_sdk/private/ddc_runtime/operations.dart
index dac14e90d76832b7281c1d6b641a81cc36c4cecb..a7b02e51d934b8fdc7c8418546c24cdc1d6ba5f0 100644
--- a/tool/input_sdk/private/ddc_runtime/operations.dart
+++ b/tool/input_sdk/private/ddc_runtime/operations.dart
@@ -92,20 +92,28 @@ _checkApply(type, actuals) => JS('', '''(() => {
Symbol _dartSymbol(name) =>
JS('', '#(#.new(#.toString()))', const_, Symbol, name);
+/// Extracts the named argument array from a list of arguments, and returns it.
// TODO(jmesserly): we need to handle named arguments better.
+extractNamedArgs(args) {
+ if (JS('bool', '#.length > 0', args)) {
+ var last = JS('', '#[#.length - 1]', args, args);
+ if (JS('bool', '# != null && #.__proto__ === Object.prototype',
+ last, last)) {
+ return JS('', '#.pop()', args);
+ }
+ }
+ return null;
+}
+
_checkAndCall(f, ftype, obj, typeArgs, args, name) => JS('', '''(() => {
$_trackCall($obj, $name);
let originalTarget = obj === void 0 ? f : obj;
function callNSM() {
- let namedArgs = null;
- if (args.length > 0 &&
- args[args.length - 1].__proto__ == Object.prototype) {
- namedArgs = args.pop();
- }
return $noSuchMethod(originalTarget, new $InvocationImpl(
- $name, $args, {namedArguments: namedArgs, isMethod: true}));
+ $name, $args,
+ {namedArguments: $extractNamedArgs($args), isMethod: true}));
}
if (!($f instanceof Function)) {
// We're not a function (and hence not a method either)

Powered by Google App Engine
This is Rietveld 408576698