From 5dfce919cd04bae29ab2c002f1a38a8916ec031f Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Mon, 13 Jan 2025 00:32:25 -0800 Subject: [PATCH 1/5] [parser/scanner] Remove ScannerConfig `enableExtensionMethods` Extension methods can no longer be disabled. This CL removes the option from the scanner config and the parser related specific recovery. It also removes any specific (triggered) test of the functionality. A follow-up CL will do the same for NNBD. Change-Id: Ia385008e5ed1333fb37697b8fe424b8759bce198 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403581 Reviewed-by: Johnni Winther Commit-Queue: Jens Johansen Reviewed-by: Brian Wilkerson --- .../lib/src/parser/parser_impl.dart | 15 +---------- .../lib/src/scanner/abstract_scanner.dart | 12 --------- .../test/macros/code_optimizer_test.dart | 1 - .../test/scanner_benchmark.dart | 3 --- .../lib/src/dart/scanner/scanner.dart | 2 -- .../extension_methods_parser_test.dart | 12 --------- pkg/analyzer/test/util/feature_sets.dart | 5 ---- .../lib/src/base/incremental_compiler.dart | 1 - pkg/front_end/lib/src/kernel/macro/macro.dart | 1 - .../lib/src/source/source_loader.dart | 7 ----- .../src/util/import_export_etc_helper.dart | 1 - .../lib/src/util/outline_extractor.dart | 5 +--- pkg/front_end/lib/src/util/parser_ast.dart | 2 -- .../crashing_test_case_minimizer_impl.dart | 18 +++---------- pkg/front_end/test/lint_suite.dart | 7 ++--- .../test/parser/parser_ast_test.dart | 26 ++++--------------- pkg/front_end/test/parser_suite.dart | 4 --- .../test/parser_test_parser_creator.dart | 3 ++- pkg/front_end/test/scanner_test.dart | 8 +----- .../test/testing/folder_options.dart | 2 -- pkg/front_end/test/testing/suite.dart | 1 - pkg/front_end/test/textual_outline_suite.dart | 3 --- pkg/front_end/test/textual_outline_test.dart | 3 +-- pkg/front_end/test/token_test.dart | 2 +- pkg/front_end/test/utils/kernel_chain.dart | 4 +-- .../test/web_parser_git_test_helper.dart | 4 +-- pkg/front_end/tool/coverage_merger.dart | 1 - pkg/front_end/tool/dart_doctest_impl.dart | 4 +-- .../duplicate_code_finder_experiment.dart | 1 - pkg/front_end/tool/fuzz/minimizer.dart | 1 - .../tool/parser_direct_ast/viewer.dart | 1 - 31 files changed, 20 insertions(+), 140 deletions(-) diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart index 3e7f0025c24f..dbc8460fc085 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart @@ -3787,20 +3787,7 @@ class Parser { if (semicolon.isA(TokenType.SEMICOLON)) { token = semicolon; } else { - // Recovery - if (kind == DeclarationKind.TopLevel && - beforeType.next!.isIdentifier && - beforeType.next!.lexeme == 'extension') { - // Looks like an extension method - // TODO(danrubel): Remove when extension methods are enabled by default - // because then 'extension' will be interpreted as a built-in - // and this code will never be executed - reportExperimentNotEnabled(ExperimentalFlag.extensionMethods, - beforeType.next!, beforeType.next!); - token = rewriter.insertSyntheticToken(token, TokenType.SEMICOLON); - } else { - token = ensureSemicolon(token); - } + token = ensureSemicolon(token); } switch (kind) { case DeclarationKind.TopLevel: diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart index 066ee566d340..4b3481b57fe0 100644 --- a/pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart +++ b/pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart @@ -73,9 +73,6 @@ abstract class AbstractScanner implements Scanner { /// based upon the specified language version. final LanguageVersionChanged? languageVersionChanged; - /// Experimental flag for enabling scanning of the `extension` token. - bool _enableExtensionMethods = false; - /// Experimental flag for enabling scanning of NNBD tokens /// such as 'required' and 'late'. bool _enableNonNullable = false; @@ -165,7 +162,6 @@ abstract class AbstractScanner implements Scanner { allowLazyStrings = true { this.tail = this.tokens; this.errorTail = this.tokens; - this._enableExtensionMethods = copyFrom._enableExtensionMethods; this._enableNonNullable = copyFrom._enableNonNullable; this._enableTripleShift = copyFrom._enableTripleShift; this.tokenStart = copyFrom.tokenStart; @@ -175,7 +171,6 @@ abstract class AbstractScanner implements Scanner { @override set configuration(ScannerConfiguration? config) { if (config != null) { - _enableExtensionMethods = config.enableExtensionMethods; _enableNonNullable = config.enableNonNullable; _enableTripleShift = config.enableTripleShift; _forAugmentationLibrary = config.forAugmentationLibrary; @@ -1745,9 +1740,6 @@ abstract class AbstractScanner implements Scanner { if (keyword == null) { return tokenizeIdentifier(next, start, allowDollar); } - if (!_enableExtensionMethods && keyword == Keyword.EXTENSION) { - return tokenizeIdentifier(next, start, allowDollar); - } if (!_enableNonNullable && (keyword == Keyword.LATE || keyword == Keyword.REQUIRED)) { return tokenizeIdentifier(next, start, allowDollar); @@ -2172,9 +2164,6 @@ class ScannerConfiguration { static const ScannerConfiguration nonNullable = const ScannerConfiguration(enableNonNullable: true); - /// Experimental flag for enabling scanning of the `extension` keyword. - final bool enableExtensionMethods; - /// Experimental flag for enabling scanning of NNBD tokens /// such as 'required' and 'late' final bool enableNonNullable; @@ -2188,7 +2177,6 @@ class ScannerConfiguration { final bool forAugmentationLibrary; const ScannerConfiguration({ - this.enableExtensionMethods = false, this.enableNonNullable = false, this.enableTripleShift = false, this.forAugmentationLibrary = false, diff --git a/pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart b/pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart index 37d2cb1a4f34..0be2a0368b25 100644 --- a/pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart +++ b/pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart @@ -740,7 +740,6 @@ void assertEdits({ code, libraryDeclarationNames: libraryDeclarationNames, scannerConfiguration: ScannerConfiguration( - enableExtensionMethods: true, enableNonNullable: true, forAugmentationLibrary: true, ), diff --git a/pkg/_fe_analyzer_shared/test/scanner_benchmark.dart b/pkg/_fe_analyzer_shared/test/scanner_benchmark.dart index 6c39cb60daf0..d2694a880663 100644 --- a/pkg/_fe_analyzer_shared/test/scanner_benchmark.dart +++ b/pkg/_fe_analyzer_shared/test/scanner_benchmark.dart @@ -53,7 +53,6 @@ void main(List args) { hasErrors = scanString( content, configuration: new ScannerConfiguration( - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, ), @@ -66,7 +65,6 @@ void main(List args) { hasErrors = scan( contentBytes, configuration: new ScannerConfiguration( - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, ), @@ -80,7 +78,6 @@ void main(List args) { hasErrors = scan( tmp, configuration: new ScannerConfiguration( - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, ), diff --git a/pkg/analyzer/lib/src/dart/scanner/scanner.dart b/pkg/analyzer/lib/src/dart/scanner/scanner.dart index 428f82bfe5e9..99d3b1726cc5 100644 --- a/pkg/analyzer/lib/src/dart/scanner/scanner.dart +++ b/pkg/analyzer/lib/src/dart/scanner/scanner.dart @@ -199,8 +199,6 @@ class Scanner { featureSet == null ? fasta.ScannerConfiguration() : fasta.ScannerConfiguration( - enableExtensionMethods: - featureSet.isEnabled(Feature.extension_methods), enableTripleShift: featureSet.isEnabled(Feature.triple_shift), enableNonNullable: featureSet.isEnabled(Feature.non_nullable), forAugmentationLibrary: featureSet.isEnabled(Feature.macros), diff --git a/pkg/analyzer/test/generated/extension_methods_parser_test.dart b/pkg/analyzer/test/generated/extension_methods_parser_test.dart index be852fcb25cb..73576cb19da0 100644 --- a/pkg/analyzer/test/generated/extension_methods_parser_test.dart +++ b/pkg/analyzer/test/generated/extension_methods_parser_test.dart @@ -7,7 +7,6 @@ import 'package:analyzer/src/dart/scanner/scanner.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; -import '../util/feature_sets.dart'; import 'parser_test_base.dart'; main() { @@ -219,17 +218,6 @@ class C {} expect(extension.members, hasLength(0)); } - void test_simple_not_enabled() { - parseCompilationUnit( - 'extension E on C { }', - errors: [ - expectedError(ParserErrorCode.EXPERIMENT_NOT_ENABLED, 0, 9), - expectedError(ParserErrorCode.MISSING_FUNCTION_PARAMETERS, 15, 1) - ], - featureSet: FeatureSets.language_2_3, - ); - } - void test_simple_with() { var unit = parseCompilationUnit('extension E with C { }', errors: [ expectedError(ParserErrorCode.EXPECTED_INSTEAD, 12, 4), diff --git a/pkg/analyzer/test/util/feature_sets.dart b/pkg/analyzer/test/util/feature_sets.dart index 7b548a94bd96..5e6d624be4b6 100644 --- a/pkg/analyzer/test/util/feature_sets.dart +++ b/pkg/analyzer/test/util/feature_sets.dart @@ -8,11 +8,6 @@ import 'package:analyzer_utilities/test/experiments/experiments.dart'; import 'package:pub_semver/pub_semver.dart'; class FeatureSets { - static final FeatureSet language_2_3 = FeatureSet.fromEnableFlags2( - sdkLanguageVersion: Version.parse('2.3.0'), - flags: [], - ); - static final FeatureSet language_2_9 = FeatureSet.fromEnableFlags2( sdkLanguageVersion: Version.parse('2.9.0'), flags: [], diff --git a/pkg/front_end/lib/src/base/incremental_compiler.dart b/pkg/front_end/lib/src/base/incremental_compiler.dart index ca404aa34d99..fea1ed6376f8 100644 --- a/pkg/front_end/lib/src/base/incremental_compiler.dart +++ b/pkg/front_end/lib/src/base/incremental_compiler.dart @@ -1232,7 +1232,6 @@ class IncrementalCompiler implements IncrementalKernelGenerator { return null; } ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableExtensionMethods: true /* can't be disabled */, enableNonNullable: true /* can't be disabled */, enableTripleShift: /* should this be on the library? */ diff --git a/pkg/front_end/lib/src/kernel/macro/macro.dart b/pkg/front_end/lib/src/kernel/macro/macro.dart index 9005780b8d48..4cb320709a03 100644 --- a/pkg/front_end/lib/src/kernel/macro/macro.dart +++ b/pkg/front_end/lib/src/kernel/macro/macro.dart @@ -1355,7 +1355,6 @@ class MacroApplications { ScannerResult scannerResult = scan(sourceUtf8, configuration: new ScannerConfiguration( - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, forAugmentationLibrary: true)); diff --git a/pkg/front_end/lib/src/source/source_loader.dart b/pkg/front_end/lib/src/source/source_loader.dart index ff61299b425d..d73c8e9e6315 100644 --- a/pkg/front_end/lib/src/source/source_loader.dart +++ b/pkg/front_end/lib/src/source/source_loader.dart @@ -1051,11 +1051,6 @@ severity: $severity ExperimentalFlag.tripleShift, compilationUnit.importUri, compilationUnit.packageLanguageVersion.version), - enableExtensionMethods: - target.isExperimentEnabledInLibraryByVersion( - ExperimentalFlag.extensionMethods, - compilationUnit.importUri, - compilationUnit.packageLanguageVersion.version), enableNonNullable: target.isExperimentEnabledInLibraryByVersion( ExperimentalFlag.nonNullable, compilationUnit.importUri, @@ -1072,8 +1067,6 @@ severity: $severity scanner.configuration = new ScannerConfiguration( enableTripleShift: compilationUnit.libraryFeatures.tripleShift.isEnabled, - enableExtensionMethods: - compilationUnit.libraryFeatures.extensionMethods.isEnabled, enableNonNullable: true); }, allowLazyStrings: allowLazyStrings); Token token = result.tokens; diff --git a/pkg/front_end/lib/src/util/import_export_etc_helper.dart b/pkg/front_end/lib/src/util/import_export_etc_helper.dart index 8dafa92e44b6..a429c46785b6 100644 --- a/pkg/front_end/lib/src/util/import_export_etc_helper.dart +++ b/pkg/front_end/lib/src/util/import_export_etc_helper.dart @@ -13,7 +13,6 @@ FileInfoHelper getFileInfoHelper(Uint8List rawBytes) { new ImportExportPartLibraryHelperVisitor(); getAST( rawBytes, - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, includeBody: false, diff --git a/pkg/front_end/lib/src/util/outline_extractor.dart b/pkg/front_end/lib/src/util/outline_extractor.dart index f6237ce44188..c1cdd781e849 100644 --- a/pkg/front_end/lib/src/util/outline_extractor.dart +++ b/pkg/front_end/lib/src/util/outline_extractor.dart @@ -135,9 +135,7 @@ class _Processor { // TODO: Support updating the configuration; also default it to match // the package version. final ScannerConfiguration configuration = new ScannerConfiguration( - enableExtensionMethods: true, - enableNonNullable: true, - enableTripleShift: true); + enableNonNullable: true, enableTripleShift: true); textualOutlineStopwatch.start(); final String? outlined = textualOutline(bytes, configuration, enablePatterns: true); @@ -147,7 +145,6 @@ class _Processor { getAstStopwatch.start(); List languageVersionsSeen = []; final ParserAstNode ast = getAST(bytes2, - enableExtensionMethods: configuration.enableExtensionMethods, enableNonNullable: configuration.enableNonNullable, enableTripleShift: configuration.enableTripleShift, languageVersionsSeen: languageVersionsSeen); diff --git a/pkg/front_end/lib/src/util/parser_ast.dart b/pkg/front_end/lib/src/util/parser_ast.dart index 9c7d49739522..77aeeee3a74e 100644 --- a/pkg/front_end/lib/src/util/parser_ast.dart +++ b/pkg/front_end/lib/src/util/parser_ast.dart @@ -28,7 +28,6 @@ CompilationUnitEnd getAST( Uint8List rawBytes, { bool includeBody = true, bool includeComments = false, - bool enableExtensionMethods = false, bool enableNonNullable = false, bool enableTripleShift = false, bool allowPatterns = false, @@ -36,7 +35,6 @@ CompilationUnitEnd getAST( List? lineStarts, }) { ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableExtensionMethods: enableExtensionMethods, enableNonNullable: enableNonNullable, enableTripleShift: enableTripleShift); diff --git a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart index 56f69b5095e3..d90f2334be95 100644 --- a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart +++ b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart @@ -561,7 +561,6 @@ class TestMinimizer { CompilationUnitEnd ast = getAST(originalBytes, includeBody: false, includeComments: false, - enableExtensionMethods: true, enableNonNullable: _isUriNnbd(uri!)); // Find all imports/exports of this file (if any). // If finding any: @@ -602,7 +601,6 @@ class TestMinimizer { ast = getAST(withoutInlineable, includeBody: false, includeComments: false, - enableExtensionMethods: true, enableNonNullable: _isUriNnbd(uri)); for (ImportEnd import in ast.getImports()) { offsetOfLast = max(offsetOfLast, import.semicolon!.offset + 1); @@ -704,10 +702,7 @@ class TestMinimizer { Uint8List oldData, Uri newUri, Uri oldUri, bool nnbd, {bool convertExportToImport = false}) { CompilationUnitEnd ast = getAST(oldData, - includeBody: false, - includeComments: false, - enableExtensionMethods: true, - enableNonNullable: nnbd); + includeBody: false, includeComments: false, enableNonNullable: nnbd); List<_Replacement> replacements = []; for (ImportEnd import in ast.getImports()) { _rewriteImportsExportsToUriInternal( @@ -1300,7 +1295,6 @@ worlds: CompilationUnitEnd ast = getAST(data, includeBody: true, includeComments: false, - enableExtensionMethods: true, enableNonNullable: _isUriNnbd(uri)); _CompilationHelperClass helper = new _CompilationHelperClass(data); @@ -1867,8 +1861,6 @@ worlds: ScannerConfiguration _getScannerConfiguration(Version languageVersion) { return new ScannerConfiguration( - enableExtensionMethods: - languageVersion >= ExperimentalFlag.extensionMethods.enabledVersion, enableNonNullable: languageVersion >= ExperimentalFlag.nonNullable.enabledVersion, enableTripleShift: @@ -2171,14 +2163,10 @@ worlds: } ScannerConfiguration _scannerConfiguration = new ScannerConfiguration( - enableTripleShift: true, - enableExtensionMethods: true, - enableNonNullable: true); + enableTripleShift: true, enableNonNullable: true); ScannerConfiguration _scannerConfigurationNonNNBD = new ScannerConfiguration( - enableTripleShift: true, - enableExtensionMethods: true, - enableNonNullable: false); + enableTripleShift: true, enableNonNullable: false); List? _dataCache; String? _dataCacheString; diff --git a/pkg/front_end/test/lint_suite.dart b/pkg/front_end/test/lint_suite.dart index db9c05097728..08f33759f64c 100644 --- a/pkg/front_end/test/lint_suite.dart +++ b/pkg/front_end/test/lint_suite.dart @@ -30,8 +30,7 @@ void main([List arguments = const []]) => internalMain(createContext, displayName: "lint suite", configurationPath: "../testing.json"); -Future createContext( - Chain suite, Map environment) { +Future createContext(Chain suite, Map environment) { const Set knownEnvironmentKeys = {"onlyInGit"}; checkEnvironment(environment, knownEnvironmentKeys); @@ -137,9 +136,7 @@ class LintStep extends Step { Utf8BytesScanner scanner = new Utf8BytesScanner( bytes, configuration: const ScannerConfiguration( - enableExtensionMethods: true, - enableNonNullable: true, - enableTripleShift: true), + enableNonNullable: true, enableTripleShift: true), includeComments: true, languageVersionChanged: (scanner, languageVersion) { // Nothing - but don't overwrite the previous settings. diff --git a/pkg/front_end/test/parser/parser_ast_test.dart b/pkg/front_end/test/parser/parser_ast_test.dart index cb8c013fa5ec..65f506fbd0b6 100644 --- a/pkg/front_end/test/parser/parser_ast_test.dart +++ b/pkg/front_end/test/parser/parser_ast_test.dart @@ -39,7 +39,6 @@ void canParseTopLevelIshOfAllFrontendFiles() { data, includeBody: true, includeComments: true, - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, ); @@ -82,10 +81,7 @@ void testTopLevelStuff() { base.resolve("parser_ast_test_data/top_level_stuff.txt")); Uint8List data = file.readAsBytesSync(); CompilationUnitEnd ast = getAST(data, - includeBody: true, - includeComments: true, - enableExtensionMethods: true, - enableNonNullable: false); + includeBody: true, includeComments: true, enableNonNullable: false); expect(2, ast.getImports().length); expect(2, ast.getExports().length); @@ -139,10 +135,7 @@ void testTopLevelStuff() { base.resolve("parser_ast_test_data/top_level_stuff_helper.txt")); data = file.readAsBytesSync(); ast = getAST(data, - includeBody: true, - includeComments: true, - enableExtensionMethods: true, - enableNonNullable: false); + includeBody: true, includeComments: true, enableNonNullable: false); foundChunks = splitIntoChunks(ast, data); expect(1, foundChunks.length); expect("part of 'top_level_stuff.txt';", foundChunks[0]); @@ -151,10 +144,7 @@ void testTopLevelStuff() { new File.fromUri(base.resolve("parser_ast_test_data/script_handle.txt")); data = file.readAsBytesSync(); ast = getAST(data, - includeBody: true, - includeComments: true, - enableExtensionMethods: true, - enableNonNullable: false); + includeBody: true, includeComments: true, enableNonNullable: false); foundChunks = splitIntoChunks(ast, data); expect(1, foundChunks.length); expect("#!/usr/bin/env dart -c", foundChunks[0]); @@ -164,10 +154,7 @@ void testClassStuff() { File file = new File.fromUri(base.resolve("parser_ast_test_data/class.txt")); Uint8List data = file.readAsBytesSync(); CompilationUnitEnd ast = getAST(data, - includeBody: true, - includeComments: true, - enableExtensionMethods: true, - enableNonNullable: false); + includeBody: true, includeComments: true, enableNonNullable: false); List classes = ast.getClasses(); expect(2, classes.length); @@ -248,10 +235,7 @@ void testMixinStuff() { File file = new File.fromUri(base.resolve("parser_ast_test_data/mixin.txt")); Uint8List data = file.readAsBytesSync(); CompilationUnitEnd ast = getAST(data, - includeBody: true, - includeComments: true, - enableExtensionMethods: true, - enableNonNullable: false); + includeBody: true, includeComments: true, enableNonNullable: false); List mixins = ast.getMixinDeclarations(); expect(mixins.length, 1); diff --git a/pkg/front_end/test/parser_suite.dart b/pkg/front_end/test/parser_suite.dart index 0d74e13d6d7f..1cb1f0f67ffa 100644 --- a/pkg/front_end/test/parser_suite.dart +++ b/pkg/front_end/test/parser_suite.dart @@ -73,27 +73,23 @@ Future createContext(Chain suite, Map environment) { ScannerConfiguration scannerConfiguration = new ScannerConfiguration( enableTripleShift: true, - enableExtensionMethods: true, enableNonNullable: true, forAugmentationLibrary: false); ScannerConfiguration scannerConfigurationNonNNBD = new ScannerConfiguration( enableTripleShift: true, - enableExtensionMethods: true, enableNonNullable: false, forAugmentationLibrary: false); ScannerConfiguration scannerConfigurationNonTripleShift = new ScannerConfiguration( enableTripleShift: false, - enableExtensionMethods: true, enableNonNullable: true, forAugmentationLibrary: false); ScannerConfiguration scannerConfigurationAugmentation = new ScannerConfiguration( enableTripleShift: true, - enableExtensionMethods: true, enableNonNullable: true, forAugmentationLibrary: true); diff --git a/pkg/front_end/test/parser_test_parser_creator.dart b/pkg/front_end/test/parser_test_parser_creator.dart index ed8b6ff2b44c..22ac64d972c1 100644 --- a/pkg/front_end/test/parser_test_parser_creator.dart +++ b/pkg/front_end/test/parser_test_parser_creator.dart @@ -307,7 +307,8 @@ class ParserCreatorListener extends Listener { troubleParameterTokens[currentFormalParameterToken] = nameToken; } currentFormalParameterToken = null; - if (kind == FormalParameterKind.optionalNamed) { + if (kind == FormalParameterKind.optionalNamed || + kind == FormalParameterKind.requiredNamed) { parametersNamed.add(nameToken.lexeme); } else { parameters.add(nameToken.lexeme); diff --git a/pkg/front_end/test/scanner_test.dart b/pkg/front_end/test/scanner_test.dart index 4d020c5f180a..cea27844ee2c 100644 --- a/pkg/front_end/test/scanner_test.dart +++ b/pkg/front_end/test/scanner_test.dart @@ -528,13 +528,7 @@ abstract class ScannerTestBase { } void test_keyword_extension() { - _assertKeywordToken("extension", - configuration: ScannerConfiguration(enableExtensionMethods: true)); - } - - void test_keyword_extension_old() { - _assertNotKeywordToken("extension", - configuration: ScannerConfiguration(enableExtensionMethods: false)); + _assertKeywordToken("extension", configuration: ScannerConfiguration()); } void test_keyword_factory() { diff --git a/pkg/front_end/test/testing/folder_options.dart b/pkg/front_end/test/testing/folder_options.dart index 490dad1a5c89..61673433fb27 100644 --- a/pkg/front_end/test/testing/folder_options.dart +++ b/pkg/front_end/test/testing/folder_options.dart @@ -144,8 +144,6 @@ class SuiteFolderOptions { } } - addForcedExperimentalFlag( - "enableExtensionMethods", ExperimentalFlag.extensionMethods); addForcedExperimentalFlag( "enableNonNullable", ExperimentalFlag.nonNullable); return experimentalFlags; diff --git a/pkg/front_end/test/testing/suite.dart b/pkg/front_end/test/testing/suite.dart index 891f3f093548..bf859742ae84 100644 --- a/pkg/front_end/test/testing/suite.dart +++ b/pkg/front_end/test/testing/suite.dart @@ -1625,7 +1625,6 @@ class FuzzAstVisitorSorter extends IgnoreSomeForCompatibilityAstVisitor { CompilationUnitEnd ast = getAST(bytes, includeBody: false, includeComments: true, - enableExtensionMethods: true, enableNonNullable: true, allowPatterns: allowPatterns); ast.accept(this); diff --git a/pkg/front_end/test/textual_outline_suite.dart b/pkg/front_end/test/textual_outline_suite.dart index e0e2ad358d92..73a65fa8d312 100644 --- a/pkg/front_end/test/textual_outline_suite.dart +++ b/pkg/front_end/test/textual_outline_suite.dart @@ -116,9 +116,6 @@ class TextualOutline extends Step { String? result = textualOutline( bytes, new ScannerConfiguration( - enableExtensionMethods: isExperimentEnabled( - ExperimentalFlag.extensionMethods, - explicitExperimentalFlags: experimentalFlags), enableNonNullable: isExperimentEnabled(ExperimentalFlag.nonNullable, explicitExperimentalFlags: experimentalFlags), enableTripleShift: isExperimentEnabled(ExperimentalFlag.tripleShift, diff --git a/pkg/front_end/test/textual_outline_test.dart b/pkg/front_end/test/textual_outline_test.dart index 2dea71fc21b4..ed8f7168c918 100644 --- a/pkg/front_end/test/textual_outline_test.dart +++ b/pkg/front_end/test/textual_outline_test.dart @@ -9,8 +9,7 @@ import 'package:_fe_analyzer_shared/src/scanner/abstract_scanner.dart' import "package:front_end/src/util/textual_outline.dart" show TextualOutlineInfoForTesting, textualOutline; -const ScannerConfiguration scannerConfiguration = - const ScannerConfiguration(enableExtensionMethods: true); +const ScannerConfiguration scannerConfiguration = const ScannerConfiguration(); void main() { TextualOutlineInfoForTesting infoForTesting; diff --git a/pkg/front_end/test/token_test.dart b/pkg/front_end/test/token_test.dart index 5feb16ee1690..ba39cd57e05a 100644 --- a/pkg/front_end/test/token_test.dart +++ b/pkg/front_end/test/token_test.dart @@ -143,7 +143,7 @@ class Foo { Keyword.CLASS, Keyword.ENUM, Keyword.EXPORT, - //Keyword.EXTENSION, <-- when "extension methods" is enabled by default + Keyword.EXTENSION, Keyword.IMPORT, Keyword.LIBRARY, Keyword.MIXIN, diff --git a/pkg/front_end/test/utils/kernel_chain.dart b/pkg/front_end/test/utils/kernel_chain.dart index fabfeb61026e..49acbb425c26 100644 --- a/pkg/front_end/test/utils/kernel_chain.dart +++ b/pkg/front_end/test/utils/kernel_chain.dart @@ -335,9 +335,7 @@ class ErrorCommentChecker Utf8BytesScanner scanner = new Utf8BytesScanner( rawBytes, configuration: const ScannerConfiguration( - enableExtensionMethods: true, - enableNonNullable: true, - enableTripleShift: true), + enableNonNullable: true, enableTripleShift: true), includeComments: true, languageVersionChanged: (scanner, languageVersion) { // Nothing - but don't overwrite the previous settings. diff --git a/pkg/front_end/test/web_parser_git_test_helper.dart b/pkg/front_end/test/web_parser_git_test_helper.dart index 14871b824461..3b5e4f6a20fd 100644 --- a/pkg/front_end/test/web_parser_git_test_helper.dart +++ b/pkg/front_end/test/web_parser_git_test_helper.dart @@ -17,9 +17,7 @@ void main(List args) { """; ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableExtensionMethods: true, - enableNonNullable: true, - enableTripleShift: true); + enableNonNullable: true, enableTripleShift: true); StringScanner scanner = new StringScanner( source, diff --git a/pkg/front_end/tool/coverage_merger.dart b/pkg/front_end/tool/coverage_merger.dart index a549676342a0..5012acfb5ff4 100644 --- a/pkg/front_end/tool/coverage_merger.dart +++ b/pkg/front_end/tool/coverage_merger.dart @@ -267,7 +267,6 @@ CoverageInfo _process( CompilationUnitEnd ast = getAST( rawBytes, includeComments: true, - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, allowPatterns: true, diff --git a/pkg/front_end/tool/dart_doctest_impl.dart b/pkg/front_end/tool/dart_doctest_impl.dart index 7b59758d1a80..b4dc6674bc70 100644 --- a/pkg/front_end/tool/dart_doctest_impl.dart +++ b/pkg/front_end/tool/dart_doctest_impl.dart @@ -531,9 +531,7 @@ List extractTests(Uint8List rawBytes, Uri uriForReporting) { Token scanRawBytes(Uint8List rawBytes, {List? lineStarts}) { ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableExtensionMethods: true, - enableNonNullable: true, - enableTripleShift: true); + enableNonNullable: true, enableTripleShift: true); Utf8BytesScanner scanner = new Utf8BytesScanner( rawBytes, diff --git a/pkg/front_end/tool/duplicate_code_finder_experiment.dart b/pkg/front_end/tool/duplicate_code_finder_experiment.dart index 40198680196d..b28d9152276c 100644 --- a/pkg/front_end/tool/duplicate_code_finder_experiment.dart +++ b/pkg/front_end/tool/duplicate_code_finder_experiment.dart @@ -330,7 +330,6 @@ List? _extend(List lines, Token _scan(String data) { ScannerConfiguration scannerConfiguration = new ScannerConfiguration( enableTripleShift: true, - enableExtensionMethods: true, enableNonNullable: true, forAugmentationLibrary: false); diff --git a/pkg/front_end/tool/fuzz/minimizer.dart b/pkg/front_end/tool/fuzz/minimizer.dart index 42f33de7ec87..da0b65d85562 100644 --- a/pkg/front_end/tool/fuzz/minimizer.dart +++ b/pkg/front_end/tool/fuzz/minimizer.dart @@ -33,7 +33,6 @@ Future main(List args) async { CompilationUnitEnd ast = getAST( rawBytes, includeComments: true, - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, allowPatterns: true, diff --git a/pkg/front_end/tool/parser_direct_ast/viewer.dart b/pkg/front_end/tool/parser_direct_ast/viewer.dart index a11f79fb241c..cac6d096f10a 100644 --- a/pkg/front_end/tool/parser_direct_ast/viewer.dart +++ b/pkg/front_end/tool/parser_direct_ast/viewer.dart @@ -19,7 +19,6 @@ void main(List args) { Uint8List bytes = new File.fromUri(uri).readAsBytesSync(); ParserAstNode ast = getAST( bytes, - enableExtensionMethods: true, enableNonNullable: true, enableTripleShift: true, allowPatterns: true, From c075d939e095307c26986c599f2ecbf6748a0d4e Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Mon, 13 Jan 2025 00:32:35 -0800 Subject: [PATCH 2/5] [parser/scanner] Remove ScannerConfig `enableNonNullable` Change-Id: If6bfbb65a02ac1a4f5708ab9e8c4d66c19ecff86 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403984 Reviewed-by: Johnni Winther Commit-Queue: Jens Johansen Reviewed-by: Brian Wilkerson --- .../lib/src/parser/parser_impl.dart | 116 ------- .../lib/src/scanner/abstract_scanner.dart | 31 +- .../test/macros/code_optimizer_test.dart | 1 - .../test/scanner_benchmark.dart | 3 - .../lib/src/dart/scanner/scanner.dart | 1 - .../test/generated/parser_test_base.dart | 5 +- .../lib/src/base/incremental_compiler.dart | 1 - pkg/front_end/lib/src/kernel/macro/macro.dart | 4 +- .../lib/src/source/source_loader.dart | 7 +- .../src/util/import_export_etc_helper.dart | 1 - .../lib/src/util/outline_extractor.dart | 5 +- pkg/front_end/lib/src/util/parser_ast.dart | 6 +- .../{non-nnbd => also-nnbd}/issue_39326.dart | 0 .../issue_39326.dart.expect | 0 .../issue_39326.dart.intertwined.expect | 0 .../issue_39326.dart.parser.expect | 0 .../issue_39326.dart.scanner.expect | 0 .../issue_40267_conditional.dart | 0 .../issue_40267_conditional.dart.expect | 0 ..._40267_conditional.dart.intertwined.expect | 0 ...issue_40267_conditional.dart.parser.expect | 0 ...ssue_40267_conditional.dart.scanner.expect | 0 .../issue_40267_conditional_2.dart | 0 .../issue_40267_conditional_2.dart.expect | 0 ...0267_conditional_2.dart.intertwined.expect | 0 ...sue_40267_conditional_2.dart.parser.expect | 0 ...ue_40267_conditional_2.dart.scanner.expect | 0 .../issue_40267_conditional_3.dart | 0 .../issue_40267_conditional_3.dart.expect | 0 ...0267_conditional_3.dart.intertwined.expect | 0 ...sue_40267_conditional_3.dart.parser.expect | 0 ...ue_40267_conditional_3.dart.scanner.expect | 0 .../issue_40267_conditional_4.dart | 0 .../issue_40267_conditional_4.dart.expect | 0 ...0267_conditional_4.dart.intertwined.expect | 0 ...sue_40267_conditional_4.dart.parser.expect | 0 ...ue_40267_conditional_4.dart.scanner.expect | 0 .../{non-nnbd => also-nnbd}/issue_40288.dart | 0 .../issue_40288.dart.expect | 39 ++- .../issue_40288.dart.intertwined.expect | 34 ++- .../issue_40288.dart.parser.expect | 8 +- .../issue_40288.dart.scanner.expect | 8 +- .../issue_40288_prime.dart | 0 .../issue_40288_prime.dart.expect | 0 .../issue_40288_prime.dart.intertwined.expect | 0 .../issue_40288_prime.dart.parser.expect | 0 .../issue_40288_prime.dart.scanner.expect | 0 .../nullable_type_argument.dart | 0 .../nullable_type_argument.dart.expect | 0 ...able_type_argument.dart.intertwined.expect | 0 .../nullable_type_argument.dart.parser.expect | 0 ...nullable_type_argument.dart.scanner.expect | 0 .../use_late_in_non_nnbd.dart | 0 .../use_late_in_non_nnbd.dart.expect | 118 +++---- ...e_late_in_non_nnbd.dart.intertwined.expect | 289 ++++++++---------- .../use_late_in_non_nnbd.dart.parser.expect | 61 ++++ .../use_late_in_non_nnbd.dart.scanner.expect | 61 ++++ .../use_required_in_non_nnbd.dart | 0 .../use_required_in_non_nnbd.dart.expect | 39 +-- ...quired_in_non_nnbd.dart.intertwined.expect | 32 +- ...se_required_in_non_nnbd.dart.parser.expect | 8 +- ...e_required_in_non_nnbd.dart.scanner.expect | 8 +- .../use_late_in_non_nnbd.dart.parser.expect | 61 ---- .../use_late_in_non_nnbd.dart.scanner.expect | 61 ---- .../crashing_test_case_minimizer_impl.dart | 91 +++--- pkg/front_end/test/lint_suite.dart | 3 +- .../test/parser/parser_ast_test.dart | 19 +- pkg/front_end/test/parser_suite.dart | 21 +- pkg/front_end/test/scanner_test.dart | 37 +-- pkg/front_end/test/testing/suite.dart | 1 - pkg/front_end/test/textual_outline_suite.dart | 2 - pkg/front_end/test/utils/kernel_chain.dart | 3 +- .../test/web_parser_git_test_helper.dart | 4 +- pkg/front_end/tool/coverage_merger.dart | 1 - pkg/front_end/tool/dart_doctest_impl.dart | 4 +- .../duplicate_code_finder_experiment.dart | 4 +- pkg/front_end/tool/fuzz/minimizer.dart | 1 - .../tool/parser_direct_ast/viewer.dart | 1 - 78 files changed, 463 insertions(+), 737 deletions(-) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_39326.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_39326.dart.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_39326.dart.intertwined.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_39326.dart.parser.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_39326.dart.scanner.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional.dart.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional.dart.intertwined.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional.dart.parser.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional.dart.scanner.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_2.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_2.dart.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_2.dart.intertwined.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_2.dart.parser.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_2.dart.scanner.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_3.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_3.dart.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_3.dart.intertwined.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_3.dart.parser.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_3.dart.scanner.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_4.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_4.dart.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_4.dart.intertwined.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_4.dart.parser.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40267_conditional_4.dart.scanner.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288.dart.expect (76%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288.dart.intertwined.expect (88%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288.dart.parser.expect (55%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288.dart.scanner.expect (55%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288_prime.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288_prime.dart.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288_prime.dart.intertwined.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288_prime.dart.parser.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/issue_40288_prime.dart.scanner.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/nullable_type_argument.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/nullable_type_argument.dart.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/nullable_type_argument.dart.intertwined.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/nullable_type_argument.dart.parser.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/nullable_type_argument.dart.scanner.expect (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/use_late_in_non_nnbd.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/use_late_in_non_nnbd.dart.expect (71%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/use_late_in_non_nnbd.dart.intertwined.expect (66%) create mode 100644 pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.parser.expect create mode 100644 pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.scanner.expect rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/use_required_in_non_nnbd.dart (100%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/use_required_in_non_nnbd.dart.expect (78%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/use_required_in_non_nnbd.dart.intertwined.expect (93%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/use_required_in_non_nnbd.dart.parser.expect (69%) rename pkg/front_end/parser_testcases/{non-nnbd => also-nnbd}/use_required_in_non_nnbd.dart.scanner.expect (69%) delete mode 100644 pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.parser.expect delete mode 100644 pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.scanner.expect diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart index dbc8460fc085..6985248563fe 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart @@ -1897,44 +1897,6 @@ class Parser { } } - /// Check if [token] is the usage of 'required' in a formal parameter in a - /// context where it's not legal (i.e. in non-nnbd-mode). - bool _isUseOfRequiredInNonNNBD(Token token) { - if (token.next is StringToken && token.next!.value() == "required") { - // Possible recovery: Figure out if we're in a situation like - // required covariant? name - // (in non-nnbd-mode) where the required modifier is not legal and thus - // would normally be parsed as the type. - token = token.next!; - Token next = token.next!; - // Skip modifiers. - while (next.isModifier) { - token = next; - next = next.next!; - } - // Parse the (potential) new type. - TypeInfo typeInfoAlternative = computeType( - token, - /* required = */ false, - /* inDeclaration = */ true, - ); - token = typeInfoAlternative.skipType(token); - next = token.next!; - - // We've essentially ignored the 'required' at this point. - // `token` is (in the good state) the last token of the type, - // `next` is (in the good state) the name; - // Are we in a 'good' state? - if (typeInfoAlternative != noType && - next.isIdentifier && - (next.next!.isA(TokenType.COMMA) || - next.next!.isA(TokenType.CLOSE_CURLY_BRACKET))) { - return true; - } - } - return false; - } - /// ``` /// normalFormalParameter: /// functionFormalParameter | @@ -1959,13 +1921,6 @@ class Parser { token = parseMetadataStar(token); Token? skippedNonRequiredRequired; - if (_isUseOfRequiredInNonNNBD(token)) { - skippedNonRequiredRequired = token.next!; - reportRecoverableErrorWithToken(skippedNonRequiredRequired, - codes.templateUnexpectedModifierInNonNnbd); - token = token.next!; - } - Token next = token.next!; Token start = next; @@ -3419,42 +3374,6 @@ class Parser { return parseTopLevelMemberImpl(token).next!; } - /// Check if [token] is the usage of 'late' before a field declaration in a - /// context where it's not legal (i.e. in non-nnbd-mode). - bool _isUseOfLateInNonNNBD(Token token) { - if (token is StringToken && token.value() == "late") { - // Possible recovery: Figure out if we're in a situation like - // late final? /var/const name [...] - // (in non-nnbd-mode) where the late modifier is not legal and thus would - // normally be parsed as the type. - Token next = token.next!; - // Skip modifiers. - while (next.isModifier) { - token = next; - next = next.next!; - } - // Parse the (potential) new type. - TypeInfo typeInfoAlternative = computeType( - token, - /* required = */ false, - /* inDeclaration = */ true, - ); - token = typeInfoAlternative.skipType(token); - next = token.next!; - - // We've essentially ignored the 'late' at this point. - // `token` is (in the good state) the last token of the type, - // `next` is (in the good state) the name; - // Are we in a 'good' state? - if (typeInfoAlternative != noType && - next.isIdentifier && - indicatesMethodOrField(next.next!)) { - return true; - } - } - return false; - } - Token parseTopLevelMemberImpl(Token token) { Token beforeStart = token; Token next = token.next!; @@ -3462,15 +3381,6 @@ class Parser { Token? skippedNonLateLate; - if (_isUseOfLateInNonNNBD(next)) { - skippedNonLateLate = next; - reportRecoverableErrorWithToken( - skippedNonLateLate, codes.templateUnexpectedModifierInNonNnbd); - token = token.next!; - beforeStart = token; - next = token.next!; - } - Token? externalToken; Token? augmentToken; Token? lateToken; @@ -4507,14 +4417,6 @@ class Parser { Token? skippedNonLateLate; - if (_isUseOfLateInNonNNBD(token.next!)) { - skippedNonLateLate = token.next!; - reportRecoverableErrorWithToken( - skippedNonLateLate, codes.templateUnexpectedModifierInNonNnbd); - token = token.next!; - beforeStart = token; - } - Token? covariantToken; Token? abstractToken; Token? augmentToken; @@ -8149,24 +8051,6 @@ class Parser { Token parseExpressionStatementOrDeclarationAfterModifiers(Token beforeType, Token start, Token? lateToken, Token? varFinalOrConst, TypeInfo? typeInfo, [ForPartsContext? forPartsContext]) { - // In simple cases check for bad 'late' modifier in non-nnbd-mode. - if (typeInfo == null && - lateToken == null && - varFinalOrConst == null && - beforeType == start && - _isUseOfLateInNonNNBD(beforeType.next!)) { - lateToken = beforeType.next!; - reportRecoverableErrorWithToken( - lateToken, codes.templateUnexpectedModifierInNonNnbd); - beforeType = start = beforeType.next!; - - // The below doesn't parse modifiers, so we need to do it here. - ModifierContext context = new ModifierContext(this); - beforeType = - start = context.parseVariableDeclarationModifiers(beforeType); - varFinalOrConst = context.varFinalOrConst; - } - if (allowPatterns && varFinalOrConst != null && (varFinalOrConst.isA(Keyword.VAR) || diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart index 4b3481b57fe0..f62ea6bac295 100644 --- a/pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart +++ b/pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart @@ -73,10 +73,6 @@ abstract class AbstractScanner implements Scanner { /// based upon the specified language version. final LanguageVersionChanged? languageVersionChanged; - /// Experimental flag for enabling scanning of NNBD tokens - /// such as 'required' and 'late'. - bool _enableNonNullable = false; - /// Experimental flag for enabling scanning of `>>>`. /// See https://github.com/dart-lang/language/issues/61 /// and https://github.com/dart-lang/language/issues/60 @@ -162,7 +158,6 @@ abstract class AbstractScanner implements Scanner { allowLazyStrings = true { this.tail = this.tokens; this.errorTail = this.tokens; - this._enableNonNullable = copyFrom._enableNonNullable; this._enableTripleShift = copyFrom._enableTripleShift; this.tokenStart = copyFrom.tokenStart; this.groupingStack = copyFrom.groupingStack; @@ -171,7 +166,6 @@ abstract class AbstractScanner implements Scanner { @override set configuration(ScannerConfiguration? config) { if (config != null) { - _enableNonNullable = config.enableNonNullable; _enableTripleShift = config.enableTripleShift; _forAugmentationLibrary = config.forAugmentationLibrary; } @@ -1048,11 +1042,9 @@ abstract class AbstractScanner implements Scanner { $EQ, TokenType.QUESTION_QUESTION_EQ, TokenType.QUESTION_QUESTION); } else if (next == $PERIOD) { next = advance(); - if (_enableNonNullable) { - if ($PERIOD == next) { - appendPrecedenceToken(TokenType.QUESTION_PERIOD_PERIOD); - return advance(); - } + if ($PERIOD == next) { + appendPrecedenceToken(TokenType.QUESTION_PERIOD_PERIOD); + return advance(); } appendPrecedenceToken(TokenType.QUESTION_PERIOD); return next; @@ -1572,10 +1564,6 @@ abstract class AbstractScanner implements Scanner { if (languageVersionChanged != null) { // TODO(danrubel): make this required and remove the languageVersion field languageVersionChanged!(this, languageVersion); - } else { - // TODO(danrubel): remove this hack and require listener to update - // the scanner's configuration. - configuration = ScannerConfiguration.classic; } if (includeComments) { _appendToCommentStream(languageVersion); @@ -1740,10 +1728,6 @@ abstract class AbstractScanner implements Scanner { if (keyword == null) { return tokenizeIdentifier(next, start, allowDollar); } - if (!_enableNonNullable && - (keyword == Keyword.LATE || keyword == Keyword.REQUIRED)) { - return tokenizeIdentifier(next, start, allowDollar); - } if (!_forAugmentationLibrary && keyword == Keyword.AUGMENT) { return tokenizeIdentifier(next, start, allowDollar); } @@ -2160,13 +2144,7 @@ class LineStarts extends Object with ListMixin { /// [ScannerConfiguration] contains information for configuring which tokens /// the scanner produces based upon the Dart language level. class ScannerConfiguration { - static const ScannerConfiguration classic = const ScannerConfiguration(); - static const ScannerConfiguration nonNullable = - const ScannerConfiguration(enableNonNullable: true); - - /// Experimental flag for enabling scanning of NNBD tokens - /// such as 'required' and 'late' - final bool enableNonNullable; + static const ScannerConfiguration nonNullable = const ScannerConfiguration(); /// Experimental flag for enabling scanning of `>>>`. /// See https://github.com/dart-lang/language/issues/61 @@ -2177,7 +2155,6 @@ class ScannerConfiguration { final bool forAugmentationLibrary; const ScannerConfiguration({ - this.enableNonNullable = false, this.enableTripleShift = false, this.forAugmentationLibrary = false, }); diff --git a/pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart b/pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart index 0be2a0368b25..60ad5c14bc4b 100644 --- a/pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart +++ b/pkg/_fe_analyzer_shared/test/macros/code_optimizer_test.dart @@ -740,7 +740,6 @@ void assertEdits({ code, libraryDeclarationNames: libraryDeclarationNames, scannerConfiguration: ScannerConfiguration( - enableNonNullable: true, forAugmentationLibrary: true, ), throwIfHasErrors: throwIfHasErrors, diff --git a/pkg/_fe_analyzer_shared/test/scanner_benchmark.dart b/pkg/_fe_analyzer_shared/test/scanner_benchmark.dart index d2694a880663..c6b9abb12190 100644 --- a/pkg/_fe_analyzer_shared/test/scanner_benchmark.dart +++ b/pkg/_fe_analyzer_shared/test/scanner_benchmark.dart @@ -53,7 +53,6 @@ void main(List args) { hasErrors = scanString( content, configuration: new ScannerConfiguration( - enableNonNullable: true, enableTripleShift: true, ), includeComments: true, @@ -65,7 +64,6 @@ void main(List args) { hasErrors = scan( contentBytes, configuration: new ScannerConfiguration( - enableNonNullable: true, enableTripleShift: true, ), includeComments: true, @@ -78,7 +76,6 @@ void main(List args) { hasErrors = scan( tmp, configuration: new ScannerConfiguration( - enableNonNullable: true, enableTripleShift: true, ), includeComments: true, diff --git a/pkg/analyzer/lib/src/dart/scanner/scanner.dart b/pkg/analyzer/lib/src/dart/scanner/scanner.dart index 99d3b1726cc5..4e9757e3b643 100644 --- a/pkg/analyzer/lib/src/dart/scanner/scanner.dart +++ b/pkg/analyzer/lib/src/dart/scanner/scanner.dart @@ -200,7 +200,6 @@ class Scanner { ? fasta.ScannerConfiguration() : fasta.ScannerConfiguration( enableTripleShift: featureSet.isEnabled(Feature.triple_shift), - enableNonNullable: featureSet.isEnabled(Feature.non_nullable), forAugmentationLibrary: featureSet.isEnabled(Feature.macros), ); } diff --git a/pkg/analyzer/test/generated/parser_test_base.dart b/pkg/analyzer/test/generated/parser_test_base.dart index 17e1f3e5c4c3..9c16e8e87efc 100644 --- a/pkg/analyzer/test/generated/parser_test_base.dart +++ b/pkg/analyzer/test/generated/parser_test_base.dart @@ -257,10 +257,7 @@ class FastaParserTestCase var languageVersion = LibraryLanguageVersion( package: ExperimentStatus.currentVersion, override: null); var result = scanString(content, - configuration: featureSet.isEnabled(Feature.non_nullable) - ? ScannerConfiguration.nonNullable - : ScannerConfiguration.classic, - includeComments: true, + configuration: ScannerConfiguration.nonNullable, includeComments: true, languageVersionChanged: (scanner, overrideVersion) { languageVersion = LibraryLanguageVersion( package: ExperimentStatus.currentVersion, diff --git a/pkg/front_end/lib/src/base/incremental_compiler.dart b/pkg/front_end/lib/src/base/incremental_compiler.dart index fea1ed6376f8..746be2d9f3aa 100644 --- a/pkg/front_end/lib/src/base/incremental_compiler.dart +++ b/pkg/front_end/lib/src/base/incremental_compiler.dart @@ -1232,7 +1232,6 @@ class IncrementalCompiler implements IncrementalKernelGenerator { return null; } ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableNonNullable: true /* can't be disabled */, enableTripleShift: /* should this be on the library? */ /* this is effectively what the constant evaluator does */ diff --git a/pkg/front_end/lib/src/kernel/macro/macro.dart b/pkg/front_end/lib/src/kernel/macro/macro.dart index 4cb320709a03..b6019ee01b11 100644 --- a/pkg/front_end/lib/src/kernel/macro/macro.dart +++ b/pkg/front_end/lib/src/kernel/macro/macro.dart @@ -1355,9 +1355,7 @@ class MacroApplications { ScannerResult scannerResult = scan(sourceUtf8, configuration: new ScannerConfiguration( - enableNonNullable: true, - enableTripleShift: true, - forAugmentationLibrary: true)); + enableTripleShift: true, forAugmentationLibrary: true)); _sourceLoader.target.addSourceInformation(augmentationImportUri, augmentationFileUri, scannerResult.lineStarts, sourceUtf8); for (Uri intermediateAugmentationUri in intermediateAugmentationUris) { diff --git a/pkg/front_end/lib/src/source/source_loader.dart b/pkg/front_end/lib/src/source/source_loader.dart index d73c8e9e6315..7d2dc9fa9182 100644 --- a/pkg/front_end/lib/src/source/source_loader.dart +++ b/pkg/front_end/lib/src/source/source_loader.dart @@ -1051,10 +1051,6 @@ severity: $severity ExperimentalFlag.tripleShift, compilationUnit.importUri, compilationUnit.packageLanguageVersion.version), - enableNonNullable: target.isExperimentEnabledInLibraryByVersion( - ExperimentalFlag.nonNullable, - compilationUnit.importUri, - compilationUnit.packageLanguageVersion.version), forAugmentationLibrary: compilationUnit.forAugmentationLibrary), languageVersionChanged: (Scanner scanner, LanguageVersionToken version) { @@ -1066,8 +1062,7 @@ severity: $severity } scanner.configuration = new ScannerConfiguration( enableTripleShift: - compilationUnit.libraryFeatures.tripleShift.isEnabled, - enableNonNullable: true); + compilationUnit.libraryFeatures.tripleShift.isEnabled); }, allowLazyStrings: allowLazyStrings); Token token = result.tokens; if (!suppressLexicalErrors) { diff --git a/pkg/front_end/lib/src/util/import_export_etc_helper.dart b/pkg/front_end/lib/src/util/import_export_etc_helper.dart index a429c46785b6..07d934f93cc5 100644 --- a/pkg/front_end/lib/src/util/import_export_etc_helper.dart +++ b/pkg/front_end/lib/src/util/import_export_etc_helper.dart @@ -13,7 +13,6 @@ FileInfoHelper getFileInfoHelper(Uint8List rawBytes) { new ImportExportPartLibraryHelperVisitor(); getAST( rawBytes, - enableNonNullable: true, enableTripleShift: true, includeBody: false, includeComments: false, diff --git a/pkg/front_end/lib/src/util/outline_extractor.dart b/pkg/front_end/lib/src/util/outline_extractor.dart index c1cdd781e849..0a31ca7e1c82 100644 --- a/pkg/front_end/lib/src/util/outline_extractor.dart +++ b/pkg/front_end/lib/src/util/outline_extractor.dart @@ -134,8 +134,8 @@ class _Processor { await fileSystem.entityForUri(fileUri).readAsBytes(); // TODO: Support updating the configuration; also default it to match // the package version. - final ScannerConfiguration configuration = new ScannerConfiguration( - enableNonNullable: true, enableTripleShift: true); + final ScannerConfiguration configuration = + new ScannerConfiguration(enableTripleShift: true); textualOutlineStopwatch.start(); final String? outlined = textualOutline(bytes, configuration, enablePatterns: true); @@ -145,7 +145,6 @@ class _Processor { getAstStopwatch.start(); List languageVersionsSeen = []; final ParserAstNode ast = getAST(bytes2, - enableNonNullable: configuration.enableNonNullable, enableTripleShift: configuration.enableTripleShift, languageVersionsSeen: languageVersionsSeen); getAstStopwatch.stop(); diff --git a/pkg/front_end/lib/src/util/parser_ast.dart b/pkg/front_end/lib/src/util/parser_ast.dart index 77aeeee3a74e..be798f3e9680 100644 --- a/pkg/front_end/lib/src/util/parser_ast.dart +++ b/pkg/front_end/lib/src/util/parser_ast.dart @@ -28,15 +28,13 @@ CompilationUnitEnd getAST( Uint8List rawBytes, { bool includeBody = true, bool includeComments = false, - bool enableNonNullable = false, bool enableTripleShift = false, bool allowPatterns = false, List? languageVersionsSeen, List? lineStarts, }) { - ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableNonNullable: enableNonNullable, - enableTripleShift: enableTripleShift); + ScannerConfiguration scannerConfiguration = + new ScannerConfiguration(enableTripleShift: enableTripleShift); Utf8BytesScanner scanner = new Utf8BytesScanner( rawBytes, diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart b/pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart rename to pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.intertwined.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.intertwined.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.parser.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.parser.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.scanner.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_39326.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.scanner.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.intertwined.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.intertwined.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.parser.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.parser.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.scanner.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.scanner.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.intertwined.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.intertwined.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.parser.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.parser.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.scanner.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_2.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.scanner.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.intertwined.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.intertwined.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.parser.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.parser.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.scanner.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_3.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.scanner.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart.intertwined.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart.intertwined.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart.parser.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart.parser.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart.scanner.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40267_conditional_4.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_4.dart.scanner.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.expect similarity index 76% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.expect index 6ac79492d62e..a846e0d72353 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.expect @@ -1,7 +1,30 @@ +Problems reported: + +parser/also-nnbd/issue_40288:1:7: Can't use 'late' as a name here. +class late { + ^^^^ + +parser/also-nnbd/issue_40288:5:7: Can't use 'required' as a name here. +class required { + ^^^^^^^^ + +parser/also-nnbd/issue_40288:10:8: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. + late l = late(); + ^ + +parser/also-nnbd/issue_40288:11:3: Can't have modifier 'required' here. + required r = required(); + ^^^^^^^^ + +parser/also-nnbd/issue_40288:11:12: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. + required r = required(); + ^ + beginCompilationUnit(class) beginMetadataStar(class) endMetadataStar(0) beginClassOrMixinOrNamedMixinApplicationPrelude(class) + handleRecoverableError(Message[BuiltInIdentifierInDeclaration, Can't use 'late' as a name here., null, {lexeme: late}], late, late) handleIdentifier(late, classOrMixinDeclaration) handleNoTypeVariables({) beginClassDeclaration(class, null, null, null, null, null, null, null, null, late) @@ -33,6 +56,7 @@ beginCompilationUnit(class) beginMetadataStar(class) endMetadataStar(0) beginClassOrMixinOrNamedMixinApplicationPrelude(class) + handleRecoverableError(Message[BuiltInIdentifierInDeclaration, Can't use 'required' as a name here., null, {lexeme: required}], required, required) handleIdentifier(required, classOrMixinDeclaration) handleNoTypeVariables({) beginClassDeclaration(class, null, null, null, null, null, null, null, null, required) @@ -76,10 +100,9 @@ beginCompilationUnit(class) beginMetadataStar(late) endMetadataStar(0) beginMember() - beginFields(DeclarationKind.Class, null, null, null, null, null, null, null, {) - handleIdentifier(late, typeReference) - handleNoTypeArguments(l) - handleType(late, null) + beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, {) + handleRecoverableError(MissingConstFinalVarOrType, l, l) + handleNoType(late) handleIdentifier(l, fieldDeclaration) beginFieldInitializer(=) handleIdentifier(late, expression) @@ -88,15 +111,15 @@ beginCompilationUnit(class) endArguments(0, (, )) handleSend(late, )) endFieldInitializer(=, )) - endClassFields(null, null, null, null, null, null, null, 1, late, ;) + endClassFields(null, null, null, null, null, late, null, 1, late, ;) endMember() beginMetadataStar(required) endMetadataStar(0) + handleRecoverableError(Message[ExtraneousModifier, Can't have modifier 'required' here., Try removing 'required'., {lexeme: required}], required, required) beginMember() beginFields(DeclarationKind.Class, null, null, null, null, null, null, null, ;) - handleIdentifier(required, typeReference) - handleNoTypeArguments(r) - handleType(required, null) + handleRecoverableError(MissingConstFinalVarOrType, r, r) + handleNoType(required) handleIdentifier(r, fieldDeclaration) beginFieldInitializer(=) handleIdentifier(required, expression) diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.intertwined.expect similarity index 88% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.intertwined.expect index 8a65b2517af0..448eb527d9ef 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.intertwined.expect @@ -10,6 +10,8 @@ parseUnit(class) parseClassOrNamedMixinApplication(class, null, null, null, null, null, null, null, null, class) listener: beginClassOrMixinOrNamedMixinApplicationPrelude(class) ensureIdentifier(class, classOrMixinDeclaration) + reportRecoverableErrorWithToken(late, Template(BuiltInIdentifierInDeclaration)) + listener: handleRecoverableError(Message[BuiltInIdentifierInDeclaration, Can't use 'late' as a name here., null, {lexeme: late}], late, late) listener: handleIdentifier(late, classOrMixinDeclaration) listener: handleNoTypeVariables({) listener: beginClassDeclaration(class, null, null, null, null, null, null, null, null, late) @@ -74,6 +76,8 @@ parseUnit(class) parseClassOrNamedMixinApplication(class, null, null, null, null, null, null, null, null, class) listener: beginClassOrMixinOrNamedMixinApplicationPrelude(class) ensureIdentifier(class, classOrMixinDeclaration) + reportRecoverableErrorWithToken(required, Template(BuiltInIdentifierInDeclaration)) + listener: handleRecoverableError(Message[BuiltInIdentifierInDeclaration, Can't use 'required' as a name here., null, {lexeme: required}], required, required) listener: handleIdentifier(required, classOrMixinDeclaration) listener: handleNoTypeVariables({) listener: beginClassDeclaration(class, null, null, null, null, null, null, null, null, required) @@ -159,24 +163,27 @@ parseUnit(class) listener: beginMetadataStar(late) listener: endMetadataStar(0) listener: beginMember() - parseFields({, null, null, null, null, null, null, null, {, SimpleType(), l, DeclarationKind.Class, C, false) - listener: beginFields(DeclarationKind.Class, null, null, null, null, null, null, null, {) - listener: handleIdentifier(late, typeReference) - listener: handleNoTypeArguments(l) - listener: handleType(late, null) + isReservedKeyword(=) + parseFields({, null, null, null, null, null, late, null, late, NoType(), l, DeclarationKind.Class, C, false) + listener: beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, {) + reportRecoverableError(l, MissingConstFinalVarOrType) + listener: handleRecoverableError(MissingConstFinalVarOrType, l, l) + listener: handleNoType(late) ensureIdentifierPotentiallyRecovered(late, fieldDeclaration, false) listener: handleIdentifier(l, fieldDeclaration) - parseFieldInitializerOpt(l, l, null, null, null, null, null, DeclarationKind.Class, C) + parseFieldInitializerOpt(l, l, late, null, null, null, null, DeclarationKind.Class, C) listener: beginFieldInitializer(=) parseExpression(=) parsePrecedenceExpression(=, 1, true, ConstantPatternContext.none) parseUnaryExpression(=, true, ConstantPatternContext.none) parsePrimary(=, expression, ConstantPatternContext.none) + inPlainSync() parseSendOrFunctionLiteral(=, expression, ConstantPatternContext.none) looksLikeFunctionBody(;) parseSend(=, expression, ConstantPatternContext.none) isNextIdentifier(=) ensureIdentifier(=, expression) + inPlainSync() listener: handleIdentifier(late, expression) listener: handleNoTypeArguments(() parseArgumentsOpt(late) @@ -186,19 +193,22 @@ parseUnit(class) listener: endArguments(0, (, )) listener: handleSend(late, )) listener: endFieldInitializer(=, )) - listener: endClassFields(null, null, null, null, null, null, null, 1, late, ;) + listener: endClassFields(null, null, null, null, null, late, null, 1, late, ;) listener: endMember() notEofOrValue(}, required) parseClassOrMixinOrExtensionOrEnumMemberImpl(;, DeclarationKind.Class, C) parseMetadataStar(;) listener: beginMetadataStar(required) listener: endMetadataStar(0) + reportRecoverableErrorWithToken(required, Template(ExtraneousModifier)) + listener: handleRecoverableError(Message[ExtraneousModifier, Can't have modifier 'required' here., Try removing 'required'., {lexeme: required}], required, required) listener: beginMember() - parseFields(;, null, null, null, null, null, null, null, ;, SimpleType(), r, DeclarationKind.Class, C, false) + isReservedKeyword(=) + parseFields(;, null, null, null, null, null, null, null, required, NoType(), r, DeclarationKind.Class, C, false) listener: beginFields(DeclarationKind.Class, null, null, null, null, null, null, null, ;) - listener: handleIdentifier(required, typeReference) - listener: handleNoTypeArguments(r) - listener: handleType(required, null) + reportRecoverableError(r, MissingConstFinalVarOrType) + listener: handleRecoverableError(MissingConstFinalVarOrType, r, r) + listener: handleNoType(required) ensureIdentifierPotentiallyRecovered(required, fieldDeclaration, false) listener: handleIdentifier(r, fieldDeclaration) parseFieldInitializerOpt(r, r, null, null, null, null, null, DeclarationKind.Class, C) @@ -207,11 +217,13 @@ parseUnit(class) parsePrecedenceExpression(=, 1, true, ConstantPatternContext.none) parseUnaryExpression(=, true, ConstantPatternContext.none) parsePrimary(=, expression, ConstantPatternContext.none) + inPlainSync() parseSendOrFunctionLiteral(=, expression, ConstantPatternContext.none) looksLikeFunctionBody(;) parseSend(=, expression, ConstantPatternContext.none) isNextIdentifier(=) ensureIdentifier(=, expression) + inPlainSync() listener: handleIdentifier(required, expression) listener: handleNoTypeArguments(() parseArgumentsOpt(required) diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.parser.expect similarity index 55% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.parser.expect index ffd3e653774b..c66134062ebf 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.parser.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.parser.expect @@ -12,16 +12,16 @@ required r = required(); } -class[KeywordToken] late[StringToken] {[BeginToken] +class[KeywordToken] late[KeywordToken] {[BeginToken] int[StringToken] get[KeywordToken] g[StringToken] =>[SimpleToken] 1[StringToken];[SimpleToken] }[SimpleToken] -class[KeywordToken] required[StringToken] {[BeginToken] +class[KeywordToken] required[KeywordToken] {[BeginToken] int[StringToken] get[KeywordToken] g[StringToken] =>[SimpleToken] 2[StringToken];[SimpleToken] }[SimpleToken] class[KeywordToken] C[StringToken] {[BeginToken] -late[StringToken] l[StringToken] =[SimpleToken] late[StringToken]([BeginToken])[SimpleToken];[SimpleToken] -required[StringToken] r[StringToken] =[SimpleToken] required[StringToken]([BeginToken])[SimpleToken];[SimpleToken] +late[KeywordToken] l[StringToken] =[SimpleToken] late[KeywordToken]([BeginToken])[SimpleToken];[SimpleToken] +required[KeywordToken] r[StringToken] =[SimpleToken] required[KeywordToken]([BeginToken])[SimpleToken];[SimpleToken] }[SimpleToken] [SimpleToken] diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.scanner.expect similarity index 55% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.scanner.expect index ffd3e653774b..c66134062ebf 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/issue_40288.dart.scanner.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/issue_40288.dart.scanner.expect @@ -12,16 +12,16 @@ required r = required(); } -class[KeywordToken] late[StringToken] {[BeginToken] +class[KeywordToken] late[KeywordToken] {[BeginToken] int[StringToken] get[KeywordToken] g[StringToken] =>[SimpleToken] 1[StringToken];[SimpleToken] }[SimpleToken] -class[KeywordToken] required[StringToken] {[BeginToken] +class[KeywordToken] required[KeywordToken] {[BeginToken] int[StringToken] get[KeywordToken] g[StringToken] =>[SimpleToken] 2[StringToken];[SimpleToken] }[SimpleToken] class[KeywordToken] C[StringToken] {[BeginToken] -late[StringToken] l[StringToken] =[SimpleToken] late[StringToken]([BeginToken])[SimpleToken];[SimpleToken] -required[StringToken] r[StringToken] =[SimpleToken] required[StringToken]([BeginToken])[SimpleToken];[SimpleToken] +late[KeywordToken] l[StringToken] =[SimpleToken] late[KeywordToken]([BeginToken])[SimpleToken];[SimpleToken] +required[KeywordToken] r[StringToken] =[SimpleToken] required[KeywordToken]([BeginToken])[SimpleToken];[SimpleToken] }[SimpleToken] [SimpleToken] diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart b/pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart.intertwined.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart.intertwined.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart.parser.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart.parser.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart.scanner.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/issue_40288_prime.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/issue_40288_prime.dart.scanner.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart b/pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart rename to pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart.intertwined.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart.intertwined.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart.parser.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart.parser.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart.scanner.expect similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/nullable_type_argument.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/nullable_type_argument.dart.scanner.expect diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart rename to pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.expect similarity index 71% rename from pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.expect index cb7e1c8a2f79..f40774ef2a2f 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.expect @@ -1,62 +1,38 @@ Problems reported: -parser/non-nnbd/use_late_in_non_nnbd:4:1: The modifier 'late' is only available in null safe libraries. -late int x2; -^^^^ - -parser/non-nnbd/use_late_in_non_nnbd:5:1: The modifier 'late' is only available in null safe libraries. -late List x3; -^^^^ +parser/also-nnbd/use_late_in_non_nnbd:7:6: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. +late x5; + ^^ -parser/non-nnbd/use_late_in_non_nnbd:6:1: The modifier 'late' is only available in null safe libraries. -late final int x4; -^^^^ - -parser/non-nnbd/use_late_in_non_nnbd:8:1: Unexpected token ';'. +parser/also-nnbd/use_late_in_non_nnbd:8:1: Unexpected token ';'. ; // Meant to confuse so `.next`-ing makes it look like the end of a field. ^ -parser/non-nnbd/use_late_in_non_nnbd:9:1: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. +parser/also-nnbd/use_late_in_non_nnbd:9:1: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. late; ^^^^ -parser/non-nnbd/use_late_in_non_nnbd:10:1: Unexpected token ';'. +parser/also-nnbd/use_late_in_non_nnbd:10:1: Unexpected token ';'. ; // Meant to confuse so `.next`-ing makes it look like the end of a field. ^ -parser/non-nnbd/use_late_in_non_nnbd:14:3: The modifier 'late' is only available in null safe libraries. - late int y2; - ^^^^ +parser/also-nnbd/use_late_in_non_nnbd:17:8: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. + late y5; + ^^ -parser/non-nnbd/use_late_in_non_nnbd:15:3: The modifier 'late' is only available in null safe libraries. - late List y3; - ^^^^ - -parser/non-nnbd/use_late_in_non_nnbd:16:3: The modifier 'late' is only available in null safe libraries. - late final int y4; - ^^^^ - -parser/non-nnbd/use_late_in_non_nnbd:25:3: The modifier 'late' is only available in null safe libraries. - late int z2; - ^^^^ - -parser/non-nnbd/use_late_in_non_nnbd:26:3: The modifier 'late' is only available in null safe libraries. - late List x3; - ^^^^ +parser/also-nnbd/use_late_in_non_nnbd:28:8: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. + late z5; + ^^ -parser/non-nnbd/use_late_in_non_nnbd:27:3: The modifier 'late' is only available in null safe libraries. - late final int z4; - ^^^^ - -parser/non-nnbd/use_late_in_non_nnbd:29:3: Expected a class member, but got ';'. +parser/also-nnbd/use_late_in_non_nnbd:29:3: Expected a class member, but got ';'. ; // Meant to confuse so `.next`-ing makes it look like the end of a field. ^ -parser/non-nnbd/use_late_in_non_nnbd:30:3: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. +parser/also-nnbd/use_late_in_non_nnbd:30:3: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. late; ^^^^ -parser/non-nnbd/use_late_in_non_nnbd:31:3: Expected a class member, but got ';'. +parser/also-nnbd/use_late_in_non_nnbd:31:3: Expected a class member, but got ';'. ; // Meant to confuse so `.next`-ing makes it look like the end of a field. ^ @@ -75,20 +51,18 @@ beginCompilationUnit(int) beginMetadataStar(late) endMetadataStar(0) beginTopLevelMember(late) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, late) + beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, ;) handleIdentifier(int, typeReference) handleNoTypeArguments(x2) handleType(int, null) handleIdentifier(x2, topLevelVariableDeclaration) handleNoFieldInitializer(;) - endTopLevelFields(null, null, null, null, late, null, 1, int, ;) + endTopLevelFields(null, null, null, null, late, null, 1, late, ;) endTopLevelDeclaration(;) beginMetadataStar(late) endMetadataStar(0) beginTopLevelMember(late) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, late) + beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, ;) handleIdentifier(List, typeReference) beginTypeArguments(<) handleIdentifier(int, typeReference) @@ -98,30 +72,28 @@ beginCompilationUnit(int) handleType(List, null) handleIdentifier(x3, topLevelVariableDeclaration) handleNoFieldInitializer(;) - endTopLevelFields(null, null, null, null, late, null, 1, List, ;) + endTopLevelFields(null, null, null, null, late, null, 1, late, ;) endTopLevelDeclaration(;) beginMetadataStar(late) endMetadataStar(0) beginTopLevelMember(late) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, final, late) + beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, final, ;) handleIdentifier(int, typeReference) handleNoTypeArguments(x4) handleType(int, null) handleIdentifier(x4, topLevelVariableDeclaration) handleNoFieldInitializer(;) - endTopLevelFields(null, null, null, null, late, final, 1, final, ;) + endTopLevelFields(null, null, null, null, late, final, 1, late, ;) endTopLevelDeclaration(;) beginMetadataStar(late) endMetadataStar(0) beginTopLevelMember(late) - beginFields(DeclarationKind.TopLevel, null, null, null, null, null, null, null, ;) - handleIdentifier(late, typeReference) - handleNoTypeArguments(x5) - handleType(late, null) + beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, ;) + handleRecoverableError(MissingConstFinalVarOrType, x5, x5) + handleNoType(late) handleIdentifier(x5, topLevelVariableDeclaration) handleNoFieldInitializer(;) - endTopLevelFields(null, null, null, null, null, null, 1, late, ;) + endTopLevelFields(null, null, null, null, late, null, 1, late, ;) endTopLevelDeclaration(;) beginMetadataStar(;) endMetadataStar(0) @@ -180,8 +152,7 @@ beginCompilationUnit(int) handleNoVariableInitializer(y1) endInitializedIdentifier(y1) endVariablesDeclaration(1, ;) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - beginMetadataStar(int) + beginMetadataStar(late) endMetadataStar(0) handleIdentifier(int, typeReference) handleNoTypeArguments(y2) @@ -192,8 +163,7 @@ beginCompilationUnit(int) handleNoVariableInitializer(y2) endInitializedIdentifier(y2) endVariablesDeclaration(1, ;) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - beginMetadataStar(List) + beginMetadataStar(late) endMetadataStar(0) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -208,8 +178,7 @@ beginCompilationUnit(int) handleNoVariableInitializer(y3) endInitializedIdentifier(y3) endVariablesDeclaration(1, ;) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - beginMetadataStar(int) + beginMetadataStar(late) endMetadataStar(0) handleIdentifier(int, typeReference) handleNoTypeArguments(y4) @@ -220,12 +189,11 @@ beginCompilationUnit(int) handleNoVariableInitializer(y4) endInitializedIdentifier(y4) endVariablesDeclaration(1, ;) + handleRecoverableError(MissingConstFinalVarOrType, y5, y5) beginMetadataStar(late) endMetadataStar(0) - handleIdentifier(late, typeReference) - handleNoTypeArguments(y5) - handleType(late, null) - beginVariablesDeclaration(y5, null, null) + handleNoType(late) + beginVariablesDeclaration(y5, late, null) handleIdentifier(y5, localVariableDeclaration) beginInitializedIdentifier(y5) handleNoVariableInitializer(y5) @@ -266,21 +234,19 @@ beginCompilationUnit(int) endMember() beginMetadataStar(late) endMetadataStar(0) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) beginMember() - beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, late) + beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, ;) handleIdentifier(int, typeReference) handleNoTypeArguments(z2) handleType(int, null) handleIdentifier(z2, fieldDeclaration) handleNoFieldInitializer(;) - endClassFields(null, null, null, null, null, late, null, 1, int, ;) + endClassFields(null, null, null, null, null, late, null, 1, late, ;) endMember() beginMetadataStar(late) endMetadataStar(0) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) beginMember() - beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, late) + beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, ;) handleIdentifier(List, typeReference) beginTypeArguments(<) handleIdentifier(int, typeReference) @@ -290,30 +256,28 @@ beginCompilationUnit(int) handleType(List, null) handleIdentifier(x3, fieldDeclaration) handleNoFieldInitializer(;) - endClassFields(null, null, null, null, null, late, null, 1, List, ;) + endClassFields(null, null, null, null, null, late, null, 1, late, ;) endMember() beginMetadataStar(late) endMetadataStar(0) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) beginMember() - beginFields(DeclarationKind.Class, null, null, null, null, null, late, final, late) + beginFields(DeclarationKind.Class, null, null, null, null, null, late, final, ;) handleIdentifier(int, typeReference) handleNoTypeArguments(z4) handleType(int, null) handleIdentifier(z4, fieldDeclaration) handleNoFieldInitializer(;) - endClassFields(null, null, null, null, null, late, final, 1, final, ;) + endClassFields(null, null, null, null, null, late, final, 1, late, ;) endMember() beginMetadataStar(late) endMetadataStar(0) beginMember() - beginFields(DeclarationKind.Class, null, null, null, null, null, null, null, ;) - handleIdentifier(late, typeReference) - handleNoTypeArguments(z5) - handleType(late, null) + beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, ;) + handleRecoverableError(MissingConstFinalVarOrType, z5, z5) + handleNoType(late) handleIdentifier(z5, fieldDeclaration) handleNoFieldInitializer(;) - endClassFields(null, null, null, null, null, null, null, 1, late, ;) + endClassFields(null, null, null, null, null, late, null, 1, late, ;) endMember() beginMetadataStar(;) endMetadataStar(0) diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.intertwined.expect similarity index 66% rename from pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.intertwined.expect index b42daacd8c25..836bda4b2fbf 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.intertwined.expect @@ -25,11 +25,8 @@ parseUnit(int) listener: endMetadataStar(0) parseTopLevelMemberImpl(;) listener: beginTopLevelMember(late) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - parseFields(late, null, null, null, null, null, late, null, late, SimpleType(), x2, DeclarationKind.TopLevel, null, false) - listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, late) + parseFields(;, null, null, null, null, null, late, null, late, SimpleType(), x2, DeclarationKind.TopLevel, null, false) + listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, ;) listener: handleIdentifier(int, typeReference) listener: handleNoTypeArguments(x2) listener: handleType(int, null) @@ -37,7 +34,7 @@ parseUnit(int) listener: handleIdentifier(x2, topLevelVariableDeclaration) parseFieldInitializerOpt(x2, x2, late, null, null, null, null, DeclarationKind.TopLevel, null) listener: handleNoFieldInitializer(;) - listener: endTopLevelFields(null, null, null, null, late, null, 1, int, ;) + listener: endTopLevelFields(null, null, null, null, late, null, 1, late, ;) listener: endTopLevelDeclaration(;) parseTopLevelDeclarationImpl(;, DirectiveContext(DirectiveState.Declarations)) parseMetadataStar(;) @@ -45,11 +42,8 @@ parseUnit(int) listener: endMetadataStar(0) parseTopLevelMemberImpl(;) listener: beginTopLevelMember(late) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - parseFields(late, null, null, null, null, null, late, null, late, SimpleTypeWith1Argument(typeArg: SimpleTypeArgument1()), x3, DeclarationKind.TopLevel, null, false) - listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, late) + parseFields(;, null, null, null, null, null, late, null, late, SimpleTypeWith1Argument(typeArg: SimpleTypeArgument1()), x3, DeclarationKind.TopLevel, null, false) + listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, ;) listener: handleIdentifier(List, typeReference) listener: beginTypeArguments(<) listener: handleIdentifier(int, typeReference) @@ -61,7 +55,7 @@ parseUnit(int) listener: handleIdentifier(x3, topLevelVariableDeclaration) parseFieldInitializerOpt(x3, x3, late, null, null, null, null, DeclarationKind.TopLevel, null) listener: handleNoFieldInitializer(;) - listener: endTopLevelFields(null, null, null, null, late, null, 1, List, ;) + listener: endTopLevelFields(null, null, null, null, late, null, 1, late, ;) listener: endTopLevelDeclaration(;) parseTopLevelDeclarationImpl(;, DirectiveContext(DirectiveState.Declarations)) parseMetadataStar(;) @@ -69,13 +63,10 @@ parseUnit(int) listener: endMetadataStar(0) parseTopLevelMemberImpl(;) listener: beginTopLevelMember(late) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) skipOuterPattern(final) skipObjectPatternRest(int) - parseFields(late, null, null, null, null, null, late, final, final, SimpleType(), x4, DeclarationKind.TopLevel, null, false) - listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, final, late) + parseFields(;, null, null, null, null, null, late, final, final, SimpleType(), x4, DeclarationKind.TopLevel, null, false) + listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, final, ;) listener: handleIdentifier(int, typeReference) listener: handleNoTypeArguments(x4) listener: handleType(int, null) @@ -83,7 +74,7 @@ parseUnit(int) listener: handleIdentifier(x4, topLevelVariableDeclaration) parseFieldInitializerOpt(x4, x4, late, null, null, null, final, DeclarationKind.TopLevel, null) listener: handleNoFieldInitializer(;) - listener: endTopLevelFields(null, null, null, null, late, final, 1, final, ;) + listener: endTopLevelFields(null, null, null, null, late, final, 1, late, ;) listener: endTopLevelDeclaration(;) parseTopLevelDeclarationImpl(;, DirectiveContext(DirectiveState.Declarations)) parseMetadataStar(;) @@ -91,16 +82,17 @@ parseUnit(int) listener: endMetadataStar(0) parseTopLevelMemberImpl(;) listener: beginTopLevelMember(late) - parseFields(;, null, null, null, null, null, null, null, ;, SimpleType(), x5, DeclarationKind.TopLevel, null, false) - listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, null, null, ;) - listener: handleIdentifier(late, typeReference) - listener: handleNoTypeArguments(x5) - listener: handleType(late, null) + isReservedKeyword(;) + parseFields(;, null, null, null, null, null, late, null, late, NoType(), x5, DeclarationKind.TopLevel, null, false) + listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, late, null, ;) + reportRecoverableError(x5, MissingConstFinalVarOrType) + listener: handleRecoverableError(MissingConstFinalVarOrType, x5, x5) + listener: handleNoType(late) ensureIdentifierPotentiallyRecovered(late, topLevelVariableDeclaration, false) listener: handleIdentifier(x5, topLevelVariableDeclaration) - parseFieldInitializerOpt(x5, x5, null, null, null, null, null, DeclarationKind.TopLevel, null) + parseFieldInitializerOpt(x5, x5, late, null, null, null, null, DeclarationKind.TopLevel, null) listener: handleNoFieldInitializer(;) - listener: endTopLevelFields(null, null, null, null, null, null, 1, late, ;) + listener: endTopLevelFields(null, null, null, null, late, null, 1, late, ;) listener: endTopLevelDeclaration(;) parseTopLevelDeclarationImpl(;, DirectiveContext(DirectiveState.Declarations)) parseMetadataStar(;) @@ -204,100 +196,95 @@ parseUnit(int) notEofOrValue(}, late) parseStatement(;) parseStatementX(;) - parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, null) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - looksLikeLocalFunction(y2) - listener: beginMetadataStar(int) - listener: endMetadataStar(0) - listener: handleIdentifier(int, typeReference) - listener: handleNoTypeArguments(y2) - listener: handleType(int, null) - listener: beginVariablesDeclaration(y2, late, null) - parseVariablesDeclarationRest(int, true) - parseOptionallyInitializedIdentifier(int) - ensureIdentifier(int, localVariableDeclaration) - listener: handleIdentifier(y2, localVariableDeclaration) - listener: beginInitializedIdentifier(y2) - parseVariableInitializerOpt(y2) - listener: handleNoVariableInitializer(y2) - listener: endInitializedIdentifier(y2) - ensureSemicolon(y2) - listener: endVariablesDeclaration(1, ;) + parseExpressionStatementOrDeclaration(;, null) + parseExpressionStatementOrDeclarationAfterModifiers(late, ;, late, null, null, null) + looksLikeLocalFunction(y2) + listener: beginMetadataStar(late) + listener: endMetadataStar(0) + listener: handleIdentifier(int, typeReference) + listener: handleNoTypeArguments(y2) + listener: handleType(int, null) + listener: beginVariablesDeclaration(y2, late, null) + parseVariablesDeclarationRest(int, true) + parseOptionallyInitializedIdentifier(int) + ensureIdentifier(int, localVariableDeclaration) + listener: handleIdentifier(y2, localVariableDeclaration) + listener: beginInitializedIdentifier(y2) + parseVariableInitializerOpt(y2) + listener: handleNoVariableInitializer(y2) + listener: endInitializedIdentifier(y2) + ensureSemicolon(y2) + listener: endVariablesDeclaration(1, ;) notEofOrValue(}, late) parseStatement(;) parseStatementX(;) - parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, null) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - looksLikeLocalFunction(y3) - listener: beginMetadataStar(List) - listener: endMetadataStar(0) - listener: handleIdentifier(List, typeReference) - listener: beginTypeArguments(<) - listener: handleIdentifier(int, typeReference) - listener: handleNoTypeArguments(>) - listener: handleType(int, null) - listener: endTypeArguments(1, <, >) - listener: handleType(List, null) - listener: beginVariablesDeclaration(y3, late, null) - parseVariablesDeclarationRest(>, true) - parseOptionallyInitializedIdentifier(>) - ensureIdentifier(>, localVariableDeclaration) - listener: handleIdentifier(y3, localVariableDeclaration) - listener: beginInitializedIdentifier(y3) - parseVariableInitializerOpt(y3) - listener: handleNoVariableInitializer(y3) - listener: endInitializedIdentifier(y3) - ensureSemicolon(y3) - listener: endVariablesDeclaration(1, ;) + parseExpressionStatementOrDeclaration(;, null) + parseExpressionStatementOrDeclarationAfterModifiers(late, ;, late, null, null, null) + looksLikeLocalFunction(y3) + listener: beginMetadataStar(late) + listener: endMetadataStar(0) + listener: handleIdentifier(List, typeReference) + listener: beginTypeArguments(<) + listener: handleIdentifier(int, typeReference) + listener: handleNoTypeArguments(>) + listener: handleType(int, null) + listener: endTypeArguments(1, <, >) + listener: handleType(List, null) + listener: beginVariablesDeclaration(y3, late, null) + parseVariablesDeclarationRest(>, true) + parseOptionallyInitializedIdentifier(>) + ensureIdentifier(>, localVariableDeclaration) + listener: handleIdentifier(y3, localVariableDeclaration) + listener: beginInitializedIdentifier(y3) + parseVariableInitializerOpt(y3) + listener: handleNoVariableInitializer(y3) + listener: endInitializedIdentifier(y3) + ensureSemicolon(y3) + listener: endVariablesDeclaration(1, ;) notEofOrValue(}, late) parseStatement(;) parseStatementX(;) - parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, null) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) - looksLikeLocalFunction(y4) - listener: beginMetadataStar(int) - listener: endMetadataStar(0) - listener: handleIdentifier(int, typeReference) - listener: handleNoTypeArguments(y4) - listener: handleType(int, null) - listener: beginVariablesDeclaration(y4, late, final) - parseVariablesDeclarationRest(int, true) - parseOptionallyInitializedIdentifier(int) - ensureIdentifier(int, localVariableDeclaration) - listener: handleIdentifier(y4, localVariableDeclaration) - listener: beginInitializedIdentifier(y4) - parseVariableInitializerOpt(y4) - listener: handleNoVariableInitializer(y4) - listener: endInitializedIdentifier(y4) - ensureSemicolon(y4) - listener: endVariablesDeclaration(1, ;) + parseExpressionStatementOrDeclaration(;, null) + parseExpressionStatementOrDeclarationAfterModifiers(final, ;, late, final, null, null) + looksLikeLocalFunction(y4) + listener: beginMetadataStar(late) + listener: endMetadataStar(0) + listener: handleIdentifier(int, typeReference) + listener: handleNoTypeArguments(y4) + listener: handleType(int, null) + listener: beginVariablesDeclaration(y4, late, final) + parseVariablesDeclarationRest(int, true) + parseOptionallyInitializedIdentifier(int) + ensureIdentifier(int, localVariableDeclaration) + listener: handleIdentifier(y4, localVariableDeclaration) + listener: beginInitializedIdentifier(y4) + parseVariableInitializerOpt(y4) + listener: handleNoVariableInitializer(y4) + listener: endInitializedIdentifier(y4) + ensureSemicolon(y4) + listener: endVariablesDeclaration(1, ;) notEofOrValue(}, late) parseStatement(;) parseStatementX(;) - parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, null) - looksLikeLocalFunction(y5) - listener: beginMetadataStar(late) - listener: endMetadataStar(0) - listener: handleIdentifier(late, typeReference) - listener: handleNoTypeArguments(y5) - listener: handleType(late, null) - listener: beginVariablesDeclaration(y5, null, null) - parseVariablesDeclarationRest(late, true) - parseOptionallyInitializedIdentifier(late) - ensureIdentifier(late, localVariableDeclaration) - listener: handleIdentifier(y5, localVariableDeclaration) - listener: beginInitializedIdentifier(y5) - parseVariableInitializerOpt(y5) - listener: handleNoVariableInitializer(y5) - listener: endInitializedIdentifier(y5) - ensureSemicolon(y5) - listener: endVariablesDeclaration(1, ;) + parseExpressionStatementOrDeclaration(;, null) + parseExpressionStatementOrDeclarationAfterModifiers(late, ;, late, null, null, null) + looksLikeLocalFunction(y5) + reportRecoverableError(y5, MissingConstFinalVarOrType) + listener: handleRecoverableError(MissingConstFinalVarOrType, y5, y5) + listener: beginMetadataStar(late) + listener: endMetadataStar(0) + listener: handleNoType(late) + listener: beginVariablesDeclaration(y5, late, null) + parseVariablesDeclarationRest(late, true) + parseOptionallyInitializedIdentifier(late) + ensureIdentifier(late, localVariableDeclaration) + listener: handleIdentifier(y5, localVariableDeclaration) + listener: beginInitializedIdentifier(y5) + parseVariableInitializerOpt(y5) + listener: handleNoVariableInitializer(y5) + listener: endInitializedIdentifier(y5) + ensureSemicolon(y5) + listener: endVariablesDeclaration(1, ;) notEofOrValue(}, ;) parseStatement(;) parseStatementX(;) @@ -306,24 +293,27 @@ parseUnit(int) notEofOrValue(}, late) parseStatement(;) parseStatementX(;) - parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, null) - looksLikeLocalFunction(late) - parseExpressionStatement(;) - parseExpression(;) - parsePrecedenceExpression(;, 1, true, ConstantPatternContext.none) - parseUnaryExpression(;, true, ConstantPatternContext.none) - parsePrimary(;, expression, ConstantPatternContext.none) - parseSendOrFunctionLiteral(;, expression, ConstantPatternContext.none) - parseSend(;, expression, ConstantPatternContext.none) - isNextIdentifier(;) - ensureIdentifier(;, expression) - listener: handleIdentifier(late, expression) - listener: handleNoTypeArguments(;) - parseArgumentsOpt(late) - listener: handleNoArguments(;) - listener: handleSend(late, late) - ensureSemicolon(late) - listener: handleExpressionStatement(late, ;) + parseExpressionStatementOrDeclaration(;, null) + parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, null) + looksLikeLocalFunction(late) + parseExpressionStatement(;) + parseExpression(;) + parsePrecedenceExpression(;, 1, true, ConstantPatternContext.none) + parseUnaryExpression(;, true, ConstantPatternContext.none) + parsePrimary(;, expression, ConstantPatternContext.none) + inPlainSync() + parseSendOrFunctionLiteral(;, expression, ConstantPatternContext.none) + parseSend(;, expression, ConstantPatternContext.none) + isNextIdentifier(;) + ensureIdentifier(;, expression) + inPlainSync() + listener: handleIdentifier(late, expression) + listener: handleNoTypeArguments(;) + parseArgumentsOpt(late) + listener: handleNoArguments(;) + listener: handleSend(late, late) + ensureSemicolon(late) + listener: handleExpressionStatement(late, ;) notEofOrValue(}, ;) parseStatement(;) parseStatementX(;) @@ -378,12 +368,9 @@ parseUnit(int) parseMetadataStar(;) listener: beginMetadataStar(late) listener: endMetadataStar(0) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) listener: beginMember() - parseFields(late, null, null, null, null, null, late, null, late, SimpleType(), z2, DeclarationKind.Class, Foo, false) - listener: beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, late) + parseFields(;, null, null, null, null, null, late, null, late, SimpleType(), z2, DeclarationKind.Class, Foo, false) + listener: beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, ;) listener: handleIdentifier(int, typeReference) listener: handleNoTypeArguments(z2) listener: handleType(int, null) @@ -391,19 +378,16 @@ parseUnit(int) listener: handleIdentifier(z2, fieldDeclaration) parseFieldInitializerOpt(z2, z2, late, null, null, null, null, DeclarationKind.Class, Foo) listener: handleNoFieldInitializer(;) - listener: endClassFields(null, null, null, null, null, late, null, 1, int, ;) + listener: endClassFields(null, null, null, null, null, late, null, 1, late, ;) listener: endMember() notEofOrValue(}, late) parseClassOrMixinOrExtensionOrEnumMemberImpl(;, DeclarationKind.Class, Foo) parseMetadataStar(;) listener: beginMetadataStar(late) listener: endMetadataStar(0) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) listener: beginMember() - parseFields(late, null, null, null, null, null, late, null, late, SimpleTypeWith1Argument(typeArg: SimpleTypeArgument1()), x3, DeclarationKind.Class, Foo, false) - listener: beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, late) + parseFields(;, null, null, null, null, null, late, null, late, SimpleTypeWith1Argument(typeArg: SimpleTypeArgument1()), x3, DeclarationKind.Class, Foo, false) + listener: beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, ;) listener: handleIdentifier(List, typeReference) listener: beginTypeArguments(<) listener: handleIdentifier(int, typeReference) @@ -415,21 +399,18 @@ parseUnit(int) listener: handleIdentifier(x3, fieldDeclaration) parseFieldInitializerOpt(x3, x3, late, null, null, null, null, DeclarationKind.Class, Foo) listener: handleNoFieldInitializer(;) - listener: endClassFields(null, null, null, null, null, late, null, 1, List, ;) + listener: endClassFields(null, null, null, null, null, late, null, 1, late, ;) listener: endMember() notEofOrValue(}, late) parseClassOrMixinOrExtensionOrEnumMemberImpl(;, DeclarationKind.Class, Foo) parseMetadataStar(;) listener: beginMetadataStar(late) listener: endMetadataStar(0) - indicatesMethodOrField(;) - reportRecoverableErrorWithToken(late, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'late' is only available in null safe libraries., null, {lexeme: late}], late, late) listener: beginMember() skipOuterPattern(final) skipObjectPatternRest(int) - parseFields(late, null, null, null, null, null, late, final, final, SimpleType(), z4, DeclarationKind.Class, Foo, false) - listener: beginFields(DeclarationKind.Class, null, null, null, null, null, late, final, late) + parseFields(;, null, null, null, null, null, late, final, final, SimpleType(), z4, DeclarationKind.Class, Foo, false) + listener: beginFields(DeclarationKind.Class, null, null, null, null, null, late, final, ;) listener: handleIdentifier(int, typeReference) listener: handleNoTypeArguments(z4) listener: handleType(int, null) @@ -437,7 +418,7 @@ parseUnit(int) listener: handleIdentifier(z4, fieldDeclaration) parseFieldInitializerOpt(z4, z4, late, null, null, null, final, DeclarationKind.Class, Foo) listener: handleNoFieldInitializer(;) - listener: endClassFields(null, null, null, null, null, late, final, 1, final, ;) + listener: endClassFields(null, null, null, null, null, late, final, 1, late, ;) listener: endMember() notEofOrValue(}, late) parseClassOrMixinOrExtensionOrEnumMemberImpl(;, DeclarationKind.Class, Foo) @@ -445,16 +426,17 @@ parseUnit(int) listener: beginMetadataStar(late) listener: endMetadataStar(0) listener: beginMember() - parseFields(;, null, null, null, null, null, null, null, ;, SimpleType(), z5, DeclarationKind.Class, Foo, false) - listener: beginFields(DeclarationKind.Class, null, null, null, null, null, null, null, ;) - listener: handleIdentifier(late, typeReference) - listener: handleNoTypeArguments(z5) - listener: handleType(late, null) + isReservedKeyword(;) + parseFields(;, null, null, null, null, null, late, null, late, NoType(), z5, DeclarationKind.Class, Foo, false) + listener: beginFields(DeclarationKind.Class, null, null, null, null, null, late, null, ;) + reportRecoverableError(z5, MissingConstFinalVarOrType) + listener: handleRecoverableError(MissingConstFinalVarOrType, z5, z5) + listener: handleNoType(late) ensureIdentifierPotentiallyRecovered(late, fieldDeclaration, false) listener: handleIdentifier(z5, fieldDeclaration) - parseFieldInitializerOpt(z5, z5, null, null, null, null, null, DeclarationKind.Class, Foo) + parseFieldInitializerOpt(z5, z5, late, null, null, null, null, DeclarationKind.Class, Foo) listener: handleNoFieldInitializer(;) - listener: endClassFields(null, null, null, null, null, null, null, 1, late, ;) + listener: endClassFields(null, null, null, null, null, late, null, 1, late, ;) listener: endMember() notEofOrValue(}, ;) parseClassOrMixinOrExtensionOrEnumMemberImpl(;, DeclarationKind.Class, Foo) @@ -473,7 +455,6 @@ parseUnit(int) listener: beginMetadataStar(late) listener: endMetadataStar(0) listener: beginMember() - isReservedKeyword(;) parseFields(;, null, null, null, null, null, null, null, ;, NoType(), late, DeclarationKind.Class, Foo, false) listener: beginFields(DeclarationKind.Class, null, null, null, null, null, null, null, ;) reportRecoverableError(late, MissingConstFinalVarOrType) diff --git a/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.parser.expect new file mode 100644 index 000000000000..5150444787a1 --- /dev/null +++ b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.parser.expect @@ -0,0 +1,61 @@ +int x1; +late int x2; +late List x3; +late final int x4; +late x5; +; +late; +; + +main(List args) { +int y1; +late int y2; +late List y3; +late final int y4; +late y5; +; +late; +; +} + +class Foo { +int z1; +late int z2; +late List x3; +late final int z4; +late z5; +; +late; +; +} + +int[StringToken] x1[StringToken];[SimpleToken] +late[KeywordToken] int[StringToken] x2[StringToken];[SimpleToken] +late[KeywordToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] x3[StringToken];[SimpleToken] +late[KeywordToken] final[KeywordToken] int[StringToken] x4[StringToken];[SimpleToken] +late[KeywordToken] x5[StringToken];[SimpleToken] +;[SimpleToken] +late[KeywordToken];[SimpleToken] +;[SimpleToken] + +main[StringToken]([BeginToken]List[StringToken]<[BeginToken]String[StringToken]>[SimpleToken] args[StringToken])[SimpleToken] {[BeginToken] +int[StringToken] y1[StringToken];[SimpleToken] +late[KeywordToken] int[StringToken] y2[StringToken];[SimpleToken] +late[KeywordToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] y3[StringToken];[SimpleToken] +late[KeywordToken] final[KeywordToken] int[StringToken] y4[StringToken];[SimpleToken] +late[KeywordToken] y5[StringToken];[SimpleToken] +;[SimpleToken] +late[KeywordToken];[SimpleToken] +;[SimpleToken] +}[SimpleToken] + +class[KeywordToken] Foo[StringToken] {[BeginToken] +int[StringToken] z1[StringToken];[SimpleToken] +late[KeywordToken] int[StringToken] z2[StringToken];[SimpleToken] +late[KeywordToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] x3[StringToken];[SimpleToken] +late[KeywordToken] final[KeywordToken] int[StringToken] z4[StringToken];[SimpleToken] +late[KeywordToken] z5[StringToken];[SimpleToken] +;[SimpleToken] +late[KeywordToken];[SimpleToken] +;[SimpleToken] +}[SimpleToken][SimpleToken] diff --git a/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.scanner.expect new file mode 100644 index 000000000000..5150444787a1 --- /dev/null +++ b/pkg/front_end/parser_testcases/also-nnbd/use_late_in_non_nnbd.dart.scanner.expect @@ -0,0 +1,61 @@ +int x1; +late int x2; +late List x3; +late final int x4; +late x5; +; +late; +; + +main(List args) { +int y1; +late int y2; +late List y3; +late final int y4; +late y5; +; +late; +; +} + +class Foo { +int z1; +late int z2; +late List x3; +late final int z4; +late z5; +; +late; +; +} + +int[StringToken] x1[StringToken];[SimpleToken] +late[KeywordToken] int[StringToken] x2[StringToken];[SimpleToken] +late[KeywordToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] x3[StringToken];[SimpleToken] +late[KeywordToken] final[KeywordToken] int[StringToken] x4[StringToken];[SimpleToken] +late[KeywordToken] x5[StringToken];[SimpleToken] +;[SimpleToken] +late[KeywordToken];[SimpleToken] +;[SimpleToken] + +main[StringToken]([BeginToken]List[StringToken]<[BeginToken]String[StringToken]>[SimpleToken] args[StringToken])[SimpleToken] {[BeginToken] +int[StringToken] y1[StringToken];[SimpleToken] +late[KeywordToken] int[StringToken] y2[StringToken];[SimpleToken] +late[KeywordToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] y3[StringToken];[SimpleToken] +late[KeywordToken] final[KeywordToken] int[StringToken] y4[StringToken];[SimpleToken] +late[KeywordToken] y5[StringToken];[SimpleToken] +;[SimpleToken] +late[KeywordToken];[SimpleToken] +;[SimpleToken] +}[SimpleToken] + +class[KeywordToken] Foo[StringToken] {[BeginToken] +int[StringToken] z1[StringToken];[SimpleToken] +late[KeywordToken] int[StringToken] z2[StringToken];[SimpleToken] +late[KeywordToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] x3[StringToken];[SimpleToken] +late[KeywordToken] final[KeywordToken] int[StringToken] z4[StringToken];[SimpleToken] +late[KeywordToken] z5[StringToken];[SimpleToken] +;[SimpleToken] +late[KeywordToken];[SimpleToken] +;[SimpleToken] +}[SimpleToken][SimpleToken] diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart similarity index 100% rename from pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart rename to pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.expect b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.expect similarity index 78% rename from pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.expect rename to pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.expect index ae4eb2bb1677..b752193b36f4 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.expect @@ -1,17 +1,13 @@ Problems reported: -parser/non-nnbd/use_required_in_non_nnbd:1:12: The modifier 'required' is only available in null safe libraries. -void foo1({required int x1}) { - ^^^^^^^^ +parser/also-nnbd/use_required_in_non_nnbd:9:21: The modifier 'required' was already specified. +void foo3({required required x3}) { + ^^^^^^^^ -parser/non-nnbd/use_required_in_non_nnbd:9:12: The modifier 'required' is only available in null safe libraries. +parser/also-nnbd/use_required_in_non_nnbd:9:12: Can't have modifier 'required' here. void foo3({required required x3}) { ^^^^^^^^ -parser/non-nnbd/use_required_in_non_nnbd:14:14: The modifier 'required' is only available in null safe libraries. - void foo4({required covariant int x4}) { - ^^^^^^^^ - beginCompilationUnit(void) beginMetadataStar(void) endMetadataStar(0) @@ -24,14 +20,13 @@ beginCompilationUnit(void) beginOptionalFormalParameters({) beginMetadataStar(required) endMetadataStar(0) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'required' is only available in null safe libraries., null, {lexeme: required}], required, required) - beginFormalParameter(int, MemberKind.TopLevelMethod, required, null, null) + beginFormalParameter(required, MemberKind.TopLevelMethod, required, null, null) handleIdentifier(int, typeReference) handleNoTypeArguments(x1) handleType(int, null) handleIdentifier(x1, formalParameterDeclaration) handleFormalParameterWithoutValue(}) - endFormalParameter(null, null, null, x1, null, null, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod) + endFormalParameter(null, null, null, x1, null, null, FormalParameterKind.requiredNamed, MemberKind.TopLevelMethod) endOptionalFormalParameters(1, {, }, MemberKind.TopLevelMethod) endFormalParameters(1, (, ), MemberKind.TopLevelMethod) handleAsyncModifier(null, null) @@ -60,13 +55,11 @@ beginCompilationUnit(void) beginOptionalFormalParameters({) beginMetadataStar(required) endMetadataStar(0) - beginFormalParameter(required, MemberKind.TopLevelMethod, null, null, null) - handleIdentifier(required, typeReference) - handleNoTypeArguments(x2) - handleType(required, null) + beginFormalParameter(required, MemberKind.TopLevelMethod, required, null, null) + handleNoType(required) handleIdentifier(x2, formalParameterDeclaration) handleFormalParameterWithoutValue(}) - endFormalParameter(null, null, null, x2, null, null, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod) + endFormalParameter(null, null, null, x2, null, null, FormalParameterKind.requiredNamed, MemberKind.TopLevelMethod) endOptionalFormalParameters(1, {, }, MemberKind.TopLevelMethod) endFormalParameters(1, (, ), MemberKind.TopLevelMethod) handleAsyncModifier(null, null) @@ -95,14 +88,13 @@ beginCompilationUnit(void) beginOptionalFormalParameters({) beginMetadataStar(required) endMetadataStar(0) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'required' is only available in null safe libraries., null, {lexeme: required}], required, required) + handleRecoverableError(Message[DuplicatedModifier, The modifier 'required' was already specified., Try removing all but one occurrence of the modifier., {lexeme: required}], required, required) + handleRecoverableError(Message[ExtraneousModifier, Can't have modifier 'required' here., Try removing 'required'., {lexeme: required}], required, required) beginFormalParameter(required, MemberKind.TopLevelMethod, required, null, null) - handleIdentifier(required, typeReference) - handleNoTypeArguments(x3) - handleType(required, null) + handleNoType(required) handleIdentifier(x3, formalParameterDeclaration) handleFormalParameterWithoutValue(}) - endFormalParameter(null, null, null, x3, null, null, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod) + endFormalParameter(null, null, null, x3, null, null, FormalParameterKind.requiredNamed, MemberKind.TopLevelMethod) endOptionalFormalParameters(1, {, }, MemberKind.TopLevelMethod) endFormalParameters(1, (, ), MemberKind.TopLevelMethod) handleAsyncModifier(null, null) @@ -143,14 +135,13 @@ beginCompilationUnit(void) beginOptionalFormalParameters({) beginMetadataStar(required) endMetadataStar(0) - handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'required' is only available in null safe libraries., null, {lexeme: required}], required, required) - beginFormalParameter(covariant, MemberKind.NonStaticMethod, required, covariant, null) + beginFormalParameter(required, MemberKind.NonStaticMethod, required, covariant, null) handleIdentifier(int, typeReference) handleNoTypeArguments(x4) handleType(int, null) handleIdentifier(x4, formalParameterDeclaration) handleFormalParameterWithoutValue(}) - endFormalParameter(null, null, null, x4, null, null, FormalParameterKind.optionalNamed, MemberKind.NonStaticMethod) + endFormalParameter(null, null, null, x4, null, null, FormalParameterKind.requiredNamed, MemberKind.NonStaticMethod) endOptionalFormalParameters(1, {, }, MemberKind.NonStaticMethod) endFormalParameters(1, (, ), MemberKind.NonStaticMethod) handleNoInitializers() diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.intertwined.expect b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.intertwined.expect similarity index 93% rename from pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.intertwined.expect rename to pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.intertwined.expect index 65914e66aa6f..a2cc0d994804 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.intertwined.expect @@ -25,16 +25,14 @@ parseUnit(void) parseMetadataStar({) listener: beginMetadataStar(required) listener: endMetadataStar(0) - reportRecoverableErrorWithToken(required, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'required' is only available in null safe libraries., null, {lexeme: required}], required, required) - listener: beginFormalParameter(int, MemberKind.TopLevelMethod, required, null, null) + listener: beginFormalParameter(required, MemberKind.TopLevelMethod, required, null, null) listener: handleIdentifier(int, typeReference) listener: handleNoTypeArguments(x1) listener: handleType(int, null) ensureIdentifier(int, formalParameterDeclaration) listener: handleIdentifier(x1, formalParameterDeclaration) listener: handleFormalParameterWithoutValue(}) - listener: endFormalParameter(null, null, null, x1, null, null, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod) + listener: endFormalParameter(null, null, null, x1, null, null, FormalParameterKind.requiredNamed, MemberKind.TopLevelMethod) listener: endOptionalFormalParameters(1, {, }, MemberKind.TopLevelMethod) ensureCloseParen(}, () listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod) @@ -108,14 +106,12 @@ parseUnit(void) parseMetadataStar({) listener: beginMetadataStar(required) listener: endMetadataStar(0) - listener: beginFormalParameter(required, MemberKind.TopLevelMethod, null, null, null) - listener: handleIdentifier(required, typeReference) - listener: handleNoTypeArguments(x2) - listener: handleType(required, null) + listener: beginFormalParameter(required, MemberKind.TopLevelMethod, required, null, null) + listener: handleNoType(required) ensureIdentifier(required, formalParameterDeclaration) listener: handleIdentifier(x2, formalParameterDeclaration) listener: handleFormalParameterWithoutValue(}) - listener: endFormalParameter(null, null, null, x2, null, null, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod) + listener: endFormalParameter(null, null, null, x2, null, null, FormalParameterKind.requiredNamed, MemberKind.TopLevelMethod) listener: endOptionalFormalParameters(1, {, }, MemberKind.TopLevelMethod) ensureCloseParen(}, () listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod) @@ -189,16 +185,16 @@ parseUnit(void) parseMetadataStar({) listener: beginMetadataStar(required) listener: endMetadataStar(0) - reportRecoverableErrorWithToken(required, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'required' is only available in null safe libraries., null, {lexeme: required}], required, required) + reportRecoverableErrorWithToken(required, Template(DuplicatedModifier)) + listener: handleRecoverableError(Message[DuplicatedModifier, The modifier 'required' was already specified., Try removing all but one occurrence of the modifier., {lexeme: required}], required, required) + reportRecoverableErrorWithToken(required, Template(ExtraneousModifier)) + listener: handleRecoverableError(Message[ExtraneousModifier, Can't have modifier 'required' here., Try removing 'required'., {lexeme: required}], required, required) listener: beginFormalParameter(required, MemberKind.TopLevelMethod, required, null, null) - listener: handleIdentifier(required, typeReference) - listener: handleNoTypeArguments(x3) - listener: handleType(required, null) + listener: handleNoType(required) ensureIdentifier(required, formalParameterDeclaration) listener: handleIdentifier(x3, formalParameterDeclaration) listener: handleFormalParameterWithoutValue(}) - listener: endFormalParameter(null, null, null, x3, null, null, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod) + listener: endFormalParameter(null, null, null, x3, null, null, FormalParameterKind.requiredNamed, MemberKind.TopLevelMethod) listener: endOptionalFormalParameters(1, {, }, MemberKind.TopLevelMethod) ensureCloseParen(}, () listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod) @@ -296,16 +292,14 @@ parseUnit(void) parseMetadataStar({) listener: beginMetadataStar(required) listener: endMetadataStar(0) - reportRecoverableErrorWithToken(required, Template(UnexpectedModifierInNonNnbd)) - listener: handleRecoverableError(Message[UnexpectedModifierInNonNnbd, The modifier 'required' is only available in null safe libraries., null, {lexeme: required}], required, required) - listener: beginFormalParameter(covariant, MemberKind.NonStaticMethod, required, covariant, null) + listener: beginFormalParameter(required, MemberKind.NonStaticMethod, required, covariant, null) listener: handleIdentifier(int, typeReference) listener: handleNoTypeArguments(x4) listener: handleType(int, null) ensureIdentifier(int, formalParameterDeclaration) listener: handleIdentifier(x4, formalParameterDeclaration) listener: handleFormalParameterWithoutValue(}) - listener: endFormalParameter(null, null, null, x4, null, null, FormalParameterKind.optionalNamed, MemberKind.NonStaticMethod) + listener: endFormalParameter(null, null, null, x4, null, null, FormalParameterKind.requiredNamed, MemberKind.NonStaticMethod) listener: endOptionalFormalParameters(1, {, }, MemberKind.NonStaticMethod) ensureCloseParen(}, () listener: endFormalParameters(1, (, ), MemberKind.NonStaticMethod) diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.parser.expect b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.parser.expect similarity index 69% rename from pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.parser.expect rename to pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.parser.expect index 468262a3ba71..bb8bfc57ac47 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.parser.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.parser.expect @@ -16,20 +16,20 @@ print(x); } } -void[KeywordToken] foo1[StringToken]([BeginToken]{[BeginToken]required[StringToken] int[StringToken] x1[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] +void[KeywordToken] foo1[StringToken]([BeginToken]{[BeginToken]required[KeywordToken] int[StringToken] x1[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] print[StringToken]([BeginToken]x[StringToken])[SimpleToken];[SimpleToken] }[SimpleToken] -void[KeywordToken] foo2[StringToken]([BeginToken]{[BeginToken]required[StringToken] x2[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] +void[KeywordToken] foo2[StringToken]([BeginToken]{[BeginToken]required[KeywordToken] x2[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] print[StringToken]([BeginToken]x[StringToken])[SimpleToken];[SimpleToken] }[SimpleToken] -void[KeywordToken] foo3[StringToken]([BeginToken]{[BeginToken]required[StringToken] required[StringToken] x3[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] +void[KeywordToken] foo3[StringToken]([BeginToken]{[BeginToken]required[KeywordToken] required[KeywordToken] x3[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] print[StringToken]([BeginToken]x[StringToken])[SimpleToken];[SimpleToken] }[SimpleToken] class[KeywordToken] Foo[StringToken] {[BeginToken] -void[KeywordToken] foo4[StringToken]([BeginToken]{[BeginToken]required[StringToken] covariant[KeywordToken] int[StringToken] x4[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] +void[KeywordToken] foo4[StringToken]([BeginToken]{[BeginToken]required[KeywordToken] covariant[KeywordToken] int[StringToken] x4[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] print[StringToken]([BeginToken]x[StringToken])[SimpleToken];[SimpleToken] }[SimpleToken] }[SimpleToken][SimpleToken] diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.scanner.expect b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.scanner.expect similarity index 69% rename from pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.scanner.expect rename to pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.scanner.expect index 468262a3ba71..bb8bfc57ac47 100644 --- a/pkg/front_end/parser_testcases/non-nnbd/use_required_in_non_nnbd.dart.scanner.expect +++ b/pkg/front_end/parser_testcases/also-nnbd/use_required_in_non_nnbd.dart.scanner.expect @@ -16,20 +16,20 @@ print(x); } } -void[KeywordToken] foo1[StringToken]([BeginToken]{[BeginToken]required[StringToken] int[StringToken] x1[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] +void[KeywordToken] foo1[StringToken]([BeginToken]{[BeginToken]required[KeywordToken] int[StringToken] x1[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] print[StringToken]([BeginToken]x[StringToken])[SimpleToken];[SimpleToken] }[SimpleToken] -void[KeywordToken] foo2[StringToken]([BeginToken]{[BeginToken]required[StringToken] x2[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] +void[KeywordToken] foo2[StringToken]([BeginToken]{[BeginToken]required[KeywordToken] x2[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] print[StringToken]([BeginToken]x[StringToken])[SimpleToken];[SimpleToken] }[SimpleToken] -void[KeywordToken] foo3[StringToken]([BeginToken]{[BeginToken]required[StringToken] required[StringToken] x3[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] +void[KeywordToken] foo3[StringToken]([BeginToken]{[BeginToken]required[KeywordToken] required[KeywordToken] x3[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] print[StringToken]([BeginToken]x[StringToken])[SimpleToken];[SimpleToken] }[SimpleToken] class[KeywordToken] Foo[StringToken] {[BeginToken] -void[KeywordToken] foo4[StringToken]([BeginToken]{[BeginToken]required[StringToken] covariant[KeywordToken] int[StringToken] x4[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] +void[KeywordToken] foo4[StringToken]([BeginToken]{[BeginToken]required[KeywordToken] covariant[KeywordToken] int[StringToken] x4[StringToken]}[SimpleToken])[SimpleToken] {[BeginToken] print[StringToken]([BeginToken]x[StringToken])[SimpleToken];[SimpleToken] }[SimpleToken] }[SimpleToken][SimpleToken] diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.parser.expect b/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.parser.expect deleted file mode 100644 index 272afaacfc54..000000000000 --- a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.parser.expect +++ /dev/null @@ -1,61 +0,0 @@ -int x1; -late int x2; -late List x3; -late final int x4; -late x5; -; -late; -; - -main(List args) { -int y1; -late int y2; -late List y3; -late final int y4; -late y5; -; -late; -; -} - -class Foo { -int z1; -late int z2; -late List x3; -late final int z4; -late z5; -; -late; -; -} - -int[StringToken] x1[StringToken];[SimpleToken] -late[StringToken] int[StringToken] x2[StringToken];[SimpleToken] -late[StringToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] x3[StringToken];[SimpleToken] -late[StringToken] final[KeywordToken] int[StringToken] x4[StringToken];[SimpleToken] -late[StringToken] x5[StringToken];[SimpleToken] -;[SimpleToken] -late[StringToken];[SimpleToken] -;[SimpleToken] - -main[StringToken]([BeginToken]List[StringToken]<[BeginToken]String[StringToken]>[SimpleToken] args[StringToken])[SimpleToken] {[BeginToken] -int[StringToken] y1[StringToken];[SimpleToken] -late[StringToken] int[StringToken] y2[StringToken];[SimpleToken] -late[StringToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] y3[StringToken];[SimpleToken] -late[StringToken] final[KeywordToken] int[StringToken] y4[StringToken];[SimpleToken] -late[StringToken] y5[StringToken];[SimpleToken] -;[SimpleToken] -late[StringToken];[SimpleToken] -;[SimpleToken] -}[SimpleToken] - -class[KeywordToken] Foo[StringToken] {[BeginToken] -int[StringToken] z1[StringToken];[SimpleToken] -late[StringToken] int[StringToken] z2[StringToken];[SimpleToken] -late[StringToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] x3[StringToken];[SimpleToken] -late[StringToken] final[KeywordToken] int[StringToken] z4[StringToken];[SimpleToken] -late[StringToken] z5[StringToken];[SimpleToken] -;[SimpleToken] -late[StringToken];[SimpleToken] -;[SimpleToken] -}[SimpleToken][SimpleToken] diff --git a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.scanner.expect b/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.scanner.expect deleted file mode 100644 index 272afaacfc54..000000000000 --- a/pkg/front_end/parser_testcases/non-nnbd/use_late_in_non_nnbd.dart.scanner.expect +++ /dev/null @@ -1,61 +0,0 @@ -int x1; -late int x2; -late List x3; -late final int x4; -late x5; -; -late; -; - -main(List args) { -int y1; -late int y2; -late List y3; -late final int y4; -late y5; -; -late; -; -} - -class Foo { -int z1; -late int z2; -late List x3; -late final int z4; -late z5; -; -late; -; -} - -int[StringToken] x1[StringToken];[SimpleToken] -late[StringToken] int[StringToken] x2[StringToken];[SimpleToken] -late[StringToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] x3[StringToken];[SimpleToken] -late[StringToken] final[KeywordToken] int[StringToken] x4[StringToken];[SimpleToken] -late[StringToken] x5[StringToken];[SimpleToken] -;[SimpleToken] -late[StringToken];[SimpleToken] -;[SimpleToken] - -main[StringToken]([BeginToken]List[StringToken]<[BeginToken]String[StringToken]>[SimpleToken] args[StringToken])[SimpleToken] {[BeginToken] -int[StringToken] y1[StringToken];[SimpleToken] -late[StringToken] int[StringToken] y2[StringToken];[SimpleToken] -late[StringToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] y3[StringToken];[SimpleToken] -late[StringToken] final[KeywordToken] int[StringToken] y4[StringToken];[SimpleToken] -late[StringToken] y5[StringToken];[SimpleToken] -;[SimpleToken] -late[StringToken];[SimpleToken] -;[SimpleToken] -}[SimpleToken] - -class[KeywordToken] Foo[StringToken] {[BeginToken] -int[StringToken] z1[StringToken];[SimpleToken] -late[StringToken] int[StringToken] z2[StringToken];[SimpleToken] -late[StringToken] List[StringToken]<[BeginToken]int[StringToken]>[SimpleToken] x3[StringToken];[SimpleToken] -late[StringToken] final[KeywordToken] int[StringToken] z4[StringToken];[SimpleToken] -late[StringToken] z5[StringToken];[SimpleToken] -;[SimpleToken] -late[StringToken];[SimpleToken] -;[SimpleToken] -}[SimpleToken][SimpleToken] diff --git a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart index d90f2334be95..d39742fc4083 100644 --- a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart +++ b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart @@ -321,8 +321,7 @@ class TestMinimizer { } else { try { if (_knownByCompiler(uri!)) { - String parsedString = - _getFileAsStringContent(_fs.data[uri]!, _isUriNnbd(uri)); + String parsedString = _getFileAsStringContent(_fs.data[uri]!); _fs.data[uri] = utf8.encode(parsedString); } } catch (e) { @@ -557,11 +556,11 @@ class TestMinimizer { if (!uri.toString().endsWith(".dart")) continue; if (inlinableUri == uri) continue; final Uint8List? originalBytes = _fs.data[uri]; - if (originalBytes == null || originalBytes.isEmpty) continue; - CompilationUnitEnd ast = getAST(originalBytes, - includeBody: false, - includeComments: false, - enableNonNullable: _isUriNnbd(uri!)); + if (uri == null || originalBytes == null || originalBytes.isEmpty) { + continue; + } + CompilationUnitEnd ast = + getAST(originalBytes, includeBody: false, includeComments: false); // Find all imports/exports of this file (if any). // If finding any: // * remove all of them, then @@ -598,10 +597,8 @@ class TestMinimizer { // have a `library` declaration. // * The file we're inlining has a library declaration. int offsetOfLast = 0; - ast = getAST(withoutInlineable, - includeBody: false, - includeComments: false, - enableNonNullable: _isUriNnbd(uri)); + ast = + getAST(withoutInlineable, includeBody: false, includeComments: false); for (ImportEnd import in ast.getImports()) { offsetOfLast = max(offsetOfLast, import.semicolon!.offset + 1); } @@ -618,15 +615,15 @@ class TestMinimizer { builder.writeCharCode(withoutInlineableString.codeUnitAt(i)); } builder.write("\n"); - builder.write(utf8.decode(_rewriteImportsExportsToUri( - inlineData, uri, inlinableUri, _isUriNnbd(inlinableUri)))); + builder.write(utf8 + .decode(_rewriteImportsExportsToUri(inlineData, uri, inlinableUri))); builder.write("\n"); for (int i = offsetOfLast; i < withoutInlineableString.length; i++) { builder.writeCharCode(withoutInlineableString.codeUnitAt(i)); } final Uint8List inlinedWithoutChange = utf8.encode(builder.toString()); - if (!_parsesWithoutError(inlinedWithoutChange, _isUriNnbd(uri))) { + if (!_parsesWithoutError(inlinedWithoutChange)) { print("WARNING: Parser error after stuff at ${StackTrace.current}"); } @@ -658,7 +655,7 @@ class TestMinimizer { } builder.write("\n"); builder.write(utf8.decode(_rewriteImportsExportsToUri( - inlineData, uri, inlinableUri, _isUriNnbd(inlinableUri), + inlineData, uri, inlinableUri, convertExportToImport: true))); builder.write("\n"); for (int i = offsetOfLast; i < withoutInlineableString.length; i++) { @@ -666,7 +663,7 @@ class TestMinimizer { } Uint8List inlinedWithChange = utf8.encode(builder.toString()); - if (!_parsesWithoutError(inlinedWithChange, _isUriNnbd(uri))) { + if (!_parsesWithoutError(inlinedWithChange)) { print("WARNING: Parser error after stuff at ${StackTrace.current}"); } @@ -699,10 +696,10 @@ class TestMinimizer { } Uint8List _rewriteImportsExportsToUri( - Uint8List oldData, Uri newUri, Uri oldUri, bool nnbd, + Uint8List oldData, Uri newUri, Uri oldUri, {bool convertExportToImport = false}) { - CompilationUnitEnd ast = getAST(oldData, - includeBody: false, includeComments: false, enableNonNullable: nnbd); + CompilationUnitEnd ast = + getAST(oldData, includeBody: false, includeComments: false); List<_Replacement> replacements = []; for (ImportEnd import in ast.getImports()) { _rewriteImportsExportsToUriInternal( @@ -1040,10 +1037,7 @@ worlds: // Because textual outline doesn't do the right thing for nnbd, only // replace if it's syntactically valid. if (candidate.length != _fs.data[uri]!.length && - _parsesWithoutError( - candidate, - languageVersion >= - ExperimentalFlag.nonNullable.enabledVersion)) { + _parsesWithoutError(candidate)) { if (await _shouldQuit()) return; _fs.data[uri] = candidate; if (!await _crashesOnCompile(initialComponent)) { @@ -1124,10 +1118,8 @@ worlds: List lineStarts = []; - Token firstToken = parser_suite.scanRawBytes( - data, - _isUriNnbd(uri) ? _scannerConfiguration : _scannerConfigurationNonNNBD, - lineStarts); + Token firstToken = + parser_suite.scanRawBytes(data, _scannerConfiguration, lineStarts); int compileTry = 0; Token? token = firstToken; @@ -1292,10 +1284,8 @@ worlds: if (!uri.toString().endsWith(".dart")) return; Uint8List data = _fs.data[uri]!; - CompilationUnitEnd ast = getAST(data, - includeBody: true, - includeComments: false, - enableNonNullable: _isUriNnbd(uri)); + CompilationUnitEnd ast = + getAST(data, includeBody: true, includeComments: false); _CompilationHelperClass helper = new _CompilationHelperClass(data); @@ -1694,11 +1684,11 @@ worlds: } Uint8List candidate = _replaceRange(data.replacements, data.originalData); - if (!_parsesWithoutError(candidate, _isUriNnbd(uri)) && - _parsesWithoutError(data.originalData, _isUriNnbd(uri))) { + if (!_parsesWithoutError(candidate) && + _parsesWithoutError(data.originalData)) { print("WARNING: Parser error after stuff at ${StackTrace.current}"); - _parsesWithoutError(candidate, _isUriNnbd(uri)); - _parsesWithoutError(data.originalData, _isUriNnbd(uri)); + _parsesWithoutError(candidate); + _parsesWithoutError(data.originalData); } _fs.data[uri] = candidate; @@ -1743,8 +1733,7 @@ worlds: Uint8List candidate = builder.takeBytes(); if (candidate.length == data.length) return; - if (uri.path.endsWith(".dart") && - !_parsesWithoutError(candidate, _isUriNnbd(uri))) { + if (uri.path.endsWith(".dart") && !_parsesWithoutError(candidate)) { print("WARNING: Parser error after stuff at ${StackTrace.current}"); } @@ -1861,8 +1850,6 @@ worlds: ScannerConfiguration _getScannerConfiguration(Version languageVersion) { return new ScannerConfiguration( - enableNonNullable: - languageVersion >= ExperimentalFlag.nonNullable.enabledVersion, enableTripleShift: languageVersion >= ExperimentalFlag.tripleShift.enabledVersion); } @@ -1915,11 +1902,6 @@ worlds: } } - bool _isUriNnbd(Uri uri, {bool crashOnFail = true}) { - return _getLanguageVersion(uri, crashOnFail: crashOnFail) >= - ExperimentalFlag.nonNullable.enabledVersion; - } - Future _crashesOnCompile(Component initialComponent) async { IncrementalCompiler incrementalCompiler; _gotWantedError = false; @@ -2134,13 +2116,11 @@ worlds: return compilerContext; } - String _getFileAsStringContent(Uint8List rawBytes, bool nnbd) { + String _getFileAsStringContent(Uint8List rawBytes) { List lineStarts = []; - Token firstToken = parser_suite.scanRawBytes( - rawBytes, - nnbd ? _scannerConfiguration : _scannerConfigurationNonNNBD, - lineStarts); + Token firstToken = + parser_suite.scanRawBytes(rawBytes, _scannerConfiguration, lineStarts); ParserTestListener parserTestListener = new ParserTestListener(false); Parser parser = new Parser(parserTestListener, @@ -2151,9 +2131,9 @@ worlds: return parsedString; } - bool _parsesWithoutError(Uint8List rawBytes, bool nnbd) { - Token firstToken = parser_suite.scanRawBytes(rawBytes, - nnbd ? _scannerConfiguration : _scannerConfigurationNonNNBD, null); + bool _parsesWithoutError(Uint8List rawBytes) { + Token firstToken = + parser_suite.scanRawBytes(rawBytes, _scannerConfiguration, null); ParserErrorListener parserErrorListener = new ParserErrorListener(); Parser parser = new Parser(parserErrorListener, @@ -2162,11 +2142,8 @@ worlds: return !parserErrorListener.gotError; } - ScannerConfiguration _scannerConfiguration = new ScannerConfiguration( - enableTripleShift: true, enableNonNullable: true); - - ScannerConfiguration _scannerConfigurationNonNNBD = new ScannerConfiguration( - enableTripleShift: true, enableNonNullable: false); + ScannerConfiguration _scannerConfiguration = + new ScannerConfiguration(enableTripleShift: true); List? _dataCache; String? _dataCacheString; diff --git a/pkg/front_end/test/lint_suite.dart b/pkg/front_end/test/lint_suite.dart index 08f33759f64c..34db7ded90c1 100644 --- a/pkg/front_end/test/lint_suite.dart +++ b/pkg/front_end/test/lint_suite.dart @@ -135,8 +135,7 @@ class LintStep extends Step { Uint8List bytes = description.cache.rawBytes = f.readAsBytesSync(); Utf8BytesScanner scanner = new Utf8BytesScanner( bytes, - configuration: const ScannerConfiguration( - enableNonNullable: true, enableTripleShift: true), + configuration: const ScannerConfiguration(enableTripleShift: true), includeComments: true, languageVersionChanged: (scanner, languageVersion) { // Nothing - but don't overwrite the previous settings. diff --git a/pkg/front_end/test/parser/parser_ast_test.dart b/pkg/front_end/test/parser/parser_ast_test.dart index 65f506fbd0b6..d9a7af8bfa1f 100644 --- a/pkg/front_end/test/parser/parser_ast_test.dart +++ b/pkg/front_end/test/parser/parser_ast_test.dart @@ -39,7 +39,6 @@ void canParseTopLevelIshOfAllFrontendFiles() { data, includeBody: true, includeComments: true, - enableNonNullable: true, enableTripleShift: true, ); splitIntoChunks(ast, data); @@ -80,8 +79,8 @@ void testTopLevelStuff() { File file = new File.fromUri( base.resolve("parser_ast_test_data/top_level_stuff.txt")); Uint8List data = file.readAsBytesSync(); - CompilationUnitEnd ast = getAST(data, - includeBody: true, includeComments: true, enableNonNullable: false); + CompilationUnitEnd ast = + getAST(data, includeBody: true, includeComments: true); expect(2, ast.getImports().length); expect(2, ast.getExports().length); @@ -134,8 +133,7 @@ void testTopLevelStuff() { file = new File.fromUri( base.resolve("parser_ast_test_data/top_level_stuff_helper.txt")); data = file.readAsBytesSync(); - ast = getAST(data, - includeBody: true, includeComments: true, enableNonNullable: false); + ast = getAST(data, includeBody: true, includeComments: true); foundChunks = splitIntoChunks(ast, data); expect(1, foundChunks.length); expect("part of 'top_level_stuff.txt';", foundChunks[0]); @@ -143,8 +141,7 @@ void testTopLevelStuff() { file = new File.fromUri(base.resolve("parser_ast_test_data/script_handle.txt")); data = file.readAsBytesSync(); - ast = getAST(data, - includeBody: true, includeComments: true, enableNonNullable: false); + ast = getAST(data, includeBody: true, includeComments: true); foundChunks = splitIntoChunks(ast, data); expect(1, foundChunks.length); expect("#!/usr/bin/env dart -c", foundChunks[0]); @@ -153,8 +150,8 @@ void testTopLevelStuff() { void testClassStuff() { File file = new File.fromUri(base.resolve("parser_ast_test_data/class.txt")); Uint8List data = file.readAsBytesSync(); - CompilationUnitEnd ast = getAST(data, - includeBody: true, includeComments: true, enableNonNullable: false); + CompilationUnitEnd ast = + getAST(data, includeBody: true, includeComments: true); List classes = ast.getClasses(); expect(2, classes.length); @@ -234,8 +231,8 @@ void testClassStuff() { void testMixinStuff() { File file = new File.fromUri(base.resolve("parser_ast_test_data/mixin.txt")); Uint8List data = file.readAsBytesSync(); - CompilationUnitEnd ast = getAST(data, - includeBody: true, includeComments: true, enableNonNullable: false); + CompilationUnitEnd ast = + getAST(data, includeBody: true, includeComments: true); List mixins = ast.getMixinDeclarations(); expect(mixins.length, 1); diff --git a/pkg/front_end/test/parser_suite.dart b/pkg/front_end/test/parser_suite.dart index 1cb1f0f67ffa..e5168ae2bd42 100644 --- a/pkg/front_end/test/parser_suite.dart +++ b/pkg/front_end/test/parser_suite.dart @@ -72,26 +72,15 @@ Future createContext(Chain suite, Map environment) { } ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableTripleShift: true, - enableNonNullable: true, - forAugmentationLibrary: false); - -ScannerConfiguration scannerConfigurationNonNNBD = new ScannerConfiguration( - enableTripleShift: true, - enableNonNullable: false, - forAugmentationLibrary: false); + enableTripleShift: true, forAugmentationLibrary: false); ScannerConfiguration scannerConfigurationNonTripleShift = new ScannerConfiguration( - enableTripleShift: false, - enableNonNullable: true, - forAugmentationLibrary: false); + enableTripleShift: false, forAugmentationLibrary: false); ScannerConfiguration scannerConfigurationAugmentation = new ScannerConfiguration( - enableTripleShift: true, - enableNonNullable: true, - forAugmentationLibrary: true); + enableTripleShift: true, forAugmentationLibrary: true); class Context extends ChainContext with MatchContext { @override @@ -401,8 +390,8 @@ Token scanUri(Uri uri, String shortName, {List? lineStarts}) { ScannerConfiguration config; String firstDir = shortName.split("/")[0]; - if (firstDir == "non-nnbd") { - config = scannerConfigurationNonNNBD; + if (firstDir == "also-nnbd") { + config = scannerConfigurationNonTripleShift; } else if (firstDir == "no-triple-shift") { config = scannerConfigurationNonTripleShift; } else if (firstDir == "augmentation") { diff --git a/pkg/front_end/test/scanner_test.dart b/pkg/front_end/test/scanner_test.dart index cea27844ee2c..862e2f948cda 100644 --- a/pkg/front_end/test/scanner_test.dart +++ b/pkg/front_end/test/scanner_test.dart @@ -588,13 +588,7 @@ abstract class ScannerTestBase { } void test_keyword_late() { - _assertKeywordToken("late", - configuration: ScannerConfiguration(enableNonNullable: true)); - } - - void test_keyword_late_old() { - _assertNotKeywordToken("late", - configuration: ScannerConfiguration(enableNonNullable: false)); + _assertKeywordToken("late", configuration: ScannerConfiguration()); } void test_keyword_library() { @@ -642,13 +636,7 @@ abstract class ScannerTestBase { } void test_keyword_required() { - _assertKeywordToken("required", - configuration: ScannerConfiguration(enableNonNullable: true)); - } - - void test_keyword_required_disabled() { - _assertNotKeywordToken("required", - configuration: ScannerConfiguration(enableNonNullable: false)); + _assertKeywordToken("required", configuration: ScannerConfiguration()); } void test_keyword_rethrow() { @@ -1443,27 +1431,6 @@ abstract class ScannerTestBase { expect(token.next!.type, TokenType.EOF); } - /** - * Assert that when scanned the given [source] contains a single identifier - * token with the same lexeme as the original source. - */ - void _assertNotKeywordToken(String source, - {ScannerConfiguration? configuration}) { - Token token = _scan(source, configuration: configuration); - expect(token, isNotNull); - expect(token.type.isKeyword, false); - expect(token.offset, 0); - expect(token.length, source.length); - expect(token.lexeme, source); - token = _scan(" $source ", configuration: configuration); - expect(token, isNotNull); - expect(token.type.isKeyword, false); - expect(token.offset, 1); - expect(token.length, source.length); - expect(token.lexeme, source); - expect(token.next!.type, TokenType.EOF); - } - /** * Assert that the token scanned from the given [source] has the * [expectedType]. diff --git a/pkg/front_end/test/testing/suite.dart b/pkg/front_end/test/testing/suite.dart index bf859742ae84..a38b1f7c2c6a 100644 --- a/pkg/front_end/test/testing/suite.dart +++ b/pkg/front_end/test/testing/suite.dart @@ -1625,7 +1625,6 @@ class FuzzAstVisitorSorter extends IgnoreSomeForCompatibilityAstVisitor { CompilationUnitEnd ast = getAST(bytes, includeBody: false, includeComments: true, - enableNonNullable: true, allowPatterns: allowPatterns); ast.accept(this); diff --git a/pkg/front_end/test/textual_outline_suite.dart b/pkg/front_end/test/textual_outline_suite.dart index 73a65fa8d312..ffcfbf6389f7 100644 --- a/pkg/front_end/test/textual_outline_suite.dart +++ b/pkg/front_end/test/textual_outline_suite.dart @@ -116,8 +116,6 @@ class TextualOutline extends Step { String? result = textualOutline( bytes, new ScannerConfiguration( - enableNonNullable: isExperimentEnabled(ExperimentalFlag.nonNullable, - explicitExperimentalFlags: experimentalFlags), enableTripleShift: isExperimentEnabled(ExperimentalFlag.tripleShift, explicitExperimentalFlags: experimentalFlags), ), diff --git a/pkg/front_end/test/utils/kernel_chain.dart b/pkg/front_end/test/utils/kernel_chain.dart index 49acbb425c26..fb8ddaaf4f1d 100644 --- a/pkg/front_end/test/utils/kernel_chain.dart +++ b/pkg/front_end/test/utils/kernel_chain.dart @@ -334,8 +334,7 @@ class ErrorCommentChecker Uint8List rawBytes = f.readAsBytesSync(); Utf8BytesScanner scanner = new Utf8BytesScanner( rawBytes, - configuration: const ScannerConfiguration( - enableNonNullable: true, enableTripleShift: true), + configuration: const ScannerConfiguration(enableTripleShift: true), includeComments: true, languageVersionChanged: (scanner, languageVersion) { // Nothing - but don't overwrite the previous settings. diff --git a/pkg/front_end/test/web_parser_git_test_helper.dart b/pkg/front_end/test/web_parser_git_test_helper.dart index 3b5e4f6a20fd..66b3309e718c 100644 --- a/pkg/front_end/test/web_parser_git_test_helper.dart +++ b/pkg/front_end/test/web_parser_git_test_helper.dart @@ -16,8 +16,8 @@ void main(List args) { } """; - ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableNonNullable: true, enableTripleShift: true); + ScannerConfiguration scannerConfiguration = + new ScannerConfiguration(enableTripleShift: true); StringScanner scanner = new StringScanner( source, diff --git a/pkg/front_end/tool/coverage_merger.dart b/pkg/front_end/tool/coverage_merger.dart index 5012acfb5ff4..14aa17b088ab 100644 --- a/pkg/front_end/tool/coverage_merger.dart +++ b/pkg/front_end/tool/coverage_merger.dart @@ -267,7 +267,6 @@ CoverageInfo _process( CompilationUnitEnd ast = getAST( rawBytes, includeComments: true, - enableNonNullable: true, enableTripleShift: true, allowPatterns: true, lineStarts: lineStarts, diff --git a/pkg/front_end/tool/dart_doctest_impl.dart b/pkg/front_end/tool/dart_doctest_impl.dart index b4dc6674bc70..a3f10fcc8238 100644 --- a/pkg/front_end/tool/dart_doctest_impl.dart +++ b/pkg/front_end/tool/dart_doctest_impl.dart @@ -530,8 +530,8 @@ List extractTests(Uint8List rawBytes, Uri uriForReporting) { } Token scanRawBytes(Uint8List rawBytes, {List? lineStarts}) { - ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableNonNullable: true, enableTripleShift: true); + ScannerConfiguration scannerConfiguration = + new ScannerConfiguration(enableTripleShift: true); Utf8BytesScanner scanner = new Utf8BytesScanner( rawBytes, diff --git a/pkg/front_end/tool/duplicate_code_finder_experiment.dart b/pkg/front_end/tool/duplicate_code_finder_experiment.dart index b28d9152276c..519c31112b7c 100644 --- a/pkg/front_end/tool/duplicate_code_finder_experiment.dart +++ b/pkg/front_end/tool/duplicate_code_finder_experiment.dart @@ -329,9 +329,7 @@ List? _extend(List lines, Token _scan(String data) { ScannerConfiguration scannerConfiguration = new ScannerConfiguration( - enableTripleShift: true, - enableNonNullable: true, - forAugmentationLibrary: false); + enableTripleShift: true, forAugmentationLibrary: false); StringScanner scanner = new StringScanner(data, configuration: scannerConfiguration); diff --git a/pkg/front_end/tool/fuzz/minimizer.dart b/pkg/front_end/tool/fuzz/minimizer.dart index da0b65d85562..ed477d67e6a2 100644 --- a/pkg/front_end/tool/fuzz/minimizer.dart +++ b/pkg/front_end/tool/fuzz/minimizer.dart @@ -33,7 +33,6 @@ Future main(List args) async { CompilationUnitEnd ast = getAST( rawBytes, includeComments: true, - enableNonNullable: true, enableTripleShift: true, allowPatterns: true, ); diff --git a/pkg/front_end/tool/parser_direct_ast/viewer.dart b/pkg/front_end/tool/parser_direct_ast/viewer.dart index cac6d096f10a..5c0bec5ec68a 100644 --- a/pkg/front_end/tool/parser_direct_ast/viewer.dart +++ b/pkg/front_end/tool/parser_direct_ast/viewer.dart @@ -19,7 +19,6 @@ void main(List args) { Uint8List bytes = new File.fromUri(uri).readAsBytesSync(); ParserAstNode ast = getAST( bytes, - enableNonNullable: true, enableTripleShift: true, allowPatterns: true, ); From 11a4a94b950db8d409c7c6eb7c571282c99ac0ce Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Mon, 13 Jan 2025 00:54:14 -0800 Subject: [PATCH 3/5] [infra-ish] Fix compile_flutter.sh after flutter engine was merged into flutter/flutter This should fix the current failures on the flutter-frontend bot. Change-Id: I26268a002055aca2eb46af74003b6c30df3efed9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404101 Reviewed-by: Alexander Thomas Commit-Queue: Jens Johansen --- tools/bots/flutter/compile_flutter.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tools/bots/flutter/compile_flutter.sh b/tools/bots/flutter/compile_flutter.sh index 045c82cc63c4..fb2d6bce8e98 100755 --- a/tools/bots/flutter/compile_flutter.sh +++ b/tools/bots/flutter/compile_flutter.sh @@ -59,24 +59,17 @@ git clone --single-branch -vv \ pushd flutter bin/flutter config --no-analytics bin/flutter update-packages -popd # flutter - -# Directly in temp directory again. -git clone --single-branch --depth=1 -vv \ - https://dart.googlesource.com/external/github.com/flutter/buildroot src -pushd src -git clone --single-branch --branch main --depth=1 -vv \ - https://dart.googlesource.com/external/github.com/flutter/engine flutter -pushd flutter -mkdir -p third_party -pushd third_party +pushd engine +pushd src/flutter/third_party ln -s $checkout dart -popd # third_party -popd # flutter -popd # src +popd # src/flutter/third_party +# This script doesn't seem to work anymore. ./src/flutter/third_party/dart/tools/patches/flutter-engine/apply.sh || true +popd # engine +popd # flutter + mkdir flutter_patched_sdk $checkout/tools/sdks/dart-sdk/bin/dart \ @@ -100,7 +93,7 @@ $checkout/tools/sdks/dart-sdk/bin/dart \ --target=flutter \ dart:core \ --single-root-scheme=org-dartlang-sdk \ - --single-root-base=src \ + --single-root-base=flutter/engine/src \ org-dartlang-sdk:///flutter/lib/snapshot/libraries.json \ vm_outline_strong.dill \ flutter_patched_sdk/platform_strong.dill \ From 86ff64c97d40bdcf5b5dfc114c8ed56540aa341e Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Mon, 13 Jan 2025 01:47:30 -0800 Subject: [PATCH 4/5] [CFE] Fix weekly but needing dart2js_platform_unsound.dill The weekly bot currently fails because the weak suite no longer have dart2js_platform_unsound.dill available. This CL fixes that. Change-Id: I2a8e71b6b8ce1ec9a9aa3d9456245c217f8ac26d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404102 Reviewed-by: Alexander Thomas Commit-Queue: Jens Johansen --- tools/bots/test_matrix.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json index 4810190fe07f..851040962b63 100644 --- a/tools/bots/test_matrix.json +++ b/tools/bots/test_matrix.json @@ -3476,7 +3476,8 @@ "--mode=release", "--arch=x64", "create_sdk", - "ddc_stable_unsound_sdk" + "ddc_stable_unsound_sdk", + "dart2js_platform_unsound.dill" ] }, { From 8063ed194b781f4c44fe7c714b54f49654470ea4 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Mon, 13 Jan 2025 02:37:13 -0800 Subject: [PATCH 5/5] [CFE] Spell checker improvements - Spell checker in interactive mode shows the 'close words' (if any) when asking if wanting to add a word to the directory. Hopefully this will make it less likely adding wrong words to the dictionary. - When finding 'close' words it now also tries to insert a letter at the end which it erroneously didn't before. The close words method is also tested better. Change-Id: Ic2628fc261ecb4d9c9322a0ab8c462b174707051 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403863 Commit-Queue: Jens Johansen Reviewed-by: Johnni Winther --- pkg/front_end/test/messages_suite.dart | 7 +-- pkg/front_end/test/spell_checking_utils.dart | 45 ++++++++++++------- .../test/spell_checking_utils_test.dart | 27 +++++++++++ pkg/front_end/test/spelling_test_base.dart | 6 +-- 4 files changed, 64 insertions(+), 21 deletions(-) diff --git a/pkg/front_end/test/messages_suite.dart b/pkg/front_end/test/messages_suite.dart index c4d5a75fe37b..b476ccd0c721 100644 --- a/pkg/front_end/test/messages_suite.dart +++ b/pkg/front_end/test/messages_suite.dart @@ -89,7 +89,7 @@ class MessageTestSuite extends ChainContext { final bool fastOnly; final bool interactive; - final Set reportedWords = {}; + final Map?> reportedWordsAndAlternatives = {}; final Set reportedWordsDenylisted = {}; @override @@ -103,7 +103,7 @@ class MessageTestSuite extends ChainContext { } String suitePath = suiteFile.path; spell.spellSummarizeAndInteractiveMode( - reportedWords, + reportedWordsAndAlternatives, reportedWordsDenylisted, [spell.Dictionaries.cfeMessages], interactive, @@ -182,7 +182,8 @@ class MessageTestSuite extends ChainContext { messageToUse = messageForDenyListed; reportedWordsDenylisted.add(spellResult.misspelledWords![i]); } else { - reportedWords.add(spellResult.misspelledWords![i]); + reportedWordsAndAlternatives[spellResult.misspelledWords![i]] = + spellResult.misspelledWordsAlternatives![i]; } result.add(command_line_reporting.formatErrorMessage( source!.getTextLine(location.line), diff --git a/pkg/front_end/test/spell_checking_utils.dart b/pkg/front_end/test/spell_checking_utils.dart index 2f3c9283a835..508d2296da22 100644 --- a/pkg/front_end/test/spell_checking_utils.dart +++ b/pkg/front_end/test/spell_checking_utils.dart @@ -82,28 +82,36 @@ List? findAlternatives(String word, List> dictionaries) { (result ??= []).add(w); } + void checkInsert(String before, String afterIncluding) { + for (int j = 0; j < 25; j++) { + String c = new String.fromCharCode(97 + j); + String insertedLetter = "${before}${c}${afterIncluding}"; + if (check(insertedLetter)) ok(insertedLetter); + } + } + // Delete a letter, insert a letter or change a letter and lookup. for (int i = 0; i < word.length; i++) { String before = word.substring(0, i); - String after = word.substring(i + 1); - String afterIncluding = word.substring(i); + String afterExcluding = word.substring(i + 1); { - String deletedLetter = before + after; + String deletedLetter = "${before}${afterExcluding}"; if (check(deletedLetter)) ok(deletedLetter); } + + checkInsert(before, word.substring(i)); + for (int j = 0; j < 25; j++) { String c = new String.fromCharCode(97 + j); - String insertedLetter = before + c + afterIncluding; - if (check(insertedLetter)) ok(insertedLetter); - } - for (int j = 0; j < 25; j++) { - String c = new String.fromCharCode(97 + j); - String replacedLetter = before + c + after; + String replacedLetter = "${before}${c}${afterExcluding}"; if (check(replacedLetter)) ok(replacedLetter); } } + // Check insert at end. + checkInsert(word, ""); + return result; } @@ -347,7 +355,7 @@ List splitStringIntoWords(String s, List splitOffsets, } void spellSummarizeAndInteractiveMode( - Set reportedWords, + Map?> reportedWordsAndAlternatives, Set reportedWordsDenylisted, List dictionaries, bool interactive, @@ -365,8 +373,8 @@ void spellSummarizeAndInteractiveMode( } print("================"); } - if (reportedWords.isNotEmpty) { - bool isSingular = reportedWords.length == 1; + if (reportedWordsAndAlternatives.isNotEmpty) { + bool isSingular = reportedWordsAndAlternatives.length == 1; String suffix = isSingular ? "" : "s"; String were = isSingular ? "was" : "were"; String are = isSingular ? "is" : "are"; @@ -394,8 +402,15 @@ void spellSummarizeAndInteractiveMode( if (interactive && dictionaryToUse != null) { List addedWords = []; - for (String s in reportedWords) { - print("- $s"); + for (MapEntry?> wordAndAlternative + in reportedWordsAndAlternatives.entries) { + String s = wordAndAlternative.key; + List? alternative = wordAndAlternative.value; + if (alternative != null) { + print(" - $s (notice close word(s)): ${alternative.join(", ")})"); + } else { + print(" - $s"); + } String answer; bool? add; while (true) { @@ -451,7 +466,7 @@ void spellSummarizeAndInteractiveMode( dictionaryFile.writeAsStringSync(lines.join("\n")); } } else { - for (String s in reportedWords) { + for (String s in reportedWordsAndAlternatives.keys) { print("$s"); } if (dictionaries.isNotEmpty) { diff --git a/pkg/front_end/test/spell_checking_utils_test.dart b/pkg/front_end/test/spell_checking_utils_test.dart index c4aa4dce272e..797caf490cd7 100644 --- a/pkg/front_end/test/spell_checking_utils_test.dart +++ b/pkg/front_end/test/spell_checking_utils_test.dart @@ -90,6 +90,33 @@ void main() { "explicitley", ["explicitly"], {"foo", "explicitly", "bar"}); expectAlternative("explicitlqqqqy", null, {"foo", "explicitly", "bar"}); + // Insert first letter. + expectAlternative("ar", ["bar"], {"foo", "explicitly", "bar"}); + + // Insert middle letter. + expectAlternative("br", ["bar"], {"foo", "explicitly", "bar"}); + + // Insert last letter. + expectAlternative("ba", ["bar"], {"foo", "explicitly", "bar"}); + + // Delete first letter. + expectAlternative("xbar", ["bar"], {"foo", "explicitly", "bar"}); + + // Delete middle letter. + expectAlternative("bxar", ["bar"], {"foo", "explicitly", "bar"}); + + // Delete last letter. + expectAlternative("barx", ["bar"], {"foo", "explicitly", "bar"}); + + // Replace first letter. + expectAlternative("car", ["bar"], {"foo", "explicitly", "bar"}); + + // Replace middle letter. + expectAlternative("bcr", ["bar"], {"foo", "explicitly", "bar"}); + + // Replace last letter. + expectAlternative("bac", ["bar"], {"foo", "explicitly", "bar"}); + print("OK"); } diff --git a/pkg/front_end/test/spelling_test_base.dart b/pkg/front_end/test/spelling_test_base.dart index b60c5b665b9e..ffef67f29036 100644 --- a/pkg/front_end/test/spelling_test_base.dart +++ b/pkg/front_end/test/spelling_test_base.dart @@ -36,7 +36,7 @@ abstract class SpellContext extends ChainContext { String get repoRelativeSuitePath; - Set reportedWords = {}; + Map?> reportedWordsAndAlternatives = {}; Set reportedWordsDenylisted = {}; @override @@ -54,7 +54,7 @@ abstract class SpellContext extends ChainContext { } String suitePath = suiteFile.path; spell.spellSummarizeAndInteractiveMode( - reportedWords, + reportedWordsAndAlternatives, reportedWordsDenylisted, dictionaries, interactive, @@ -92,7 +92,7 @@ class SpellTest extends Step { context.reportedWordsDenylisted.add(word); } else { message = "The word '$word' is not in our dictionary."; - context.reportedWords.add(word); + context.reportedWordsAndAlternatives[word] = alternatives; } if (alternatives != null && alternatives.isNotEmpty) { message += "\n\nThe following word(s) was 'close' "