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

Unified Diff: pkg/analyzer/test/dart/element/builder_test.dart

Issue 2437793002: Handle default formal parameters in LocalElementBuilder (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/builder.dart ('k') | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/dart/element/builder_test.dart
diff --git a/pkg/analyzer/test/dart/element/builder_test.dart b/pkg/analyzer/test/dart/element/builder_test.dart
index 7623aa0626f801255b43cd86c93219426d856eb9..db35770a4db562655c8d506d51c070a1958a848e 100644
--- a/pkg/analyzer/test/dart/element/builder_test.dart
+++ b/pkg/analyzer/test/dart/element/builder_test.dart
@@ -971,6 +971,32 @@ main() {
expect(variableElement.initializer, isNotNull);
}
+ void test_visitDefaultFormalParameter_local() {
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit('''
+main() {
+ f({bool b: false}) {}
+}
+''');
+ var mainAst = unit.declarations.single as FunctionDeclaration;
+ // Build API elements.
+ FunctionElementImpl main;
+ {
+ ElementHolder holder = new ElementHolder();
+ unit.accept(new ApiElementBuilder(holder, compilationUnitElement));
+ main = holder.functions.single as FunctionElementImpl;
+ }
+ // Build local elements in body.
+ ElementHolder holder = new ElementHolder();
+ FunctionBody mainBody = mainAst.functionExpression.body;
+ mainBody.accept(new LocalElementBuilder(holder, compilationUnitElement));
+ main.functions = holder.functions;
+ main.localVariables = holder.localVariables;
+ expect(main.functions, hasLength(1));
+ FunctionElement f = main.functions[0];
+ expect(f.parameters, hasLength(1));
+ expect(f.parameters[0].initializer, isNotNull);
+ }
+
void test_visitVariableDeclaration_local() {
var holder = buildElementsForText('class C { m() { T v = null; } }');
List<LocalVariableElement> variableElements = holder.localVariables;
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/builder.dart ('k') | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698