Chromium Code Reviews| Index: frog/leg/resolver.dart |
| diff --git a/frog/leg/resolver.dart b/frog/leg/resolver.dart |
| index 2f564394d28a2b3aa8c0d88f868f494148560d7e..8cb91fbbc0b405fc103401efe3feb87ca5f80420 100644 |
| --- a/frog/leg/resolver.dart |
| +++ b/frog/leg/resolver.dart |
| @@ -369,6 +369,9 @@ class InitializerResolver { |
| } |
| if (validTarget) { |
| + // Resolve the arguments of the call to get a selector. |
|
ngeoffray
2012/02/24 13:43:01
This is not just for getting a selector, but also
|
| + visitor.inStaticContext( () => visitor.handleArguments(call) ); |
| + // Lookup constructor and try to match it to the selector. |
| ResolverTask resolver = visitor.compiler.resolver; |
| result = resolver.lookupConstructor(lookupTarget, call); |
| if (result === null) { |
| @@ -380,19 +383,14 @@ class InitializerResolver { |
| error(call, MessageKind.CANNOT_RESOLVE_CONSTRUCTOR, [name]); |
| } else { |
| final Compiler compiler = visitor.compiler; |
| + Selector selector = visitor.mapping.getSelector(call); |
| // TODO(karlklose): support optional arguments. |
| - if (result.parameterCount(compiler) != call.argumentCount()) { |
| + if (!selector.applies(compiler, result)) { |
| error(call, MessageKind.NO_MATCHING_CONSTRUCTOR); |
| } |
| } |
| visitor.useElement(call, result); |
| } |
| - // Resolve the arguments of the call. |
| - for (Link<Node> arguments = call.arguments; |
| - !arguments.isEmpty(); |
| - arguments = arguments.tail) { |
| - visitor.visitInStaticContext(arguments.head); |
| - } |
| return result; |
| } |
| @@ -555,13 +553,17 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| return result; |
| } |
| - visitInStaticContext(Node node) { |
| + inStaticContext(action()) { |
| bool wasInstanceContext = inInstanceContext; |
| inInstanceContext = false; |
| - visit(node); |
| + action(); |
| inInstanceContext = wasInstanceContext; |
| } |
| + visitInStaticContext(Node node) { |
| + inStaticContext(() => visit(node)); |
| + } |
| + |
| visitIdentifier(Identifier node) { |
| if (node.isThis()) { |
| if (!inInstanceContext) { |