@@ -1897,44 +1897,6 @@ class Parser {
1897
1897
}
1898
1898
}
1899
1899
1900
- /// Check if [token] is the usage of 'required' in a formal parameter in a
1901
- /// context where it's not legal (i.e. in non-nnbd-mode).
1902
- bool _isUseOfRequiredInNonNNBD (Token token) {
1903
- if (token.next is StringToken && token.next! .value () == "required" ) {
1904
- // Possible recovery: Figure out if we're in a situation like
1905
- // required covariant? <type> name
1906
- // (in non-nnbd-mode) where the required modifier is not legal and thus
1907
- // would normally be parsed as the type.
1908
- token = token.next! ;
1909
- Token next = token.next! ;
1910
- // Skip modifiers.
1911
- while (next.isModifier) {
1912
- token = next;
1913
- next = next.next! ;
1914
- }
1915
- // Parse the (potential) new type.
1916
- TypeInfo typeInfoAlternative = computeType (
1917
- token,
1918
- /* required = */ false ,
1919
- /* inDeclaration = */ true ,
1920
- );
1921
- token = typeInfoAlternative.skipType (token);
1922
- next = token.next! ;
1923
-
1924
- // We've essentially ignored the 'required' at this point.
1925
- // `token` is (in the good state) the last token of the type,
1926
- // `next` is (in the good state) the name;
1927
- // Are we in a 'good' state?
1928
- if (typeInfoAlternative != noType &&
1929
- next.isIdentifier &&
1930
- (next.next! .isA (TokenType .COMMA ) ||
1931
- next.next! .isA (TokenType .CLOSE_CURLY_BRACKET ))) {
1932
- return true ;
1933
- }
1934
- }
1935
- return false ;
1936
- }
1937
-
1938
1900
/// ```
1939
1901
/// normalFormalParameter:
1940
1902
/// functionFormalParameter |
@@ -1959,13 +1921,6 @@ class Parser {
1959
1921
token = parseMetadataStar (token);
1960
1922
1961
1923
Token ? skippedNonRequiredRequired;
1962
- if (_isUseOfRequiredInNonNNBD (token)) {
1963
- skippedNonRequiredRequired = token.next! ;
1964
- reportRecoverableErrorWithToken (skippedNonRequiredRequired,
1965
- codes.templateUnexpectedModifierInNonNnbd);
1966
- token = token.next! ;
1967
- }
1968
-
1969
1924
Token next = token.next! ;
1970
1925
Token start = next;
1971
1926
@@ -3419,58 +3374,13 @@ class Parser {
3419
3374
return parseTopLevelMemberImpl (token).next! ;
3420
3375
}
3421
3376
3422
- /// Check if [token] is the usage of 'late' before a field declaration in a
3423
- /// context where it's not legal (i.e. in non-nnbd-mode).
3424
- bool _isUseOfLateInNonNNBD (Token token) {
3425
- if (token is StringToken && token.value () == "late" ) {
3426
- // Possible recovery: Figure out if we're in a situation like
3427
- // late final? <type>/var/const name [...]
3428
- // (in non-nnbd-mode) where the late modifier is not legal and thus would
3429
- // normally be parsed as the type.
3430
- Token next = token.next! ;
3431
- // Skip modifiers.
3432
- while (next.isModifier) {
3433
- token = next;
3434
- next = next.next! ;
3435
- }
3436
- // Parse the (potential) new type.
3437
- TypeInfo typeInfoAlternative = computeType (
3438
- token,
3439
- /* required = */ false ,
3440
- /* inDeclaration = */ true ,
3441
- );
3442
- token = typeInfoAlternative.skipType (token);
3443
- next = token.next! ;
3444
-
3445
- // We've essentially ignored the 'late' at this point.
3446
- // `token` is (in the good state) the last token of the type,
3447
- // `next` is (in the good state) the name;
3448
- // Are we in a 'good' state?
3449
- if (typeInfoAlternative != noType &&
3450
- next.isIdentifier &&
3451
- indicatesMethodOrField (next.next! )) {
3452
- return true ;
3453
- }
3454
- }
3455
- return false ;
3456
- }
3457
-
3458
3377
Token parseTopLevelMemberImpl (Token token) {
3459
3378
Token beforeStart = token;
3460
3379
Token next = token.next! ;
3461
3380
listener.beginTopLevelMember (next);
3462
3381
3463
3382
Token ? skippedNonLateLate;
3464
3383
3465
- if (_isUseOfLateInNonNNBD (next)) {
3466
- skippedNonLateLate = next;
3467
- reportRecoverableErrorWithToken (
3468
- skippedNonLateLate, codes.templateUnexpectedModifierInNonNnbd);
3469
- token = token.next! ;
3470
- beforeStart = token;
3471
- next = token.next! ;
3472
- }
3473
-
3474
3384
Token ? externalToken;
3475
3385
Token ? augmentToken;
3476
3386
Token ? lateToken;
@@ -3787,20 +3697,7 @@ class Parser {
3787
3697
if (semicolon.isA (TokenType .SEMICOLON )) {
3788
3698
token = semicolon;
3789
3699
} else {
3790
- // Recovery
3791
- if (kind == DeclarationKind .TopLevel &&
3792
- beforeType.next! .isIdentifier &&
3793
- beforeType.next! .lexeme == 'extension' ) {
3794
- // Looks like an extension method
3795
- // TODO(danrubel): Remove when extension methods are enabled by default
3796
- // because then 'extension' will be interpreted as a built-in
3797
- // and this code will never be executed
3798
- reportExperimentNotEnabled (ExperimentalFlag .extensionMethods,
3799
- beforeType.next! , beforeType.next! );
3800
- token = rewriter.insertSyntheticToken (token, TokenType .SEMICOLON );
3801
- } else {
3802
- token = ensureSemicolon (token);
3803
- }
3700
+ token = ensureSemicolon (token);
3804
3701
}
3805
3702
switch (kind) {
3806
3703
case DeclarationKind .TopLevel :
@@ -4520,14 +4417,6 @@ class Parser {
4520
4417
4521
4418
Token ? skippedNonLateLate;
4522
4419
4523
- if (_isUseOfLateInNonNNBD (token.next! )) {
4524
- skippedNonLateLate = token.next! ;
4525
- reportRecoverableErrorWithToken (
4526
- skippedNonLateLate, codes.templateUnexpectedModifierInNonNnbd);
4527
- token = token.next! ;
4528
- beforeStart = token;
4529
- }
4530
-
4531
4420
Token ? covariantToken;
4532
4421
Token ? abstractToken;
4533
4422
Token ? augmentToken;
@@ -8162,24 +8051,6 @@ class Parser {
8162
8051
Token parseExpressionStatementOrDeclarationAfterModifiers (Token beforeType,
8163
8052
Token start, Token ? lateToken, Token ? varFinalOrConst, TypeInfo ? typeInfo,
8164
8053
[ForPartsContext ? forPartsContext]) {
8165
- // In simple cases check for bad 'late' modifier in non-nnbd-mode.
8166
- if (typeInfo == null &&
8167
- lateToken == null &&
8168
- varFinalOrConst == null &&
8169
- beforeType == start &&
8170
- _isUseOfLateInNonNNBD (beforeType.next! )) {
8171
- lateToken = beforeType.next! ;
8172
- reportRecoverableErrorWithToken (
8173
- lateToken, codes.templateUnexpectedModifierInNonNnbd);
8174
- beforeType = start = beforeType.next! ;
8175
-
8176
- // The below doesn't parse modifiers, so we need to do it here.
8177
- ModifierContext context = new ModifierContext (this );
8178
- beforeType =
8179
- start = context.parseVariableDeclarationModifiers (beforeType);
8180
- varFinalOrConst = context.varFinalOrConst;
8181
- }
8182
-
8183
8054
if (allowPatterns &&
8184
8055
varFinalOrConst != null &&
8185
8056
(varFinalOrConst.isA (Keyword .VAR ) ||
0 commit comments