@@ -178,134 +178,6 @@ f(p) { return const A(p); }
178
178
]);
179
179
}
180
180
181
- test_constWithNonType () async {
182
- await assertErrorsInCode (r'''
183
- int A;
184
- f() {
185
- return const A();
186
- }
187
- ''' , [
188
- error (CompileTimeErrorCode .CONST_WITH_NON_TYPE , 28 , 1 ),
189
- ]);
190
- }
191
-
192
- test_constWithNonType_fromLibrary () async {
193
- newFile ('/test/lib/lib1.dart' );
194
- await assertErrorsInCode ('''
195
- import 'lib1.dart' as lib;
196
- void f() {
197
- const lib.A();
198
- }
199
- ''' , [
200
- error (CompileTimeErrorCode .CONST_WITH_NON_TYPE , 50 , 1 ),
201
- ]);
202
- }
203
-
204
- test_constWithTypeParameters_direct () async {
205
- await assertErrorsInCode (r'''
206
- class A<T> {
207
- static const V = const A<T>();
208
- const A();
209
- }
210
- ''' , [
211
- error (CompileTimeErrorCode .TYPE_PARAMETER_REFERENCED_BY_STATIC , 40 , 1 ),
212
- error (CompileTimeErrorCode .CONST_WITH_TYPE_PARAMETERS , 40 , 1 ),
213
- ]);
214
- }
215
-
216
- test_constWithTypeParameters_indirect () async {
217
- await assertErrorsInCode (r'''
218
- class A<T> {
219
- static const V = const A<List<T>>();
220
- const A();
221
- }
222
- ''' , [
223
- error (CompileTimeErrorCode .CONST_WITH_TYPE_PARAMETERS , 45 , 1 ),
224
- error (CompileTimeErrorCode .TYPE_PARAMETER_REFERENCED_BY_STATIC , 45 , 1 ),
225
- ]);
226
- }
227
-
228
- test_constWithUndefinedConstructor () async {
229
- await assertErrorsInCode (r'''
230
- class A {
231
- const A();
232
- }
233
- f() {
234
- return const A.noSuchConstructor();
235
- }
236
- ''' , [
237
- error (CompileTimeErrorCode .CONST_WITH_UNDEFINED_CONSTRUCTOR , 48 , 17 ),
238
- ]);
239
- }
240
-
241
- test_constWithUndefinedConstructorDefault () async {
242
- await assertErrorsInCode (r'''
243
- class A {
244
- const A.name();
245
- }
246
- f() {
247
- return const A();
248
- }
249
- ''' , [
250
- error (
251
- CompileTimeErrorCode .CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT , 51 , 1 ),
252
- ]);
253
- }
254
-
255
- test_extraPositionalArguments_const () async {
256
- await assertErrorsInCode (r'''
257
- class A {
258
- const A();
259
- }
260
- main() {
261
- const A(0);
262
- }
263
- ''' , [
264
- error (CompileTimeErrorCode .EXTRA_POSITIONAL_ARGUMENTS , 43 , 3 ),
265
- ]);
266
- }
267
-
268
- test_extraPositionalArguments_const_super () async {
269
- await assertErrorsInCode (r'''
270
- class A {
271
- const A();
272
- }
273
- class B extends A {
274
- const B() : super(0);
275
- }
276
- ''' , [
277
- error (CompileTimeErrorCode .EXTRA_POSITIONAL_ARGUMENTS , 64 , 3 ),
278
- ]);
279
- }
280
-
281
- test_extraPositionalArgumentsCouldBeNamed_const () async {
282
- await assertErrorsInCode (r'''
283
- class A {
284
- const A({int x});
285
- }
286
- main() {
287
- const A(0);
288
- }
289
- ''' , [
290
- error (CompileTimeErrorCode .EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED , 50 ,
291
- 3 ),
292
- ]);
293
- }
294
-
295
- test_extraPositionalArgumentsCouldBeNamed_const_super () async {
296
- await assertErrorsInCode (r'''
297
- class A {
298
- const A({int x});
299
- }
300
- class B extends A {
301
- const B() : super(0);
302
- }
303
- ''' , [
304
- error (CompileTimeErrorCode .EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED , 71 ,
305
- 3 ),
306
- ]);
307
- }
308
-
309
181
test_fromEnvironment_bool_badArgs () async {
310
182
await assertErrorsInCode (r'''
311
183
var b1 = const bool.fromEnvironment(1);
@@ -359,80 +231,13 @@ main() { new C().f(<S>(S s) => s); }
359
231
]);
360
232
}
361
233
362
- test_genericFunctionTypeAsBound_class () async {
363
- await assertErrorsInCode (r'''
364
- class C<T extends S Function<S>(S)> {
365
- }
366
- ''' , [
367
- error (CompileTimeErrorCode .GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND , 18 , 16 ),
368
- ]);
369
- }
370
-
371
- test_genericFunctionTypeAsBound_genericFunction () async {
372
- await assertErrorsInCode (r'''
373
- T Function<T extends S Function<S>(S)>(T) fun;
374
- ''' , [
375
- error (CompileTimeErrorCode .GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND , 21 , 16 ),
376
- ]);
377
- }
378
-
379
- test_genericFunctionTypeAsBound_genericFunctionTypedef () async {
380
- await assertErrorsInCode (r'''
381
- typedef foo = T Function<T extends S Function<S>(S)>(T t);
382
- ''' , [
383
- error (CompileTimeErrorCode .GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND , 35 , 16 ),
384
- ]);
385
- }
386
-
387
- test_genericFunctionTypeAsBound_parameterOfFunction () async {
388
- await assertNoErrorsInCode (r'''
389
- class C<T extends void Function(S Function<S>(S))> {}
390
- ''' );
391
- }
392
-
393
- test_genericFunctionTypeAsBound_typedef () async {
394
- await assertErrorsInCode (r'''
395
- typedef T foo<T extends S Function<S>(S)>(T t);
396
- ''' , [
397
- error (CompileTimeErrorCode .GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND , 24 , 16 ),
398
- ]);
399
- }
400
-
401
234
test_genericFunctionTypedParameter () async {
402
235
var code = '''
403
236
void g(T f<T>(T x)) {}
404
237
''' ;
405
238
await assertNoErrorsInCode (code);
406
239
}
407
240
408
- test_importInternalLibrary () async {
409
- // Note, in these error cases we may generate an UNUSED_IMPORT hint, while
410
- // we could prevent the hint from being generated by testing the import
411
- // directive for the error, this is such a minor corner case that we don't
412
- // think we should add the additional computation time to figure out such
413
- // cases.
414
- await assertErrorsInCode ('''
415
- import 'dart:_interceptors';
416
- ''' , [
417
- error (CompileTimeErrorCode .IMPORT_INTERNAL_LIBRARY , 7 , 20 ),
418
- error (HintCode .UNUSED_IMPORT , 7 , 20 ),
419
- ]);
420
- }
421
-
422
- test_importOfNonLibrary () async {
423
- newFile ("/test/lib/part.dart" , content: r'''
424
- part of lib;
425
- class A{}
426
- ''' );
427
- await assertErrorsInCode (r'''
428
- library lib;
429
- import 'part.dart';
430
- A a;
431
- ''' , [
432
- error (CompileTimeErrorCode .IMPORT_OF_NON_LIBRARY , 20 , 11 ),
433
- ]);
434
- }
435
-
436
241
test_length_of_erroneous_constant () async {
437
242
// Attempting to compute the length of constant that couldn't be evaluated
438
243
// (due to an error) should not crash the analyzer (see dartbug.com/23383)
0 commit comments