Fix handling of default formal parameters in DeclarationResolver.

When visiting a DefaultFormalParameter, we can't call
super.visitDefaultFormalParameter, because that would cause the
default value to be visited twice.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2438113002 .
This commit is contained in:
Paul Berry 2016-10-20 12:34:16 -07:00
parent 78ed4066c8
commit 74d8298777
2 changed files with 2 additions and 1 deletions

View file

@ -126,7 +126,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
});
}
_walk(new ElementWalker.forParameter(element), () {
super.visitDefaultFormalParameter(node);
node.parameter.accept(this);
});
_resolveMetadata(node, node.metadata, element);
return null;

View file

@ -2475,6 +2475,7 @@ void topLevelFunctionWithLocalFunction() {
}
void functionWithGenericFunctionTypedParam/*<S>*/(/*=T*/ pf/*<T>*/(/*=T*/ e)) {}
void functionWithClosureAsDefaultParam([x = () => null]) {}
''');
context.resolveCompilationUnit2(source, source);
LibraryElement firstElement = context.computeLibraryElement(source);