Skip to content

Commit 34a63b5

Browse files
munificentCommit Queue
authored andcommitted
[private named parameters] Update static error test expectations.
This pins the expected errors down more precisely. It should also fix the failure in initializing_formal_collision_error_test.dart where there are two expected errors on the same line and using "unspecified" confuses the test runner. Change-Id: I44fe14295bb34ea2f836774d1dd24daae2524ebb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465989 Reviewed-by: Kallen Tu <[email protected]> Auto-Submit: Bob Nystrom <[email protected]> Commit-Queue: Kallen Tu <[email protected]>
1 parent b72d2f6 commit 34a63b5

File tree

4 files changed

+99
-98
lines changed

4 files changed

+99
-98
lines changed

tests/language/private_named_parameters/initializing_formal_collision_error_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,55 +15,55 @@ class C {
1515
C.a({required this._foo, required this._foo}) {}
1616
// ^^^^
1717
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_FIELD_FORMAL_PARAMETER
18-
// [cfe] unspecified
18+
// [cfe] '_foo' was already initialized by this constructor.
19+
// [cfe] Duplicated parameter name '_foo'.
1920

2021
// Collide with previous public initializing formal.
2122
C.b({required this.foo, required this._foo}) {}
2223
// ^^^^
2324
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_DUPLICATE_PUBLIC_NAME
24-
// [cfe] unspecified
25+
// [cfe] The corresponding public name 'foo' is already the name of another parameter.
2526

2627
// Collide with later private named.
2728
C.c({required this._foo, String? _foo}) {}
2829
// ^^^^
2930
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
30-
// [cfe] unspecified
31-
// ^^^^
3231
// [analyzer] SYNTACTIC_ERROR.PRIVATE_NAMED_NON_FIELD_PARAMETER
33-
// [cfe] unspecified
32+
// [cfe] A named parameter that doesn't refer to an instance variable can't start with an underscore ('_').
33+
// [cfe] Duplicated parameter name '_foo'.
3434

3535
// Collide with later public named.
3636
C.d({required this._foo, String? foo}) {}
3737
// ^^^^
3838
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_DUPLICATE_PUBLIC_NAME
39-
// [cfe] unspecified
39+
// [cfe] The corresponding public name 'foo' is already the name of another parameter.
4040

4141
// Collide with previous private named.
4242
C.e({String? _foo, required this._foo}) {}
4343
// ^^^^
4444
// [analyzer] SYNTACTIC_ERROR.PRIVATE_NAMED_NON_FIELD_PARAMETER
45-
// [cfe] unspecified
45+
// [cfe] A named parameter that doesn't refer to an instance variable can't start with an underscore ('_').
4646
// ^^^^
4747
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
48-
// [cfe] unspecified
48+
// [cfe] Duplicated parameter name '_foo'.
4949

5050
// Collide with previous public named.
5151
C.f({String? foo, required this._foo}) {}
5252
// ^^^^
5353
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_DUPLICATE_PUBLIC_NAME
54-
// [cfe] unspecified
54+
// [cfe] The corresponding public name 'foo' is already the name of another parameter.
5555

5656
// Collide with previous private positional.
5757
C.g(String _foo, {required this._foo}) {}
5858
// ^^^^
5959
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
60-
// [cfe] unspecified
60+
// [cfe] Duplicated parameter name '_foo'.
6161

6262
// Collide with previous public positional.
6363
C.h(String? foo, {required this._foo}) {}
6464
// ^^^^
6565
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_DUPLICATE_PUBLIC_NAME
66-
// [cfe] unspecified
66+
// [cfe] The corresponding public name 'foo' is already the name of another parameter.
6767
}
6868

6969
void main() {}

tests/language/private_named_parameters/no_corresponding_variable_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
class C {
1111
C({this._unknown});
12-
// ^^^^^^^^
13-
// [analyzer] unspecified
14-
// [cfe] unspecified
12+
// ^^^^^^^^^^^^^
13+
// [analyzer] COMPILE_TIME_ERROR.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD
14+
// ^
15+
// [cfe] '_unknown' isn't an instance field of this class.
1516

1617
// There is a public field with the name, but that isn't what the private
1718
// name refers to.

tests/language/private_named_parameters/public_name_error_test.dart

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
class Empty {
1212
Empty({required this._});
1313
// ^
14-
// [analyzer] unspecified
15-
// [cfe] unspecified
14+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
15+
// [cfe] A private named parameter must have a corresponding public name.
1616

1717
String? _;
1818
}
@@ -21,13 +21,13 @@ class Empty {
2121
class Digit {
2222
Digit({
2323
required this._123,
24-
// ^^^^
25-
// [analyzer] unspecified
26-
// [cfe] unspecified
24+
// ^^^^
25+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
26+
// [cfe] A private named parameter must have a corresponding public name.
2727
required this._1more,
28-
// ^^^^^^
29-
// [analyzer] unspecified
30-
// [cfe] unspecified
28+
// ^^^^^^
29+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
30+
// [cfe] A private named parameter must have a corresponding public name.
3131
});
3232

3333
String? _123;
@@ -40,13 +40,13 @@ class Private {
4040
Private({
4141
required this.__,
4242
// ^^
43-
// [analyzer] unspecified
44-
// [cfe] unspecified
43+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
44+
// [cfe] A private named parameter must have a corresponding public name.
4545

4646
required this.__tooPrivate,
4747
// ^^^^^^^^^^^^
48-
// [analyzer] unspecified
49-
// [cfe] unspecified
48+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
49+
// [cfe] A private named parameter must have a corresponding public name.
5050
});
5151

5252
String? __;
@@ -59,136 +59,136 @@ class Reserved {
5959
Reserved({
6060
required this._assert,
6161
// ^^^^^^^
62-
// [analyzer] unspecified
63-
// [cfe] unspecified
62+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
63+
// [cfe] A private named parameter must have a corresponding public name.
6464
required this._break,
6565
// ^^^^^^
66-
// [analyzer] unspecified
67-
// [cfe] unspecified
66+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
67+
// [cfe] A private named parameter must have a corresponding public name.
6868
required this._case,
6969
// ^^^^^
70-
// [analyzer] unspecified
71-
// [cfe] unspecified
70+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
71+
// [cfe] A private named parameter must have a corresponding public name.
7272
required this._catch,
7373
// ^^^^^^
74-
// [analyzer] unspecified
75-
// [cfe] unspecified
74+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
75+
// [cfe] A private named parameter must have a corresponding public name.
7676
required this._class,
7777
// ^^^^^^
78-
// [analyzer] unspecified
79-
// [cfe] unspecified
78+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
79+
// [cfe] A private named parameter must have a corresponding public name.
8080
required this._const,
8181
// ^^^^^^
82-
// [analyzer] unspecified
83-
// [cfe] unspecified
82+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
83+
// [cfe] A private named parameter must have a corresponding public name.
8484
required this._continue,
8585
// ^^^^^^^^^
86-
// [analyzer] unspecified
87-
// [cfe] unspecified
86+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
87+
// [cfe] A private named parameter must have a corresponding public name.
8888
required this._default,
8989
// ^^^^^^^^
90-
// [analyzer] unspecified
91-
// [cfe] unspecified
90+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
91+
// [cfe] A private named parameter must have a corresponding public name.
9292
required this._do,
9393
// ^^^
94-
// [analyzer] unspecified
95-
// [cfe] unspecified
94+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
95+
// [cfe] A private named parameter must have a corresponding public name.
9696
required this._else,
9797
// ^^^^^
98-
// [analyzer] unspecified
99-
// [cfe] unspecified
98+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
99+
// [cfe] A private named parameter must have a corresponding public name.
100100
required this._enum,
101101
// ^^^^^
102-
// [analyzer] unspecified
103-
// [cfe] unspecified
102+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
103+
// [cfe] A private named parameter must have a corresponding public name.
104104
required this._extends,
105105
// ^^^^^^^^
106-
// [analyzer] unspecified
107-
// [cfe] unspecified
106+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
107+
// [cfe] A private named parameter must have a corresponding public name.
108108
required this._false,
109109
// ^^^^^^
110-
// [analyzer] unspecified
111-
// [cfe] unspecified
110+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
111+
// [cfe] A private named parameter must have a corresponding public name.
112112
required this._final,
113113
// ^^^^^^
114-
// [analyzer] unspecified
115-
// [cfe] unspecified
114+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
115+
// [cfe] A private named parameter must have a corresponding public name.
116116
required this._finally,
117117
// ^^^^^^^^
118-
// [analyzer] unspecified
119-
// [cfe] unspecified
118+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
119+
// [cfe] A private named parameter must have a corresponding public name.
120120
required this._for,
121121
// ^^^^
122-
// [analyzer] unspecified
123-
// [cfe] unspecified
122+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
123+
// [cfe] A private named parameter must have a corresponding public name.
124124
required this._if,
125125
// ^^^
126-
// [analyzer] unspecified
127-
// [cfe] unspecified
126+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
127+
// [cfe] A private named parameter must have a corresponding public name.
128128
required this._in,
129129
// ^^^
130-
// [analyzer] unspecified
131-
// [cfe] unspecified
130+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
131+
// [cfe] A private named parameter must have a corresponding public name.
132132
required this._is,
133133
// ^^^
134-
// [analyzer] unspecified
135-
// [cfe] unspecified
134+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
135+
// [cfe] A private named parameter must have a corresponding public name.
136136
required this._new,
137137
// ^^^^
138-
// [analyzer] unspecified
139-
// [cfe] unspecified
138+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
139+
// [cfe] A private named parameter must have a corresponding public name.
140140
required this._null,
141141
// ^^^^^
142-
// [analyzer] unspecified
143-
// [cfe] unspecified
142+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
143+
// [cfe] A private named parameter must have a corresponding public name.
144144
required this._rethrow,
145145
// ^^^^^^^^
146-
// [analyzer] unspecified
147-
// [cfe] unspecified
146+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
147+
// [cfe] A private named parameter must have a corresponding public name.
148148
required this._return,
149149
// ^^^^^^^
150-
// [analyzer] unspecified
151-
// [cfe] unspecified
150+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
151+
// [cfe] A private named parameter must have a corresponding public name.
152152
required this._super,
153153
// ^^^^^^
154-
// [analyzer] unspecified
155-
// [cfe] unspecified
154+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
155+
// [cfe] A private named parameter must have a corresponding public name.
156156
required this._switch,
157157
// ^^^^^^^
158-
// [analyzer] unspecified
159-
// [cfe] unspecified
158+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
159+
// [cfe] A private named parameter must have a corresponding public name.
160160
required this._this,
161161
// ^^^^^
162-
// [analyzer] unspecified
163-
// [cfe] unspecified
162+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
163+
// [cfe] A private named parameter must have a corresponding public name.
164164
required this._throw,
165165
// ^^^^^^
166-
// [analyzer] unspecified
167-
// [cfe] unspecified
166+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
167+
// [cfe] A private named parameter must have a corresponding public name.
168168
required this._true,
169169
// ^^^^^
170-
// [analyzer] unspecified
171-
// [cfe] unspecified
170+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
171+
// [cfe] A private named parameter must have a corresponding public name.
172172
required this._try,
173173
// ^^^^
174-
// [analyzer] unspecified
175-
// [cfe] unspecified
174+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
175+
// [cfe] A private named parameter must have a corresponding public name.
176176
required this._var,
177177
// ^^^^
178-
// [analyzer] unspecified
179-
// [cfe] unspecified
178+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
179+
// [cfe] A private named parameter must have a corresponding public name.
180180
required this._void,
181181
// ^^^^^
182-
// [analyzer] unspecified
183-
// [cfe] unspecified
182+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
183+
// [cfe] A private named parameter must have a corresponding public name.
184184
required this._while,
185185
// ^^^^^^
186-
// [analyzer] unspecified
187-
// [cfe] unspecified
186+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
187+
// [cfe] A private named parameter must have a corresponding public name.
188188
required this._with,
189189
// ^^^^^
190-
// [analyzer] unspecified
191-
// [cfe] unspecified
190+
// [analyzer] COMPILE_TIME_ERROR.PRIVATE_NAMED_PARAMETER_WITHOUT_PUBLIC_NAME
191+
// [cfe] A private named parameter must have a corresponding public name.
192192
});
193193

194194
String? _assert;

tests/language/private_named_parameters/wrong_parameter_kind_error_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ class C {
1111
// In a generative constructor, but not an initializing formal.
1212
C({int? _notInitializingFormal});
1313
// ^^^^^^^^^^^^^^^^^^^^^^
14-
// [analyzer] unspecified
15-
// [cfe] unspecified
14+
// [analyzer] SYNTACTIC_ERROR.PRIVATE_NAMED_NON_FIELD_PARAMETER
15+
// [cfe] A named parameter that doesn't refer to an instance variable can't start with an underscore ('_').
1616

1717
// In a factory constructor.
1818
factory C.fact({int? _inFactory}) => throw '!';
1919
// ^^^^^^^^^^
20-
// [analyzer] unspecified
21-
// [cfe] unspecified
20+
// [analyzer] SYNTACTIC_ERROR.PRIVATE_NAMED_NON_FIELD_PARAMETER
21+
// [cfe] A named parameter that doesn't refer to an instance variable can't start with an underscore ('_').
2222
}
2323

2424
// In a non-constructor function.
2525
void function({int? _parameter}) {}
2626
// ^^^^^^^^^^
27-
// [analyzer] unspecified
28-
// [cfe] unspecified
27+
// [analyzer] SYNTACTIC_ERROR.PRIVATE_NAMED_NON_FIELD_PARAMETER
28+
// [cfe] A named parameter that doesn't refer to an instance variable can't start with an underscore ('_').
2929

3030
void main() {}

0 commit comments

Comments
 (0)