From 74d8298777edeac7cc6a714156b255ec481324f8 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Thu, 20 Oct 2016 12:34:16 -0700 Subject: [PATCH] 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 . --- pkg/analyzer/lib/src/generated/declaration_resolver.dart | 2 +- pkg/analyzer/test/src/context/context_test.dart | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/analyzer/lib/src/generated/declaration_resolver.dart b/pkg/analyzer/lib/src/generated/declaration_resolver.dart index a6b8a13998f..df4afc29c81 100644 --- a/pkg/analyzer/lib/src/generated/declaration_resolver.dart +++ b/pkg/analyzer/lib/src/generated/declaration_resolver.dart @@ -126,7 +126,7 @@ class DeclarationResolver extends RecursiveAstVisitor { }); } _walk(new ElementWalker.forParameter(element), () { - super.visitDefaultFormalParameter(node); + node.parameter.accept(this); }); _resolveMetadata(node, node.metadata, element); return null; diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart index 83de70da6e1..19352ab88d4 100644 --- a/pkg/analyzer/test/src/context/context_test.dart +++ b/pkg/analyzer/test/src/context/context_test.dart @@ -2475,6 +2475,7 @@ void topLevelFunctionWithLocalFunction() { } void functionWithGenericFunctionTypedParam/**/(/*=T*/ pf/**/(/*=T*/ e)) {} +void functionWithClosureAsDefaultParam([x = () => null]) {} '''); context.resolveCompilationUnit2(source, source); LibraryElement firstElement = context.computeLibraryElement(source);