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

Unified Diff: pkg/analyzer/test/generated/simple_resolver_test.dart

Issue 2335693002: Add support for accessing field formal parameters in the initializer list of constructors (Closed)
Patch Set: Clean up Created 4 years, 3 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/test/generated/compile_time_error_code_test.dart ('k') | pkg/analyzer_cli/lib/src/driver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/simple_resolver_test.dart
diff --git a/pkg/analyzer/test/generated/simple_resolver_test.dart b/pkg/analyzer/test/generated/simple_resolver_test.dart
index 1de9a0c70a8acb67e32cf701604f30a0922ad89e..9431deaeb75a1a5ef6606d3650fe1e60507fc6c4 100644
--- a/pkg/analyzer/test/generated/simple_resolver_test.dart
+++ b/pkg/analyzer/test/generated/simple_resolver_test.dart
@@ -656,11 +656,29 @@ class A {
}
void test_fieldFormalParameter() {
+ AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ options.enableInitializingFormalAccess = true;
+ resetWithOptions(options);
Source source = addSource(r'''
class A {
int x;
- A(this.x) {}
+ int y;
+ A(this.x) : y = x {}
}''');
+ CompilationUnit unit =
+ analysisContext2.resolveCompilationUnit2(source, source);
+ ClassDeclaration classA = unit.declarations[0];
+ FieldDeclaration field = classA.members[0];
+ ConstructorDeclaration constructor = classA.members[2];
+ ParameterElement paramElement =
+ constructor.parameters.parameters[0].element;
+ expect(paramElement, new isInstanceOf<FieldFormalParameterElement>());
+ expect((paramElement as FieldFormalParameterElement).field,
+ field.fields.variables[0].element);
+ ConstructorFieldInitializer initializer = constructor.initializers[0];
+ SimpleIdentifier identifierX = initializer.expression;
+ expect(identifierX.staticElement, paramElement);
+
computeLibrarySourceErrors(source);
assertNoErrors(source);
verify([source]);
« no previous file with comments | « pkg/analyzer/test/generated/compile_time_error_code_test.dart ('k') | pkg/analyzer_cli/lib/src/driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698