| Index: pkg/compiler/lib/src/universe/universe.dart
|
| diff --git a/pkg/compiler/lib/src/universe/universe.dart b/pkg/compiler/lib/src/universe/universe.dart
|
| index 3deffcba75cd27966bafcbcc8b0126afc809a713..a7ddbb03bd91dbda5eafd2af2d45e2c0c780f12d 100644
|
| --- a/pkg/compiler/lib/src/universe/universe.dart
|
| +++ b/pkg/compiler/lib/src/universe/universe.dart
|
| @@ -506,7 +506,49 @@ class Selector {
|
| *
|
| * Invariant: [element] must be the implementation element.
|
| */
|
| - /*<T>*/ List/*<T>*/ makeArgumentsList(
|
| + /*<S, T>*/ List/*<T>*/ makeArgumentsList(
|
| + FunctionElement element,
|
| + List/*<T>*/ compiledArguments,
|
| + /*T*/ compileDefaultValue(ParameterElement element)) {
|
| + assert(invariant(element, element.isImplementation));
|
| + List/*<T>*/ result = new List();
|
| + FunctionSignature parameters = element.functionSignature;
|
| + int i = 0;
|
| + parameters.forEachRequiredParameter((ParameterElement element) {
|
| + result.add(compiledArguments[i]);
|
| + ++i;
|
| + });
|
| +
|
| + if (!parameters.optionalParametersAreNamed) {
|
| + parameters.forEachOptionalParameter((ParameterElement element) {
|
| + if (i < compiledArguments.length) {
|
| + result.add(compiledArguments[i]);
|
| + ++i;
|
| + } else {
|
| + result.add(compileDefaultValue(element));
|
| + }
|
| + });
|
| + } else {
|
| + int offset = i;
|
| + // Iterate over the optional parameters of the signature, and try to
|
| + // find them in [compiledNamedArguments]. If found, we use the
|
| + // value in the temporary list, otherwise the default value.
|
| + parameters.orderedOptionalParameters
|
| + .forEach((ParameterElement element) {
|
| + int foundIndex = namedArguments.indexOf(element.name);
|
| + if (foundIndex != -1) {
|
| + result.add(compiledArguments[offset + foundIndex]);
|
| + } else {
|
| + result.add(compileDefaultValue(element));
|
| + }
|
| + });
|
| + }
|
| + return result;
|
| + }
|
| +
|
| + /// This is a version of [makeArgumentsList] that works for a `Link`
|
| + /// representation of arguments.
|
| + /*<T>*/ List/*<T>*/ makeArgumentsList2(
|
| Link<Node> arguments,
|
| FunctionElement element,
|
| /*T*/ compileArgument(Node argument),
|
| @@ -551,6 +593,7 @@ class Selector {
|
| return result;
|
| }
|
|
|
| +
|
| /**
|
| * Fills [list] with the arguments in the order expected by
|
| * [callee], and where [caller] is a synthesized element
|
| @@ -618,10 +661,10 @@ class Selector {
|
| namedParameters);
|
|
|
| if (!selector.applies(callee, world)) return false;
|
| - list.addAll(selector.makeArgumentsList(nodes,
|
| - callee,
|
| - internalCompileArgument,
|
| - compileConstant));
|
| + list.addAll(selector.makeArgumentsList2(nodes,
|
| + callee,
|
| + internalCompileArgument,
|
| + compileConstant));
|
|
|
| return true;
|
| }
|
|
|