|
4 | 4 |
|
5 | 5 | import 'package:analyzer/file_system/file_system.dart';
|
6 | 6 | import 'package:analyzer/src/error/codes.dart';
|
| 7 | +import 'package:analyzer/src/generated/parser.dart'; |
7 | 8 | import 'package:analyzer/utilities/package_config_file_builder.dart';
|
8 | 9 | import 'package:test_reflective_loader/test_reflective_loader.dart';
|
9 | 10 |
|
@@ -688,6 +689,31 @@ import 'package:aaa/a.dart';
|
688 | 689 | );
|
689 | 690 | }
|
690 | 691 |
|
| 692 | + test_incorrectlyNestedNamedParameterDeclaration() async { |
| 693 | + // This is a regression test; previously this code would cause an analyzer |
| 694 | + // crash in DeprecatedMemberUseVerifier. |
| 695 | + await assertErrorsInCode( |
| 696 | + r''' |
| 697 | +class C { |
| 698 | + final String x; |
| 699 | + final bool y; |
| 700 | +
|
| 701 | + const C({ |
| 702 | + required this.x, |
| 703 | + {this.y = false} |
| 704 | + }); |
| 705 | +} |
| 706 | +
|
| 707 | +const z = C(x: ''); |
| 708 | +''', |
| 709 | + [ |
| 710 | + error(CompileTimeErrorCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1, 53, 1), |
| 711 | + error(ParserErrorCode.MISSING_IDENTIFIER, 82, 1), |
| 712 | + error(ParserErrorCode.EXPECTED_TOKEN, 82, 1), |
| 713 | + ], |
| 714 | + ); |
| 715 | + } |
| 716 | + |
691 | 717 | test_inDeprecatedClass() async {
|
692 | 718 | await assertNoErrorsInCode2(
|
693 | 719 | externalCode: r'''
|
@@ -1330,6 +1356,28 @@ class B = Object with A;
|
1330 | 1356 | ''');
|
1331 | 1357 | }
|
1332 | 1358 |
|
| 1359 | + test_namedParameterMissingName() async { |
| 1360 | + // This is a regression test; previously this code would cause an analyzer |
| 1361 | + // crash in DeprecatedMemberUseVerifier. |
| 1362 | + await assertErrorsInCode( |
| 1363 | + r''' |
| 1364 | +class C { |
| 1365 | + const C({this.}); |
| 1366 | +} |
| 1367 | +var z = C(x: ''); |
| 1368 | +''', |
| 1369 | + [ |
| 1370 | + error( |
| 1371 | + CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD, |
| 1372 | + 21, |
| 1373 | + 5, |
| 1374 | + ), |
| 1375 | + error(ParserErrorCode.MISSING_IDENTIFIER, 26, 1), |
| 1376 | + error(CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER, 42, 1), |
| 1377 | + ], |
| 1378 | + ); |
| 1379 | + } |
| 1380 | + |
1333 | 1381 | test_operator() async {
|
1334 | 1382 | await assertErrorsInCode2(
|
1335 | 1383 | externalCode: r'''
|
|
0 commit comments