Skip to content

Commit f6ed8d7

Browse files
author
Dart CI
committed
Version 3.7.0-323.0.dev
Merge 8063ed1 into dev
2 parents 1482910 + 8063ed1 commit f6ed8d7

File tree

91 files changed

+545
-902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+545
-902
lines changed

pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart

+1-130
Original file line numberDiff line numberDiff line change
@@ -1897,44 +1897,6 @@ class Parser {
18971897
}
18981898
}
18991899

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-
19381900
/// ```
19391901
/// normalFormalParameter:
19401902
/// functionFormalParameter |
@@ -1959,13 +1921,6 @@ class Parser {
19591921
token = parseMetadataStar(token);
19601922

19611923
Token? skippedNonRequiredRequired;
1962-
if (_isUseOfRequiredInNonNNBD(token)) {
1963-
skippedNonRequiredRequired = token.next!;
1964-
reportRecoverableErrorWithToken(skippedNonRequiredRequired,
1965-
codes.templateUnexpectedModifierInNonNnbd);
1966-
token = token.next!;
1967-
}
1968-
19691924
Token next = token.next!;
19701925
Token start = next;
19711926

@@ -3419,58 +3374,13 @@ class Parser {
34193374
return parseTopLevelMemberImpl(token).next!;
34203375
}
34213376

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-
34583377
Token parseTopLevelMemberImpl(Token token) {
34593378
Token beforeStart = token;
34603379
Token next = token.next!;
34613380
listener.beginTopLevelMember(next);
34623381

34633382
Token? skippedNonLateLate;
34643383

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-
34743384
Token? externalToken;
34753385
Token? augmentToken;
34763386
Token? lateToken;
@@ -3787,20 +3697,7 @@ class Parser {
37873697
if (semicolon.isA(TokenType.SEMICOLON)) {
37883698
token = semicolon;
37893699
} 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);
38043701
}
38053702
switch (kind) {
38063703
case DeclarationKind.TopLevel:
@@ -4520,14 +4417,6 @@ class Parser {
45204417

45214418
Token? skippedNonLateLate;
45224419

4523-
if (_isUseOfLateInNonNNBD(token.next!)) {
4524-
skippedNonLateLate = token.next!;
4525-
reportRecoverableErrorWithToken(
4526-
skippedNonLateLate, codes.templateUnexpectedModifierInNonNnbd);
4527-
token = token.next!;
4528-
beforeStart = token;
4529-
}
4530-
45314420
Token? covariantToken;
45324421
Token? abstractToken;
45334422
Token? augmentToken;
@@ -8162,24 +8051,6 @@ class Parser {
81628051
Token parseExpressionStatementOrDeclarationAfterModifiers(Token beforeType,
81638052
Token start, Token? lateToken, Token? varFinalOrConst, TypeInfo? typeInfo,
81648053
[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-
81838054
if (allowPatterns &&
81848055
varFinalOrConst != null &&
81858056
(varFinalOrConst.isA(Keyword.VAR) ||

pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart

+4-39
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ abstract class AbstractScanner implements Scanner {
7373
/// based upon the specified language version.
7474
final LanguageVersionChanged? languageVersionChanged;
7575

76-
/// Experimental flag for enabling scanning of the `extension` token.
77-
bool _enableExtensionMethods = false;
78-
79-
/// Experimental flag for enabling scanning of NNBD tokens
80-
/// such as 'required' and 'late'.
81-
bool _enableNonNullable = false;
82-
8376
/// Experimental flag for enabling scanning of `>>>`.
8477
/// See https://github.com/dart-lang/language/issues/61
8578
/// and https://github.com/dart-lang/language/issues/60
@@ -165,8 +158,6 @@ abstract class AbstractScanner implements Scanner {
165158
allowLazyStrings = true {
166159
this.tail = this.tokens;
167160
this.errorTail = this.tokens;
168-
this._enableExtensionMethods = copyFrom._enableExtensionMethods;
169-
this._enableNonNullable = copyFrom._enableNonNullable;
170161
this._enableTripleShift = copyFrom._enableTripleShift;
171162
this.tokenStart = copyFrom.tokenStart;
172163
this.groupingStack = copyFrom.groupingStack;
@@ -175,8 +166,6 @@ abstract class AbstractScanner implements Scanner {
175166
@override
176167
set configuration(ScannerConfiguration? config) {
177168
if (config != null) {
178-
_enableExtensionMethods = config.enableExtensionMethods;
179-
_enableNonNullable = config.enableNonNullable;
180169
_enableTripleShift = config.enableTripleShift;
181170
_forAugmentationLibrary = config.forAugmentationLibrary;
182171
}
@@ -1053,11 +1042,9 @@ abstract class AbstractScanner implements Scanner {
10531042
$EQ, TokenType.QUESTION_QUESTION_EQ, TokenType.QUESTION_QUESTION);
10541043
} else if (next == $PERIOD) {
10551044
next = advance();
1056-
if (_enableNonNullable) {
1057-
if ($PERIOD == next) {
1058-
appendPrecedenceToken(TokenType.QUESTION_PERIOD_PERIOD);
1059-
return advance();
1060-
}
1045+
if ($PERIOD == next) {
1046+
appendPrecedenceToken(TokenType.QUESTION_PERIOD_PERIOD);
1047+
return advance();
10611048
}
10621049
appendPrecedenceToken(TokenType.QUESTION_PERIOD);
10631050
return next;
@@ -1577,10 +1564,6 @@ abstract class AbstractScanner implements Scanner {
15771564
if (languageVersionChanged != null) {
15781565
// TODO(danrubel): make this required and remove the languageVersion field
15791566
languageVersionChanged!(this, languageVersion);
1580-
} else {
1581-
// TODO(danrubel): remove this hack and require listener to update
1582-
// the scanner's configuration.
1583-
configuration = ScannerConfiguration.classic;
15841567
}
15851568
if (includeComments) {
15861569
_appendToCommentStream(languageVersion);
@@ -1745,13 +1728,6 @@ abstract class AbstractScanner implements Scanner {
17451728
if (keyword == null) {
17461729
return tokenizeIdentifier(next, start, allowDollar);
17471730
}
1748-
if (!_enableExtensionMethods && keyword == Keyword.EXTENSION) {
1749-
return tokenizeIdentifier(next, start, allowDollar);
1750-
}
1751-
if (!_enableNonNullable &&
1752-
(keyword == Keyword.LATE || keyword == Keyword.REQUIRED)) {
1753-
return tokenizeIdentifier(next, start, allowDollar);
1754-
}
17551731
if (!_forAugmentationLibrary && keyword == Keyword.AUGMENT) {
17561732
return tokenizeIdentifier(next, start, allowDollar);
17571733
}
@@ -2168,16 +2144,7 @@ class LineStarts extends Object with ListMixin<int> {
21682144
/// [ScannerConfiguration] contains information for configuring which tokens
21692145
/// the scanner produces based upon the Dart language level.
21702146
class ScannerConfiguration {
2171-
static const ScannerConfiguration classic = const ScannerConfiguration();
2172-
static const ScannerConfiguration nonNullable =
2173-
const ScannerConfiguration(enableNonNullable: true);
2174-
2175-
/// Experimental flag for enabling scanning of the `extension` keyword.
2176-
final bool enableExtensionMethods;
2177-
2178-
/// Experimental flag for enabling scanning of NNBD tokens
2179-
/// such as 'required' and 'late'
2180-
final bool enableNonNullable;
2147+
static const ScannerConfiguration nonNullable = const ScannerConfiguration();
21812148

21822149
/// Experimental flag for enabling scanning of `>>>`.
21832150
/// See https://github.com/dart-lang/language/issues/61
@@ -2188,8 +2155,6 @@ class ScannerConfiguration {
21882155
final bool forAugmentationLibrary;
21892156

21902157
const ScannerConfiguration({
2191-
this.enableExtensionMethods = false,
2192-
this.enableNonNullable = false,
21932158
this.enableTripleShift = false,
21942159
this.forAugmentationLibrary = false,
21952160
});

pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,6 @@ void assertEdits({
740740
code,
741741
libraryDeclarationNames: libraryDeclarationNames,
742742
scannerConfiguration: ScannerConfiguration(
743-
enableExtensionMethods: true,
744-
enableNonNullable: true,
745743
forAugmentationLibrary: true,
746744
),
747745
throwIfHasErrors: throwIfHasErrors,

pkg/_fe_analyzer_shared/test/scanner_benchmark.dart

-6
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ void main(List<String> args) {
5353
hasErrors = scanString(
5454
content,
5555
configuration: new ScannerConfiguration(
56-
enableExtensionMethods: true,
57-
enableNonNullable: true,
5856
enableTripleShift: true,
5957
),
6058
includeComments: true,
@@ -66,8 +64,6 @@ void main(List<String> args) {
6664
hasErrors = scan(
6765
contentBytes,
6866
configuration: new ScannerConfiguration(
69-
enableExtensionMethods: true,
70-
enableNonNullable: true,
7167
enableTripleShift: true,
7268
),
7369
includeComments: true,
@@ -80,8 +76,6 @@ void main(List<String> args) {
8076
hasErrors = scan(
8177
tmp,
8278
configuration: new ScannerConfiguration(
83-
enableExtensionMethods: true,
84-
enableNonNullable: true,
8579
enableTripleShift: true,
8680
),
8781
includeComments: true,

pkg/analyzer/lib/src/dart/scanner/scanner.dart

-3
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ class Scanner {
199199
featureSet == null
200200
? fasta.ScannerConfiguration()
201201
: fasta.ScannerConfiguration(
202-
enableExtensionMethods:
203-
featureSet.isEnabled(Feature.extension_methods),
204202
enableTripleShift: featureSet.isEnabled(Feature.triple_shift),
205-
enableNonNullable: featureSet.isEnabled(Feature.non_nullable),
206203
forAugmentationLibrary: featureSet.isEnabled(Feature.macros),
207204
);
208205
}

pkg/analyzer/test/generated/extension_methods_parser_test.dart

-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:analyzer/src/dart/scanner/scanner.dart';
77
import 'package:test/test.dart';
88
import 'package:test_reflective_loader/test_reflective_loader.dart';
99

10-
import '../util/feature_sets.dart';
1110
import 'parser_test_base.dart';
1211

1312
main() {
@@ -219,17 +218,6 @@ class C {}
219218
expect(extension.members, hasLength(0));
220219
}
221220

222-
void test_simple_not_enabled() {
223-
parseCompilationUnit(
224-
'extension E on C { }',
225-
errors: [
226-
expectedError(ParserErrorCode.EXPERIMENT_NOT_ENABLED, 0, 9),
227-
expectedError(ParserErrorCode.MISSING_FUNCTION_PARAMETERS, 15, 1)
228-
],
229-
featureSet: FeatureSets.language_2_3,
230-
);
231-
}
232-
233221
void test_simple_with() {
234222
var unit = parseCompilationUnit('extension E with C { }', errors: [
235223
expectedError(ParserErrorCode.EXPECTED_INSTEAD, 12, 4),

pkg/analyzer/test/generated/parser_test_base.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,7 @@ class FastaParserTestCase
257257
var languageVersion = LibraryLanguageVersion(
258258
package: ExperimentStatus.currentVersion, override: null);
259259
var result = scanString(content,
260-
configuration: featureSet.isEnabled(Feature.non_nullable)
261-
? ScannerConfiguration.nonNullable
262-
: ScannerConfiguration.classic,
263-
includeComments: true,
260+
configuration: ScannerConfiguration.nonNullable, includeComments: true,
264261
languageVersionChanged: (scanner, overrideVersion) {
265262
languageVersion = LibraryLanguageVersion(
266263
package: ExperimentStatus.currentVersion,

pkg/analyzer/test/util/feature_sets.dart

-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ import 'package:analyzer_utilities/test/experiments/experiments.dart';
88
import 'package:pub_semver/pub_semver.dart';
99

1010
class FeatureSets {
11-
static final FeatureSet language_2_3 = FeatureSet.fromEnableFlags2(
12-
sdkLanguageVersion: Version.parse('2.3.0'),
13-
flags: [],
14-
);
15-
1611
static final FeatureSet language_2_9 = FeatureSet.fromEnableFlags2(
1712
sdkLanguageVersion: Version.parse('2.9.0'),
1813
flags: [],

pkg/front_end/lib/src/base/incremental_compiler.dart

-2
Original file line numberDiff line numberDiff line change
@@ -1232,8 +1232,6 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
12321232
return null;
12331233
}
12341234
ScannerConfiguration scannerConfiguration = new ScannerConfiguration(
1235-
enableExtensionMethods: true /* can't be disabled */,
1236-
enableNonNullable: true /* can't be disabled */,
12371235
enableTripleShift:
12381236
/* should this be on the library? */
12391237
/* this is effectively what the constant evaluator does */

pkg/front_end/lib/src/kernel/macro/macro.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -1355,10 +1355,7 @@ class MacroApplications {
13551355

13561356
ScannerResult scannerResult = scan(sourceUtf8,
13571357
configuration: new ScannerConfiguration(
1358-
enableExtensionMethods: true,
1359-
enableNonNullable: true,
1360-
enableTripleShift: true,
1361-
forAugmentationLibrary: true));
1358+
enableTripleShift: true, forAugmentationLibrary: true));
13621359
_sourceLoader.target.addSourceInformation(augmentationImportUri,
13631360
augmentationFileUri, scannerResult.lineStarts, sourceUtf8);
13641361
for (Uri intermediateAugmentationUri in intermediateAugmentationUris) {

0 commit comments

Comments
 (0)