@@ -62,6 +62,20 @@ void f(final List<int> x) {
62
62
]);
63
63
}
64
64
65
+ test_closure_wildcard () async {
66
+ await assertNoDiagnostics (r'''
67
+ var f = (Object _) { };
68
+ ''' );
69
+ }
70
+
71
+ test_constructor_unused_wildcard () async {
72
+ await assertNoDiagnostics (r'''
73
+ class C {
74
+ C(String _);
75
+ }
76
+ ''' );
77
+ }
78
+
65
79
test_constructor_usedInBody () async {
66
80
await assertDiagnostics (r'''
67
81
class C {
@@ -158,6 +172,22 @@ class C {
158
172
''' );
159
173
}
160
174
175
+ test_method_wildcard () async {
176
+ await assertNoDiagnostics (r'''
177
+ class C {
178
+ void m(String _) { }
179
+ }
180
+ ''' );
181
+ }
182
+
183
+ test_method_wildcard_final () async {
184
+ await assertNoDiagnostics (r'''
185
+ class C {
186
+ void m(final String _) { }
187
+ }
188
+ ''' );
189
+ }
190
+
161
191
test_operator () async {
162
192
await assertDiagnostics (r'''
163
193
class C {
@@ -180,6 +210,16 @@ class C {
180
210
''' );
181
211
}
182
212
213
+ test_operator_wildcard () async {
214
+ await assertNoDiagnostics (r'''
215
+ class C {
216
+ C operator +(C _) {
217
+ return this;
218
+ }
219
+ }
220
+ ''' );
221
+ }
222
+
183
223
test_recordPattern_destructured () async {
184
224
await assertNoDiagnostics (r'''
185
225
void f(int a, int b) {
@@ -208,6 +248,14 @@ class C {
208
248
''' );
209
249
}
210
250
251
+ test_setter_wildcard () async {
252
+ await assertNoDiagnostics (r'''
253
+ class C {
254
+ void set f(int _) { }
255
+ }
256
+ ''' );
257
+ }
258
+
211
259
test_superParameter () async {
212
260
await assertNoDiagnostics ('''
213
261
class D {
@@ -274,6 +322,16 @@ void f({final String? p}) {
274
322
''' );
275
323
}
276
324
325
+ test_topLevelFunction_named_wildcard () async {
326
+ await assertDiagnostics (r'''
327
+ void f({final String? _}) { }
328
+ ''' , [
329
+ // No lint.
330
+ // https://github.com/dart-lang/language/blob/main/working/wildcards/feature-specification.md#declarations-that-are-capable-of-declaring-a-wildcard
331
+ error (CompileTimeErrorCode .PRIVATE_OPTIONAL_PARAMETER , 22 , 1 ),
332
+ ]);
333
+ }
334
+
277
335
test_topLevelFunction_namedRequired () async {
278
336
await assertDiagnostics (r'''
279
337
void f({required String p}) {
@@ -292,6 +350,16 @@ void f({required final String p}) {
292
350
''' );
293
351
}
294
352
353
+ test_topLevelFunction_namedRequired_wildcard () async {
354
+ await assertDiagnostics (r'''
355
+ void f({required String _}) { }
356
+ ''' , [
357
+ // No lint.
358
+ // https://github.com/dart-lang/language/blob/main/working/wildcards/feature-specification.md#declarations-that-are-capable-of-declaring-a-wildcard
359
+ error (CompileTimeErrorCode .PRIVATE_OPTIONAL_PARAMETER , 24 , 1 ),
360
+ ]);
361
+ }
362
+
295
363
test_topLevelFunction_optional () async {
296
364
await assertDiagnostics (r'''
297
365
void f([String? p]) {
@@ -307,6 +375,18 @@ void f([String? p]) {
307
375
void f([final String? p]) {
308
376
print(p);
309
377
}
378
+ ''' );
379
+ }
380
+
381
+ test_topLevelFunction_optional_wildcard () async {
382
+ await assertNoDiagnostics (r'''
383
+ void f([String? _]) { }
384
+ ''' );
385
+ }
386
+
387
+ test_topLevelFunction_wildcard () async {
388
+ await assertNoDiagnostics (r'''
389
+ void f(int _){ }
310
390
''' );
311
391
}
312
392
}
0 commit comments