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

Unified Diff: pkg/analyzer/test/generated/compile_time_error_code_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/lib/src/task/options.dart ('k') | pkg/analyzer/test/generated/simple_resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/compile_time_error_code_test.dart
diff --git a/pkg/analyzer/test/generated/compile_time_error_code_test.dart b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
index f506339294f0238d2b175fb48cd34fed394a534b..71b0aef83027337e263197b20cbc7ca458217123 100644
--- a/pkg/analyzer/test/generated/compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
@@ -1800,6 +1800,17 @@ class A {
verify([source]);
}
+ void test_duplicateDefinition_parameters_inConstructor() {
+ Source source = addSource(r'''
+class A {
+ int a;
+ A(int a, this.a);
+}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
+ verify([source]);
+ }
+
void test_duplicateDefinition_parameters_inFunctionTypeAlias() {
Source source = addSource(r'''
typedef F(int a, double a);
@@ -2152,6 +2163,18 @@ class B extends A {
verify([source]);
}
+ void test_fieldFormalParameter_assignedInInitializer() {
+ Source source = addSource(r'''
+class A {
+ int x;
+ A(this.x) : x = 3 {}
+}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source,
+ [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
+ verify([source]);
+ }
+
void test_fieldInitializedByMultipleInitializers() {
Source source = addSource(r'''
class A {
@@ -2334,6 +2357,7 @@ class A {
A(this.x, this.x) {}
}''');
computeLibrarySourceErrors(source);
+ // TODO(brianwilkerson) There should only be one error here.
assertErrors(source, [
CompileTimeErrorCode.DUPLICATE_DEFINITION,
CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES
« no previous file with comments | « pkg/analyzer/lib/src/task/options.dart ('k') | pkg/analyzer/test/generated/simple_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698