Version 2.18.0-198.0.dev
Merge commit '6d923dfd992c7a3805564ad50c7df99e65766072' into 'dev'
diff --git a/DEPS b/DEPS
index a07f262..c048fa6 100644
--- a/DEPS
+++ b/DEPS
@@ -66,8 +66,8 @@
# The list of revisions for these tools comes from Fuchsia, here:
# https://fuchsia.googlesource.com/integration/+/HEAD/toolchain
# If there are problems with the toolchain, contact fuchsia-toolchain@.
- "clang_revision": "c2592c374e469f343ecea82d6728609650924259",
- "gn_revision": "d7c2209cebcfe37f46dba7be4e1a7000ffc342fb",
+ "clang_revision": "aaaf8e4c409f080f35ea227b20dc6ac8a45c2fa4",
+ "gn_revision": "e62d4e1938a45babc9afb6db543f388cd1802a52",
# Scripts that make 'git cl format' work.
"clang_format_scripts_rev": "bb994c6f067340c1135eb43eed84f4b33cfa7397",
@@ -163,7 +163,7 @@
"webkit_inspection_protocol_rev": "e4965778e2837adc62354eec3a19123402997897",
"yaml_edit_rev": "0b74d85fac10b4fbf7d1a347debcf16c8f7b0e9c",
"yaml_rev": "0971c06490b9670add644ed62182acd6a5536946",
- "zlib_rev": "27c2f474b71d0d20764f86f60ef8b00da1a16cda",
+ "zlib_rev": "64bbf988543996eb8df9a86877b32917187eba8f",
# Windows deps
"crashpad_rev": "bf327d8ceb6a669607b0dbab5a83a275d03f99ed",
diff --git a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
index a72b342..654ab4a 100644
--- a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
@@ -2645,8 +2645,7 @@
@override
String toString() {
- SsaNode self = this; // Work around #44475
- int id = _debugIds[self] ??= _nextDebugId++;
+ int id = _debugIds[this] ??= _nextDebugId++;
return 'ssa$id';
}
}
diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
index 9e00504..04d9334 100644
--- a/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
+++ b/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
@@ -16,6 +16,18 @@
const jsonEncoder = JsonEncoder.withIndent(' ');
+/// Result for a request to resolve the incoming calls for a given
+/// `CallHierarchyItem`.
+///
+/// @since 3.16.0
+typedef CallHierarchyIncomingCallsResult = List<CallHierarchyIncomingCall>?;
+
+/// Result for a request to resolve the outgoing calls for a given
+/// `CallHierarchyItem`.
+///
+/// @since 3.16.0
+typedef CallHierarchyOutgoingCallsResult = List<CallHierarchyOutgoingCall>?;
+
/// An identifier to refer to a change annotation stored with a workspace edit.
typedef ChangeAnnotationIdentifier = String;
@@ -119,11 +131,61 @@
= Either3<PlaceholderAndRange, PrepareRenameResult2, Range>;
typedef ProgressToken = Either2<int, String>;
+/// Result for a request to provide commands for the given text document and
+/// range.
+typedef TextDocumentCodeActionResult = List<Either2<CodeAction, Command>>?;
+
+/// Result for a request to provide code lens for the given text document.
+typedef TextDocumentCodeLensResult = List<CodeLens>?;
+
+/// Result for request to request completion at a given text document position.
+/// The request's parameter is of type TextDocumentPosition the response is of
+/// type [CompletionItem[]](#CompletionItem) or CompletionList or a Thenable
+/// that resolves to such.
+///
+/// The request can delay the computation of the `detail` and `documentation`
+/// properties to the `completionItem/resolve` request. However, properties that
+/// are needed for the initial sorting and filtering, like `sortText`,
+/// `filterText`, `insertText`, and `textEdit`, must not be changed during
+/// resolve.
+typedef TextDocumentCompletionResult
+ = Either2<CompletionList, List<CompletionItem>>?;
+
/// An event describing a change to a text document. If only a text is provided
/// it is considered to be the full content of the document.
typedef TextDocumentContentChangeEvent
= Either2<TextDocumentContentChangeEvent1, TextDocumentContentChangeEvent2>;
+/// Result for a request to resolve the type definition locations of a symbol at
+/// a given text document position. The request's parameter is of type
+/// TextDocumentPositionParams the response is of type Declaration or a typed
+/// array of DeclarationLink or a Thenable that resolves to such.
+typedef TextDocumentDeclarationResult
+ = Either2<Declaration, List<DeclarationLink>>?;
+
+/// Result for a request to resolve the definition location of a symbol at a
+/// given text document position. The request's parameter is of type
+/// TextDocumentPosition the response is of either type Definition or a typed
+/// array of DefinitionLink or a Thenable that resolves to such.
+typedef TextDocumentDefinitionResult
+ = Either2<Definition, List<DefinitionLink>>?;
+
+/// Result for request to resolve a DocumentHighlight for a given text document
+/// position. The request's parameter is of type TextDocumentPosition the
+/// request response is of type [DocumentHighlight[]] (#DocumentHighlight) or a
+/// Thenable that resolves to such.
+typedef TextDocumentDocumentHighlightResult = List<DocumentHighlight>?;
+
+/// Result for a request to provide document links
+typedef TextDocumentDocumentLinkResult = List<DocumentLink>?;
+
+/// Result for a request to list all symbols found in a given text document. The
+/// request's parameter is of type TextDocumentIdentifier the response is of
+/// type [SymbolInformation[]](#SymbolInformation) or a Thenable that resolves
+/// to such.
+typedef TextDocumentDocumentSymbolResult
+ = Either2<List<DocumentSymbol>, List<SymbolInformation>>?;
+
/// A document filter denotes a document by different properties like the
/// language, the scheme of its resource, or a glob-pattern that is applied to
/// the path.
@@ -148,6 +210,131 @@
typedef TextDocumentFilter = Either3<TextDocumentFilter1,
TextDocumentFilterWithScheme, TextDocumentFilter3>;
+/// Result for a request to provide folding ranges in a document. The request's
+/// parameter is of type FoldingRangeParams, the response is of type
+/// FoldingRangeList or a Thenable that resolves to such.
+typedef TextDocumentFoldingRangeResult = List<FoldingRange>?;
+
+/// Result for a request to to format a whole document.
+typedef TextDocumentFormattingResult = List<TextEdit>?;
+
+/// Result for request to request hover information at a given text document
+/// position. The request's parameter is of type TextDocumentPosition the
+/// response is of type Hover or a Thenable that resolves to such.
+typedef TextDocumentHoverResult = Hover?;
+
+/// Result for a request to resolve the implementation locations of a symbol at
+/// a given text document position. The request's parameter is of type
+/// TextDocumentPositionParams the response is of type Definition or a Thenable
+/// that resolves to such.
+typedef TextDocumentImplementationResult
+ = Either2<Definition, List<DefinitionLink>>?;
+
+/// Result for a request to provide inlay hints in a document. The request's
+/// parameter is of type InlayHintsParams, the response is of type
+/// [InlayHint[]](#InlayHint[]) or a Thenable that resolves to such.
+///
+/// @since 3.17.0
+typedef TextDocumentInlayHintResult = List<InlayHint>?;
+
+/// Result for a request to provide inline values in a document. The request's
+/// parameter is of type InlineValueParams, the response is of type
+/// [InlineValue[]](#InlineValue[]) or a Thenable that resolves to such.
+///
+/// @since 3.17.0
+typedef TextDocumentInlineValueResult = List<InlineValue>?;
+
+/// Result for a request to provide ranges that can be edited together.
+///
+/// @since 3.16.0
+typedef TextDocumentLinkedEditingRangeResult = LinkedEditingRanges?;
+
+/// Result for a request to get the moniker of a symbol at a given text document
+/// position. The request parameter is of type TextDocumentPositionParams. The
+/// response is of type [Moniker[]](#Moniker[]) or `null`.
+typedef TextDocumentMonikerResult = List<Moniker>?;
+
+/// Result for a request to format a document on type.
+typedef TextDocumentOnTypeFormattingResult = List<TextEdit>?;
+
+/// Result for a request to result a `CallHierarchyItem` in a document at a
+/// given position. Can be used as an input to an incoming or outgoing call
+/// hierarchy.
+///
+/// @since 3.16.0
+typedef TextDocumentPrepareCallHierarchyResult = List<CallHierarchyItem>?;
+
+/// Result for a request to test and perform the setup necessary for a rename.
+///
+/// @since 3.16 - support for default behavior
+typedef TextDocumentPrepareRenameResult = PrepareRenameResult?;
+
+/// Result for a request to result a `TypeHierarchyItem` in a document at a
+/// given position. Can be used as an input to a subtypes or supertypes type
+/// hierarchy.
+///
+/// @since 3.17.0
+typedef TextDocumentPrepareTypeHierarchyResult = List<TypeHierarchyItem>?;
+
+/// Result for a request to to format a range in a document.
+typedef TextDocumentRangeFormattingResult = List<TextEdit>?;
+
+/// Result for a request to resolve project-wide references for the symbol
+/// denoted by the given text document position. The request's parameter is of
+/// type ReferenceParams the response is of type [Location[]](#Location) or a
+/// Thenable that resolves to such.
+typedef TextDocumentReferencesResult = List<Location>?;
+
+/// Result for a request to rename a symbol.
+typedef TextDocumentRenameResult = WorkspaceEdit?;
+
+/// Result for a request to provide selection ranges in a document. The
+/// request's parameter is of type SelectionRangeParams, the response is of type
+/// [SelectionRange[]](#SelectionRange[]) or a Thenable that resolves to such.
+typedef TextDocumentSelectionRangeResult = List<SelectionRange>?;
+
+/// Result for @since 3.16.0
+typedef TextDocumentSemanticTokensFullDeltaResult
+ = Either2<SemanticTokens, SemanticTokensDelta>?;
+
+/// Result for @since 3.16.0
+typedef TextDocumentSemanticTokensFullResult = SemanticTokens?;
+
+/// Result for @since 3.16.0
+typedef TextDocumentSemanticTokensRangeResult = SemanticTokens?;
+typedef TextDocumentSignatureHelpResult = SignatureHelp?;
+
+/// Result for a request to resolve the type definition locations of a symbol at
+/// a given text document position. The request's parameter is of type
+/// TextDocumentPositioParams the response is of type Definition or a Thenable
+/// that resolves to such.
+typedef TextDocumentTypeDefinitionResult
+ = Either2<Definition, List<DefinitionLink>>?;
+
+/// Result for a document will save request is sent from the client to the
+/// server before the document is actually saved. The request can return an
+/// array of TextEdits which will be applied to the text document before it is
+/// saved. Please note that clients might drop results if computing the text
+/// edits took too long or if a server constantly fails on this request. This is
+/// done to keep the save fast and reliable.
+typedef TextDocumentWillSaveWaitUntilResult = List<TextEdit>?;
+
+/// Result for a request to resolve the subtypes for a given
+/// `TypeHierarchyItem`.
+///
+/// @since 3.17.0
+typedef TypeHierarchySubtypesResult = List<TypeHierarchyItem>?;
+
+/// Result for a request to resolve the supertypes for a given
+/// `TypeHierarchyItem`.
+///
+/// @since 3.17.0
+typedef TypeHierarchySupertypesResult = List<TypeHierarchyItem>?;
+
+/// Result for the show message request is sent from the server to the client to
+/// show a message and a set of options actions to the user.
+typedef WindowShowMessageRequestResult = MessageActionItem?;
+
/// A workspace diagnostic document report.
///
/// @since 3.17.0
@@ -155,6 +342,46 @@
WorkspaceFullDocumentDiagnosticReport,
WorkspaceUnchangedDocumentDiagnosticReport>;
+/// Result for a request send from the client to the server to execute a
+/// command. The request might return a workspace edit which the client will
+/// apply to the workspace.
+typedef WorkspaceExecuteCommandResult = LSPAny?;
+
+/// Result for a request to list project-wide symbols matching the query string
+/// given by the WorkspaceSymbolParams. The response is of type
+/// [SymbolInformation[]](#SymbolInformation) or a Thenable that resolves to
+/// such.
+///
+/// @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients
+/// need to advertise support for WorkspaceSymbols via the client capability
+/// `workspace.symbol.resolveSupport`.
+typedef WorkspaceSymbolResult
+ = Either2<List<SymbolInformation>, List<WorkspaceSymbol>>?;
+
+/// Result for the will create files request is sent from the client to the
+/// server before files are actually created as long as the creation is
+/// triggered from within the client.
+///
+/// @since 3.16.0
+typedef WorkspaceWillCreateFilesResult = WorkspaceEdit?;
+
+/// Result for the did delete files notification is sent from the client to the
+/// server when files were deleted from within the client.
+///
+/// @since 3.16.0
+typedef WorkspaceWillDeleteFilesResult = WorkspaceEdit?;
+
+/// Result for the will rename files request is sent from the client to the
+/// server before files are actually renamed as long as the rename is triggered
+/// from within the client.
+///
+/// @since 3.16.0
+typedef WorkspaceWillRenameFilesResult = WorkspaceEdit?;
+
+/// Result for the `workspace/workspaceFolders` is sent from the server to the
+/// client to fetch the open workspace folders.
+typedef WorkspaceWorkspaceFoldersResult = List<WorkspaceFolder>?;
+
/// A special text edit with an additional change annotation.
///
/// @since 3.16.0.
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 082f048..f9f9301 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -874,6 +874,10 @@
/// If set, this string will be reported as the protocol version.
String? reportProtocolVersion;
+
+ /// Experiments which have been enabled (or disabled) via the
+ /// `--enable-experiment` command-line option.
+ List<String> enabledExperiments = [];
}
class ServerContextManagerCallbacks extends ContextManagerCallbacks {
diff --git a/pkg/analysis_server/lib/src/analysis_server_abstract.dart b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
index 5189728..d199752 100644
--- a/pkg/analysis_server/lib/src/analysis_server_abstract.dart
+++ b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
@@ -228,6 +228,7 @@
resourceProvider,
sdkManager,
options.packagesFile,
+ options.enabledExperiments,
byteStore,
fileContentCache,
analysisPerformanceLogger,
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index bf2d198..47748d6 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -7,6 +7,7 @@
import 'package:analysis_server/src/lsp/handlers/handlers.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_parser.dart';
+import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
@@ -206,6 +207,10 @@
/// clean up when we destroy a context.
final bazelWatchedPathsPerFolder = <Folder, _BazelWatchedFiles>{};
+ /// Experiments which have been enabled (or disabled) via the
+ /// `--enable-experiment` command-line option.
+ final List<String> _enabledExperiments;
+
/// Information about the current/last queued context rebuild.
///
/// This is used when a new build is requested to cancel any in-progress
@@ -216,6 +221,7 @@
this.resourceProvider,
this.sdkManager,
this.packagesFile,
+ this._enabledExperiments,
this._byteStore,
this._fileContentCache,
this._performanceLog,
@@ -456,6 +462,18 @@
sdkPath: sdkManager.defaultSdkDirectory,
packagesFile: packagesFile,
fileContentCache: _fileContentCache,
+ updateAnalysisOptions2: ({
+ required analysisOptions,
+ required contextRoot,
+ required sdk,
+ }) {
+ if (_enabledExperiments.isNotEmpty) {
+ analysisOptions.contextFeatures = FeatureSet.fromEnableFlags2(
+ sdkLanguageVersion: sdk.languageVersion,
+ flags: _enabledExperiments,
+ );
+ }
+ },
);
for (var analysisContext in collection.contexts) {
diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart
index 7eca97f..20e9aaf 100644
--- a/pkg/analysis_server/lib/src/server/driver.dart
+++ b/pkg/analysis_server/lib/src/server/driver.dart
@@ -65,6 +65,9 @@
static const String DISABLE_SERVER_FEATURE_SEARCH =
'disable-server-feature-search';
+ /// The name of the multi-option to enable one or more experiments.
+ static const String ENABLE_EXPERIMENT = 'enable-experiment';
+
/// The name of the option used to print usage information.
static const String HELP_OPTION = 'help';
@@ -170,6 +173,11 @@
analysisServerOptions.reportProtocolVersion =
results[REPORT_PROTOCOL_VERSION] as String?;
+ analysisServerOptions.enabledExperiments =
+ results.wasParsed(ENABLE_EXPERIMENT)
+ ? results[ENABLE_EXPERIMENT] as List<String>
+ : <String>[];
+
// Read in any per-SDK overrides specified in <sdk>/config/settings.json.
var sdkConfig = SdkConfiguration.readFromSdk();
analysisServerOptions.configurationOverrides = sdkConfig;
@@ -689,6 +697,13 @@
help: 'The path to the package resolution configuration file, which '
'supplies a mapping of package names\ninto paths.',
);
+ parser.addMultiOption(
+ ENABLE_EXPERIMENT,
+ valueHelp: 'experiment',
+ help: 'Enable one or more experimental features '
+ '(see dart.dev/go/experiments).',
+ hide: true,
+ );
parser.addOption(
SERVER_PROTOCOL,
@@ -784,8 +799,6 @@
parser.addFlag('dartpad', hide: true);
// Removed 11/15/2020.
parser.addFlag('enable-completion-model', hide: true);
- // Removed 10/30/2020.
- parser.addMultiOption('enable-experiment', hide: true);
// Removed 9/23/2020.
parser.addFlag('enable-instrumentation', hide: true);
// Removed 11/12/2020.
diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart
index b3f677f..2799810 100644
--- a/pkg/analysis_server/test/lsp/server_abstract.dart
+++ b/pkg/analysis_server/test/lsp/server_abstract.dart
@@ -1753,7 +1753,7 @@
Future<ResponseMessage> sendDidChangeConfiguration() {
final request = makeRequest(
Method.workspace_didChangeConfiguration,
- DidChangeConfigurationParams(settings: {}),
+ DidChangeConfigurationParams(),
);
return sendRequestToServer(request);
}
diff --git a/pkg/analysis_server/tool/lsp_spec/meta_model.dart b/pkg/analysis_server/tool/lsp_spec/meta_model.dart
index 20aadea..8273079 100644
--- a/pkg/analysis_server/tool/lsp_spec/meta_model.dart
+++ b/pkg/analysis_server/tool/lsp_spec/meta_model.dart
@@ -226,6 +226,7 @@
/// Renames will be followed when generating code, but other aliases may be
/// created as `typedef`s.
final bool isRename;
+
TypeAlias({
required super.name,
super.comment,
diff --git a/pkg/analysis_server/tool/lsp_spec/meta_model_reader.dart b/pkg/analysis_server/tool/lsp_spec/meta_model_reader.dart
index 3be39a9..aa11e78 100644
--- a/pkg/analysis_server/tool/lsp_spec/meta_model_reader.dart
+++ b/pkg/analysis_server/tool/lsp_spec/meta_model_reader.dart
@@ -49,6 +49,12 @@
...?typeAliases?.map(_readTypeAlias),
].forEach(_addType);
+ // Requests and notifications may have inline union types as their
+ // params/result. We can create TypeAliases for those using sensible
+ // names to simplify their use in the handlers.
+ requests?.forEach(_readRequest);
+ notifications?.forEach(_readNotification);
+
final methodsEnum = _createMethodNamesEnum(methodNames);
if (methodsEnum != null) {
_addType(methodsEnum);
@@ -94,6 +100,32 @@
);
}
+ /// Creates a type alias for a top-level union, such as those used for
+ /// request parameters/results that don't have named types in the spec.
+ void _createUnionAlias(String name, dynamic model, String? documentation) {
+ if (model == null) {
+ return;
+ }
+
+ // We don't currently support reading the two top-level intersection types.
+ // These can just be skipped because the types we're generating here are
+ // just for convenience (to produce better names for use in handlers rather
+ // than referencing `EitherX<Y>` everywhere).
+ if (model['kind'] == 'and') {
+ return;
+ }
+
+ final type = _extractType(name, '', model);
+ if (type is UnionType) {
+ _addType(TypeAlias(
+ name: name,
+ comment: documentation,
+ baseType: type,
+ isRename: false,
+ ));
+ }
+ }
+
Constant _extractEnumValue(TypeBase parentType, dynamic model) {
final name = model['name'] as String;
return Constant(
@@ -257,6 +289,35 @@
);
}
+ void _readNotification(dynamic model) {
+ final method = model['method'] as String;
+ final namePrefix = method.split('/').map(capitalize).join();
+ final documentation = model['documentation'] as String?;
+
+ final paramsDoc = documentation != null
+ ? 'Parameters for ${_camelCase(documentation)}'
+ : null;
+
+ _createUnionAlias('${namePrefix}Params', model['params'], paramsDoc);
+ }
+
+ void _readRequest(dynamic model) {
+ final method = model['method'] as String;
+ final namePrefix = method.split('/').map(capitalize).join();
+ final documentation = model['documentation'] as String?;
+
+ final paramsDoc = documentation != null
+ ? 'Parameters for ${_camelCase(documentation)}'
+ : null;
+
+ final resultDoc = documentation != null
+ ? 'Result for ${_camelCase(documentation)}'
+ : null;
+
+ _createUnionAlias('${namePrefix}Params', model['params'], paramsDoc);
+ _createUnionAlias('${namePrefix}Result', model['result'], resultDoc);
+ }
+
LspEntity _readStructure(dynamic model) {
final name = model['name'] as String;
return Interface(
diff --git a/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart b/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
index d6d58b7..fd8131d 100644
--- a/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
@@ -6,6 +6,7 @@
as macro;
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
import 'package:analyzer/dart/analysis/context_locator.dart';
+import 'package:analyzer/dart/analysis/context_root.dart';
import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
@@ -16,6 +17,7 @@
import 'package:analyzer/src/dart/analysis/file_content_cache.dart';
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
+import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/summary2/kernel_compilation_service.dart';
import 'package:analyzer/src/summary2/macro.dart';
import 'package:analyzer/src/util/sdk.dart';
@@ -53,7 +55,15 @@
String? sdkSummaryPath,
AnalysisDriverScheduler? scheduler,
FileContentCache? fileContentCache,
- void Function(AnalysisOptionsImpl)? updateAnalysisOptions,
+ @Deprecated('Use updateAnalysisOptions2, which must be a function that '
+ 'accepts a second parameter')
+ void Function(AnalysisOptionsImpl)? updateAnalysisOptions,
+ void Function({
+ required AnalysisOptionsImpl analysisOptions,
+ required ContextRoot contextRoot,
+ required DartSdk sdk,
+ })?
+ updateAnalysisOptions2,
}) : resourceProvider =
resourceProvider ?? PhysicalResourceProvider.INSTANCE {
sdkPath ??= getSdkPath();
@@ -61,6 +71,12 @@
_throwIfAnyNotAbsoluteNormalizedPath(includedPaths);
_throwIfNotAbsoluteNormalizedPath(sdkPath);
+ if (updateAnalysisOptions != null && updateAnalysisOptions2 != null) {
+ throw ArgumentError(
+ 'Either updateAnalysisOptions or updateAnalysisOptions2 must be '
+ 'given, but not both.');
+ }
+
var contextLocator = ContextLocator(
resourceProvider: this.resourceProvider,
);
@@ -86,7 +102,9 @@
sdkPath: sdkPath,
sdkSummaryPath: sdkSummaryPath,
scheduler: scheduler,
+ // ignore: deprecated_member_use_from_same_package
updateAnalysisOptions: updateAnalysisOptions,
+ updateAnalysisOptions2: updateAnalysisOptions2,
fileContentCache: fileContentCache,
macroKernelBuilder: macroKernelBuilder,
macroExecutor: macroExecutor,
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index 220750e..2c0bac1 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -59,7 +59,14 @@
AnalysisDriverScheduler? scheduler,
String? sdkPath,
String? sdkSummaryPath,
- void Function(AnalysisOptionsImpl)? updateAnalysisOptions,
+ @Deprecated('Use updateAnalysisOptions2')
+ void Function(AnalysisOptionsImpl)? updateAnalysisOptions,
+ void Function({
+ required AnalysisOptionsImpl analysisOptions,
+ required ContextRoot contextRoot,
+ required DartSdk sdk,
+ })?
+ updateAnalysisOptions2,
FileContentCache? fileContentCache,
MacroKernelBuilder? macroKernelBuilder,
macro.MultiMacroExecutor? macroExecutor,
@@ -67,6 +74,11 @@
// TODO(scheglov) Remove this, and make `sdkPath` required.
sdkPath ??= getSdkPath();
ArgumentError.checkNotNull(sdkPath, 'sdkPath');
+ if (updateAnalysisOptions != null && updateAnalysisOptions2 != null) {
+ throw ArgumentError(
+ 'Either updateAnalysisOptions or updateAnalysisOptions2 must be '
+ 'given, but not both.');
+ }
byteStore ??= MemoryByteStore();
performanceLog ??= PerformanceLog(StringBuffer());
@@ -104,6 +116,12 @@
var options = _getAnalysisOptions(contextRoot, sourceFactory);
if (updateAnalysisOptions != null) {
updateAnalysisOptions(options);
+ } else if (updateAnalysisOptions2 != null) {
+ updateAnalysisOptions2(
+ analysisOptions: options,
+ contextRoot: contextRoot,
+ sdk: sdk,
+ );
}
final analysisContext =
diff --git a/pkg/analyzer/lib/src/lint/analysis.dart b/pkg/analyzer/lib/src/lint/analysis.dart
index e11bd6e..2827708 100644
--- a/pkg/analyzer/lib/src/lint/analysis.dart
+++ b/pkg/analyzer/lib/src/lint/analysis.dart
@@ -116,7 +116,11 @@
sdkPath: options.dartSdkPath,
includedPaths:
files.map((file) => _absoluteNormalizedPath(file.path)).toList(),
- updateAnalysisOptions: (analysisOptions) {
+ updateAnalysisOptions2: ({
+ required analysisOptions,
+ required contextRoot,
+ required sdk,
+ }) {
_updateAnalyzerOptions(analysisOptions, options);
},
);
diff --git a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
index c2aa845..6c41892 100644
--- a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
@@ -4,6 +4,7 @@
import 'package:analyzer/dart/analysis/analysis_context.dart';
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
+import 'package:analyzer/dart/analysis/context_root.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
@@ -12,6 +13,7 @@
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
+import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/summary2/kernel_compilation_service.dart';
import 'package:analyzer/src/test_utilities/mock_packages.dart';
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
@@ -234,7 +236,11 @@
/// Override this method to update [analysisOptions] for every context root,
/// the default or already updated with `analysis_options.yaml` file.
- void updateAnalysisOptions(AnalysisOptionsImpl analysisOptions) {}
+ void updateAnalysisOptions({
+ required AnalysisOptionsImpl analysisOptions,
+ required ContextRoot contextRoot,
+ required DartSdk sdk,
+ }) {}
/// Call this method if the test needs to use the empty byte store, without
/// any information cached.
@@ -267,7 +273,7 @@
sdkPath: sdkRoot.path,
sdkSummaryPath: sdkSummaryFile?.path,
librarySummaryPaths: librarySummaryFiles?.map((e) => e.path).toList(),
- updateAnalysisOptions: updateAnalysisOptions,
+ updateAnalysisOptions2: updateAnalysisOptions,
);
verifyCreatedCollection();
diff --git a/pkg/analyzer/test/src/diagnostics/illegal_language_version_override_test.dart b/pkg/analyzer/test/src/diagnostics/illegal_language_version_override_test.dart
index 3076cbb5a..994c09b 100644
--- a/pkg/analyzer/test/src/diagnostics/illegal_language_version_override_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/illegal_language_version_override_test.dart
@@ -2,8 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:analyzer/dart/analysis/context_root.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/sdk.dart';
import 'package:pub_semver/src/version_constraint.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -72,7 +74,11 @@
}
@override
- void updateAnalysisOptions(AnalysisOptionsImpl analysisOptions) {
+ void updateAnalysisOptions({
+ required AnalysisOptionsImpl analysisOptions,
+ required ContextRoot contextRoot,
+ required DartSdk sdk,
+ }) {
analysisOptions.sourceLanguageConstraint =
VersionConstraint.parse('>= 2.12.0');
}
diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart
index cb8357e..be1bca1 100644
--- a/pkg/analyzer_cli/lib/src/driver.dart
+++ b/pkg/analyzer_cli/lib/src/driver.dart
@@ -4,6 +4,7 @@
import 'dart:io' as io;
+import 'package:analyzer/dart/analysis/context_root.dart';
import 'package:analyzer/dart/sdk/build_sdk_summary.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
@@ -17,6 +18,7 @@
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/dart/analysis/results.dart';
import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/lint/linter.dart';
import 'package:analyzer/src/lint/pub.dart';
@@ -553,7 +555,7 @@
packagesFile: _commandLineOptions!.defaultPackagesPath,
resourceProvider: _resourceProvider,
sdkPath: _commandLineOptions!.dartSdkPath,
- updateAnalysisOptions: _updateAnalysisOptions,
+ updateAnalysisOptions2: _updateAnalysisOptions,
fileContentCache: _fileContentCache,
);
@@ -578,7 +580,11 @@
_analysisContext = _collection!.contextFor(path);
}
- void _updateAnalysisOptions(AnalysisOptionsImpl analysisOptions) {
+ void _updateAnalysisOptions({
+ required AnalysisOptionsImpl analysisOptions,
+ required ContextRoot contextRoot,
+ required DartSdk sdk,
+ }) {
_commandLineOptions!.updateAnalysisOptions(analysisOptions);
}
}
diff --git a/pkg/dartdev/lib/src/analysis_server.dart b/pkg/dartdev/lib/src/analysis_server.dart
index 7c823da..cc9c182 100644
--- a/pkg/dartdev/lib/src/analysis_server.dart
+++ b/pkg/dartdev/lib/src/analysis_server.dart
@@ -17,6 +17,7 @@
import 'package:path/path.dart' as path;
import 'core.dart';
+import 'experiments.dart';
import 'sdk.dart';
import 'utils.dart';
@@ -33,6 +34,7 @@
this.cacheDirectoryPath,
required this.commandName,
required this.argResults,
+ this.enabledExperiments = const [],
});
final String? cacheDirectoryPath;
@@ -41,6 +43,7 @@
final List<FileSystemEntity> analysisRoots;
final String commandName;
final ArgResults? argResults;
+ final List<String> enabledExperiments;
Process? _process;
@@ -103,6 +106,8 @@
sdkPath.path,
if (cacheDirectoryPath != null) '--cache=$cacheDirectoryPath',
if (packagesFile != null) '--packages=${packagesFile!.path}',
+ if (enabledExperiments.isNotEmpty)
+ '--$experimentFlagName=${enabledExperiments.join(',')}'
];
final process = await startDartProcess(sdk, command);
diff --git a/pkg/dartdev/lib/src/commands/analyze.dart b/pkg/dartdev/lib/src/commands/analyze.dart
index b5ff3d4..6237a7a 100644
--- a/pkg/dartdev/lib/src/commands/analyze.dart
+++ b/pkg/dartdev/lib/src/commands/analyze.dart
@@ -6,12 +6,14 @@
import 'dart:convert';
import 'dart:io' as io;
+import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:cli_util/cli_logging.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import '../analysis_server.dart';
import '../core.dart';
+import '../experiments.dart';
import '../sdk.dart';
import '../utils.dart';
@@ -80,7 +82,8 @@
valueHelp: 'path',
help: 'The path to the Dart SDK.',
hide: !verbose,
- );
+ )
+ ..addExperimentalFlags();
}
@override
@@ -110,12 +113,6 @@
final machineFormat = args['format'] == 'machine';
final jsonFormat = args['format'] == 'json';
- final targetsNames =
- targets.map((entity) => path.basename(entity.path)).join(', ');
-
- var progress =
- machineFormat ? null : log.progress('Analyzing $targetsNames');
-
io.Directory sdkPath;
if (args.wasParsed('sdk-path')) {
sdkPath = io.Directory(args['sdk-path'] as String);
@@ -137,6 +134,26 @@
sdkPath = io.Directory(sdk.sdkPath);
}
+ final experimentNames = {
+ for (var experiment in args.enabledExperiments)
+ if (experiment.startsWith('no-'))
+ experiment.substring(3)
+ else
+ experiment
+ };
+ final unknownExperiments =
+ experimentNames.difference(ExperimentStatus.knownFeatures.keys.toSet());
+ if (unknownExperiments.isNotEmpty) {
+ final unknownExperimentsText =
+ unknownExperiments.map((e) => "'$e'").join(', ');
+ usageException('Unknown experiment(s): $unknownExperimentsText');
+ }
+
+ final targetsNames =
+ targets.map((entity) => path.basename(entity.path)).join(', ');
+ final progress =
+ machineFormat ? null : log.progress('Analyzing $targetsNames');
+
final AnalysisServer server = AnalysisServer(
_packagesFile(),
sdkPath,
@@ -144,6 +161,7 @@
cacheDirectoryPath: args['cache'],
commandName: 'analyze',
argResults: args,
+ enabledExperiments: args.enabledExperiments,
);
server.onErrors.listen((FileAnalysisErrors fileErrors) {
diff --git a/pkg/dartdev/lib/src/commands/compile.dart b/pkg/dartdev/lib/src/commands/compile.dart
index 3645c43..0e0d501 100644
--- a/pkg/dartdev/lib/src/commands/compile.dart
+++ b/pkg/dartdev/lib/src/commands/compile.dart
@@ -123,8 +123,8 @@
help: defineOption.help,
abbr: defineOption.abbr,
valueHelp: defineOption.valueHelp,
- );
- addExperimentalFlags(argParser, verbose);
+ )
+ ..addExperimentalFlags(verbose: verbose);
}
@override
@@ -255,9 +255,8 @@
help: 'Pass additional options to gen_snapshot.',
hide: true,
valueHelp: 'opt1,opt2,...',
- );
-
- addExperimentalFlags(argParser, verbose);
+ )
+ ..addExperimentalFlags(verbose: verbose);
}
@override
diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart
index 39e5ea4..48c4291 100644
--- a/pkg/dartdev/lib/src/commands/run.dart
+++ b/pkg/dartdev/lib/src/commands/run.dart
@@ -179,15 +179,15 @@
hide: !verbose,
help:
'Use the Dart Development Service (DDS) for enhanced debugging '
- 'functionality. Note: Disabling DDS may break some functionality '
- 'in IDEs and other tooling.',
+ 'functionality. Note: Disabling DDS may break some '
+ 'functionality in IDEs and other tooling.',
defaultsTo: true)
..addFlag(
'debug-dds',
hide: true,
);
}
- addExperimentalFlags(argParser, verbose);
+ argParser.addExperimentalFlags(verbose: verbose);
}
@override
diff --git a/pkg/dartdev/lib/src/experiments.dart b/pkg/dartdev/lib/src/experiments.dart
index 70acd2a..392d5f3 100644
--- a/pkg/dartdev/lib/src/experiments.dart
+++ b/pkg/dartdev/lib/src/experiments.dart
@@ -9,53 +9,53 @@
const experimentFlagName = 'enable-experiment';
/// Return a list of all the non-expired Dart experiments.
-List<ExperimentalFeature> get experimentalFeatures {
- List<ExperimentalFeature> features = ExperimentStatus.knownFeatures.values
- .where((feature) => !feature.isExpired)
- .toList();
- features.sort((a, b) => a.enableString.compareTo(b.enableString));
- return features;
-}
+List<ExperimentalFeature> get experimentalFeatures =>
+ ExperimentStatus.knownFeatures.values
+ .where((feature) => !feature.isExpired)
+ .toList()
+ ..sort((a, b) => a.enableString.compareTo(b.enableString));
-void addExperimentalFlags(ArgParser argParser, bool verbose) {
- List<ExperimentalFeature> features = experimentalFeatures;
+extension ArgParserExtensions on ArgParser {
+ void addExperimentalFlags({bool verbose = false}) {
+ List<ExperimentalFeature> features = experimentalFeatures;
- Map<String, String> allowedHelp = {};
- for (ExperimentalFeature feature in features) {
- String suffix =
- feature.isEnabledByDefault ? ' (no-op - enabled by default)' : '';
- allowedHelp[feature.enableString] = '${feature.documentation}$suffix';
+ Map<String, String> allowedHelp = {};
+ for (ExperimentalFeature feature in features) {
+ String suffix =
+ feature.isEnabledByDefault ? ' (no-op - enabled by default)' : '';
+ allowedHelp[feature.enableString] = '${feature.documentation}$suffix';
+ }
+
+ addMultiOption(
+ experimentFlagName,
+ valueHelp: 'experiment',
+ allowedHelp: verbose ? allowedHelp : null,
+ help: 'Enable one or more experimental features '
+ '(see dart.dev/go/experiments).',
+ hide: !verbose,
+ );
}
-
- argParser.addMultiOption(
- experimentFlagName,
- valueHelp: 'experiment',
- allowedHelp: verbose ? allowedHelp : null,
- help: 'Enable one or more experimental features '
- '(see dart.dev/go/experiments).',
- hide: !verbose,
- );
}
-extension EnabledExperimentsArg on ArgResults {
+extension ArgResultsExtensions on ArgResults {
List<String> get enabledExperiments {
List<String> enabledExperiments = [];
// Check to see if the ArgParser which generated this result accepts
- // --enable-experiment as an option. If so, return the result if it was
+ // `--enable-experiment` as an option. If so, return the result if it was
// provided.
if (options.contains(experimentFlagName)) {
if (wasParsed(experimentFlagName)) {
- enabledExperiments = this[experimentFlagName];
+ enabledExperiments = this[experimentFlagName] as List<String>;
}
} else {
- // In the case where a command uses ArgParser.allowAnything() as its
- // parser the valid set of options for the command isn't specified and
+ // In the case where a command uses `ArgParser.allowAnything()` as its
+ // parser, the valid set of options for the command isn't specified and
// isn't enforced. Instead, we have to manually parse the arguments to
- // look for --enable-experiment=. Currently, this path is only taken for
- // the pub and test commands, as well as when we are trying to send
+ // look for `--enable-experiment=`. Currently, this path is only taken for
+ // the `pub` and `test` commands, as well as when we are trying to send
// analytics.
- final String? experiments = arguments.firstWhereOrNull(
- (e) => e.startsWith('--enable-experiment='),
+ final experiments = arguments.firstWhereOrNull(
+ (e) => e.startsWith('--$experimentFlagName='),
);
if (experiments == null) {
return [];
@@ -63,7 +63,7 @@
enabledExperiments = experiments.split('=')[1].split(',');
}
- for (ExperimentalFeature feature in experimentalFeatures) {
+ for (final feature in experimentalFeatures) {
// We allow default true flags, but complain when they are passed in.
if (feature.isEnabledByDefault &&
enabledExperiments.contains(feature.enableString)) {
diff --git a/pkg/dartdev/test/commands/analyze_test.dart b/pkg/dartdev/test/commands/analyze_test.dart
index 065d607..4da2ec8 100644
--- a/pkg/dartdev/test/commands/analyze_test.dart
+++ b/pkg/dartdev/test/commands/analyze_test.dart
@@ -421,6 +421,26 @@
expect(result.stderr, isEmpty);
});
+ test('--enable-experiment', () async {
+ p = project(mainSrc: 'final x = List.filled(growable: true, 7, "");');
+ var result = await p
+ .run(['analyze', '--enable-experiment=no-named-arguments-anywhere']);
+
+ expect(result.exitCode, 3);
+ expect(result.stdout,
+ contains('Positional arguments must occur before named arguments.'));
+ expect(result.stderr, isEmpty);
+ });
+
+ test('--enable-experiment with a bad experiment', () async {
+ p = project();
+ var result = await p.run(['analyze', '--enable-experiment=bad']);
+
+ expect(result.exitCode, 64);
+ expect(result.stdout, isEmpty);
+ expect(result.stderr, contains("Unknown experiment(s): 'bad'"));
+ });
+
test('--verbose', () async {
p = project(mainSrc: '''
int f() {
diff --git a/pkg/test_runner/lib/src/static_error.dart b/pkg/test_runner/lib/src/static_error.dart
index c24e8f8..fdabb44 100644
--- a/pkg/test_runner/lib/src/static_error.dart
+++ b/pkg/test_runner/lib/src/static_error.dart
@@ -312,7 +312,7 @@
return false;
}
- throw UnsupportedError("Unsupported source: ${source.name}");
+ throw FallThroughError();
}
String toString() {
diff --git a/runtime/include/dart_tools_api.h b/runtime/include/dart_tools_api.h
index fc7bd0e..4ccfe4f 100644
--- a/runtime/include/dart_tools_api.h
+++ b/runtime/include/dart_tools_api.h
@@ -291,8 +291,6 @@
const char* type;
const char* reason;
- // DEPRECATED: Use [isolate_group_id] instead.
- const char* isolate_id;
Dart_IsolateGroupId isolate_group_id;
Dart_GCStats new_space;
@@ -460,44 +458,6 @@
DART_EXPORT int64_t Dart_VMIsolateCountMetric(); // Counter
DART_EXPORT int64_t Dart_VMCurrentRSSMetric(); // Byte
DART_EXPORT int64_t Dart_VMPeakRSSMetric(); // Byte
-
-// DEPRECATED: Use Dart_IsolateGroupHeapOldUsedMetric instead
-DART_EXPORT int64_t
-Dart_IsolateHeapOldUsedMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapOldUsedMaxMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapOldUsedMaxMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapOldCapacityMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapOldCapacityMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapOldCapacityMaxMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapOldCapacityMaxMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapOldExternalMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapOldExternalMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapNewUsedMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapNewUsedMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapNewUsedMaxMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapNewUsedMaxMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapNewCapacityMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapNewCapacityMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapNewCapacityMaxMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapNewCapacityMaxMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapNewExternalMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapNewExternalMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapGlobalUsedMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapGlobalUsedMetric(Dart_Isolate isolate); // Byte
-// DEPRECATED: Use Dart_IsolateGroupHeapGlobalUsedMaxMetric instead.
-DART_EXPORT int64_t
-Dart_IsolateHeapGlobalUsedMaxMetric(Dart_Isolate isolate); // Byte
-
DART_EXPORT int64_t
Dart_IsolateGroupHeapOldUsedMetric(Dart_IsolateGroup group); // Byte
DART_EXPORT int64_t
diff --git a/runtime/vm/compiler/assembler/assembler_ia32_test.cc b/runtime/vm/compiler/assembler/assembler_ia32_test.cc
index 3c6797b..3c1acdd 100644
--- a/runtime/vm/compiler/assembler/assembler_ia32_test.cc
+++ b/runtime/vm/compiler/assembler/assembler_ia32_test.cc
@@ -1801,7 +1801,7 @@
"mov eax,0x4144cccd\n"
"movd xmm0,eax\n"
"shufps xmm0,xmm0 [0]\n"
- "xorps xmm0,[0x.......]\n"
+ "xorps xmm0,[0x........]\n"
"shufps xmm0,xmm0 [aa]\n"
"push eax\n"
"movss [esp],xmm0\n"
@@ -1832,7 +1832,7 @@
"mov eax,0xc174cccd\n"
"movd xmm0,eax\n"
"shufps xmm0,xmm0 [0]\n"
- "andps xmm0,[0x.......]\n"
+ "andps xmm0,[0x........]\n"
"shufps xmm0,xmm0 [aa]\n"
"push eax\n"
"movss [esp],xmm0\n"
@@ -1861,7 +1861,7 @@
"mov eax,0x4144cccd\n"
"movd xmm0,eax\n"
"shufps xmm0,xmm0 [0]\n"
- "andps xmm0,[0x.......]\n"
+ "andps xmm0,[0x........]\n"
"shufps xmm0,xmm0 [ff]\n"
"push eax\n"
"movss [esp],xmm0\n"
@@ -1961,8 +1961,8 @@
uint32_t res = reinterpret_cast<PackedLogicalOrCode>(test->entry())();
EXPECT_EQ(0xFFFFFFFF, res);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"orps xmm0,xmm1\n"
"push eax\n"
"movss [esp],xmm0\n"
@@ -1999,8 +1999,8 @@
uint32_t res = reinterpret_cast<PackedLogicalAndCode>(test->entry())();
EXPECT_EQ(static_cast<uword>(0x0000F000), res);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "andps xmm0,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "andps xmm0,[0x........]\n"
"push eax\n"
"movss [esp],xmm0\n"
"fld_s [esp]\n"
@@ -2030,8 +2030,8 @@
uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())();
EXPECT_EQ(static_cast<uword>(0x0), res);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "xorps xmm0,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "xorps xmm0,[0x........]\n"
"push eax\n"
"movss [esp],xmm0\n"
"fld_s [esp]\n"
@@ -2076,8 +2076,8 @@
float res = reinterpret_cast<PackedMoveHighLow>(test->entry())();
EXPECT_FLOAT_EQ(15.0f, res, 0.001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"movhlps xmm0,xmm1\n"
"xorps xmm1,xmm1\n"
"movaps xmm1,xmm0\n"
@@ -2128,8 +2128,8 @@
float res = reinterpret_cast<PackedMoveLowHigh>(test->entry())();
EXPECT_FLOAT_EQ(11.0f, res, 0.001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"movlhps xmm0,xmm1\n"
"xorps xmm1,xmm1\n"
"movaps xmm1,xmm0\n"
@@ -2179,8 +2179,8 @@
float res = reinterpret_cast<PackedUnpackLow>(test->entry())();
EXPECT_FLOAT_EQ(11.0f, res, 0.001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"unpcklps xmm0,xmm1\n"
"movaps xmm1,xmm0\n"
"shufps xmm0,xmm0 [55]\n"
@@ -2229,8 +2229,8 @@
float res = reinterpret_cast<PackedUnpackHigh>(test->entry())();
EXPECT_FLOAT_EQ(7.0f, res, 0.001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"unpckhps xmm0,xmm1\n"
"movaps xmm1,xmm0\n"
"shufps xmm0,xmm0 [0]\n"
@@ -2279,8 +2279,8 @@
float res = reinterpret_cast<PackedUnpackLowPair>(test->entry())();
EXPECT_FLOAT_EQ(6.0f, res, 0.001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"unpcklpd xmm0,xmm1\n"
"movaps xmm1,xmm0\n"
"shufps xmm0,xmm0 [0]\n"
@@ -2329,8 +2329,8 @@
float res = reinterpret_cast<PackedUnpackHighPair>(test->entry())();
EXPECT_FLOAT_EQ(12.0f, res, 0.001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"unpckhpd xmm0,xmm1\n"
"movaps xmm1,xmm0\n"
"shufps xmm0,xmm0 [55]\n"
@@ -2369,8 +2369,8 @@
double res = reinterpret_cast<PackedDoubleAdd>(test->entry())();
EXPECT_FLOAT_EQ(4.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"addpd xmm0,xmm1\n"
"push eax\n"
"push eax\n"
@@ -2407,8 +2407,8 @@
double res = reinterpret_cast<PackedDoubleSub>(test->entry())();
EXPECT_FLOAT_EQ(-2.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"subpd xmm0,xmm1\n"
"push eax\n"
"push eax\n"
@@ -2440,8 +2440,8 @@
double res = reinterpret_cast<PackedDoubleNegate>(test->entry())();
EXPECT_FLOAT_EQ(-1.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "xorpd xmm0,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "xorpd xmm0,[0x........]\n"
"push eax\n"
"push eax\n"
"movsd [esp],xmm0\n"
@@ -2472,8 +2472,8 @@
double res = reinterpret_cast<PackedDoubleAbsolute>(test->entry())();
EXPECT_FLOAT_EQ(1.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "andpd xmm0,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "andpd xmm0,[0x........]\n"
"push eax\n"
"push eax\n"
"movsd [esp],xmm0\n"
@@ -2509,8 +2509,8 @@
double res = reinterpret_cast<PackedDoubleMul>(test->entry())();
EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"mulpd xmm0,xmm1\n"
"push eax\n"
"push eax\n"
@@ -2547,8 +2547,8 @@
double res = reinterpret_cast<PackedDoubleDiv>(test->entry())();
EXPECT_FLOAT_EQ(3.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"divpd xmm0,xmm1\n"
"push eax\n"
"push eax\n"
@@ -2580,7 +2580,7 @@
double res = reinterpret_cast<PackedDoubleSqrt>(test->entry())();
EXPECT_FLOAT_EQ(4.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
"sqrtpd xmm0,xmm0\n"
"push eax\n"
"push eax\n"
@@ -2617,8 +2617,8 @@
double res = reinterpret_cast<PackedDoubleMin>(test->entry())();
EXPECT_FLOAT_EQ(3.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"minpd xmm0,xmm1\n"
"push eax\n"
"push eax\n"
@@ -2655,8 +2655,8 @@
double res = reinterpret_cast<PackedDoubleMax>(test->entry())();
EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
- "movups xmm1,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
+ "movups xmm1,[0x........]\n"
"maxpd xmm0,xmm1\n"
"push eax\n"
"push eax\n"
@@ -2692,7 +2692,7 @@
double res = reinterpret_cast<PackedDoubleShuffle>(test->entry())();
EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm0,[0x.......]\n"
+ "movups xmm0,[0x........]\n"
"shufpd xmm0, xmm0 [33]\n"
"shufpd xmm0, xmm0 [0]\n"
"push eax\n"
@@ -2723,7 +2723,7 @@
float res = reinterpret_cast<PackedDoubleToSingle>(test->entry())();
EXPECT_FLOAT_EQ(9.0f, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm1,[0x.......]\n"
+ "movups xmm1,[0x........]\n"
"cvtpd2ps xmm0,xmm1\n"
"push eax\n"
"movss [esp],xmm0\n"
@@ -2755,7 +2755,7 @@
double res = reinterpret_cast<PackedSingleToDouble>(test->entry())();
EXPECT_FLOAT_EQ(9.0f, res, 0.000001f);
EXPECT_DISASSEMBLY(
- "movups xmm1,[0x.......]\n"
+ "movups xmm1,[0x........]\n"
"cvtps2pd xmm0,xmm1\n"
"push eax\n"
"push eax\n"
@@ -3499,7 +3499,7 @@
double res = reinterpret_cast<GlobalAddressCode>(test->entry())();
EXPECT_FLOAT_EQ(kDoubleConst, res, 0.000001);
EXPECT_DISASSEMBLY(
- "movsd xmm0,[0x.......]\n"
+ "movsd xmm0,[0x........]\n"
"push eax\n"
"push eax\n"
"movsd [esp],xmm0\n"
@@ -3703,7 +3703,7 @@
EXPECT_FLOAT_EQ(-kFloatConst, res, 0.0001);
EXPECT_DISASSEMBLY(
"movss xmm0,[esp+0x4]\n"
- "xorps xmm0,[0x.......]\n"
+ "xorps xmm0,[0x........]\n"
"push eax\n"
"movss [esp],xmm0\n"
"fld_s [esp]\n"
@@ -3730,7 +3730,7 @@
EXPECT_FLOAT_EQ(-kDoubleConst, res, 0.0001);
EXPECT_DISASSEMBLY(
"movsd xmm0,[esp+0x4]\n"
- "xorpd xmm0,[0x.......]\n"
+ "xorpd xmm0,[0x........]\n"
"push eax\n"
"push eax\n"
"movsd [esp],xmm0\n"
@@ -4214,7 +4214,7 @@
EXPECT_DISASSEMBLY(
"movsd xmm0,[esp+0x4]\n"
"xorpd xmm1,xmm1\n"
- "xorpd xmm1,[0x.......]\n"
+ "xorpd xmm1,[0x........]\n"
"orpd xmm0,xmm1\n"
"push eax\n"
"push eax\n"
@@ -4383,7 +4383,7 @@
EXPECT_FLOAT_EQ(val, res, 0.001);
EXPECT_DISASSEMBLY(
"movsd xmm0,[esp+0x4]\n"
- "andpd xmm0,[0x.......]\n"
+ "andpd xmm0,[0x........]\n"
"push eax\n"
"push eax\n"
"movsd [esp],xmm0\n"
diff --git a/runtime/vm/compiler/assembler/disassembler_x86.cc b/runtime/vm/compiler/assembler/disassembler_x86.cc
index d99afbf..cea3446 100644
--- a/runtime/vm/compiler/assembler/disassembler_x86.cc
+++ b/runtime/vm/compiler/assembler/disassembler_x86.cc
@@ -406,7 +406,7 @@
if ((rm & 7) == 5) {
#if defined(TARGET_ARCH_IA32)
int32_t abs = LoadUnaligned(reinterpret_cast<int32_t*>(modrmp + 1));
- Print("[%#x]", abs);
+ Print("[0x%08x]", abs);
#else
int32_t disp = LoadUnaligned(reinterpret_cast<int32_t*>(modrmp + 1));
Print("[rip");
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 99be4dd..eb33322 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1234,15 +1234,7 @@
#undef VM_METRIC_API
#endif // !defined(PRODUCT)
-// TODO(dartbug.com/49211): Remove definition of deprecated functions.
#define ISOLATE_GROUP_METRIC_API(type, variable, name, unit) \
- DART_EXPORT int64_t Dart_Isolate##variable##Metric(Dart_Isolate isolate) { \
- if (isolate == nullptr) { \
- FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); \
- } \
- Isolate* iso = reinterpret_cast<Isolate*>(isolate); \
- return iso->group()->Get##variable##Metric()->Value(); \
- } \
DART_EXPORT int64_t Dart_IsolateGroup##variable##Metric( \
Dart_IsolateGroup isolate_group) { \
if (isolate_group == nullptr) { \
diff --git a/runtime/vm/heap/heap.cc b/runtime/vm/heap/heap.cc
index 0c943fa..ed01f6a 100644
--- a/runtime/vm/heap/heap.cc
+++ b/runtime/vm/heap/heap.cc
@@ -1035,14 +1035,6 @@
if (Dart::gc_event_callback() != nullptr) {
Dart_GCEvent event;
int64_t isolate_group_uptime_micros = isolate_group_->UptimeMicros();
-
- // TODO(dartbug.com/49211): Remove use of deprecated [isolate_id] field.
- auto isolate_id = Utils::CStringUniquePtr(
- OS::SCreate(nullptr, ISOLATE_GROUP_SERVICE_ID_FORMAT_STRING,
- isolate_group_->id()),
- std::free);
- event.isolate_id = isolate_id.get();
-
event.isolate_group_id = isolate_group_->id();
event.type = GCTypeToString(stats_.type_);
event.reason = GCReasonToString(stats_.reason_);
diff --git a/runtime/vm/malloc_hooks_ia32.cc b/runtime/vm/malloc_hooks_ia32.cc
index 2b7a371..0572ac0 100644
--- a/runtime/vm/malloc_hooks_ia32.cc
+++ b/runtime/vm/malloc_hooks_ia32.cc
@@ -11,9 +11,9 @@
namespace dart {
#if defined(DEBUG)
-const intptr_t kSkipCount = 6;
+const intptr_t kSkipCount = 7;
#elif !(defined(PRODUCT) || defined(DEBUG))
-const intptr_t kSkipCount = 5;
+const intptr_t kSkipCount = 6;
#endif
} // namespace dart
diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h
index 80e135e..f0fe6a8 100644
--- a/runtime/vm/symbols.h
+++ b/runtime/vm/symbols.h
@@ -211,7 +211,7 @@
V(NoSuchMethod, "noSuchMethod") \
V(NoSuchMethodError, "NoSuchMethodError") \
V(Null, "Null") \
- V(NullThrownError, "_NullThrownError") \
+ V(NullThrownError, "NullThrownError") \
V(Number, "num") \
V(Object, "Object") \
V(ObjectPool, "ObjectPool") \
diff --git a/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart b/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart
index 49c92c7..1eed466 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart
@@ -692,7 +692,7 @@
abstract class JavaScriptIndexingBehavior<E> extends JSMutableIndexable<E> {}
/// Thrown by type assertions that fail.
-class TypeErrorImpl extends Error implements TypeError {
+class TypeErrorImpl extends Error implements TypeError, CastError {
final String _message;
TypeErrorImpl(this._message);
diff --git a/sdk/lib/_internal/js_shared/lib/rti.dart b/sdk/lib/_internal/js_shared/lib/rti.dart
index ca9ab8f..b7c9881 100644
--- a/sdk/lib/_internal/js_shared/lib/rti.dart
+++ b/sdk/lib/_internal/js_shared/lib/rti.dart
@@ -1073,7 +1073,7 @@
String toString() => _message;
}
-class _TypeError extends _Error implements TypeError {
+class _TypeError extends _Error implements TypeError, CastError {
_TypeError.fromMessage(String message) : super('TypeError: $message');
factory _TypeError.forType(object, String type) {
diff --git a/sdk/lib/_internal/vm/lib/errors_patch.dart b/sdk/lib/_internal/vm/lib/errors_patch.dart
index 0c448da..05b0afa 100644
--- a/sdk/lib/_internal/vm/lib/errors_patch.dart
+++ b/sdk/lib/_internal/vm/lib/errors_patch.dart
@@ -95,7 +95,7 @@
final Object? message;
}
-class _TypeError extends Error implements TypeError {
+class _TypeError extends Error implements TypeError, CastError {
@pragma("vm:entry-point")
_TypeError._create(this._url, this._line, this._column, this._message);
@@ -112,7 +112,7 @@
final String _message;
}
-class _CastError extends Error implements TypeError {
+class _CastError extends Error implements CastError, TypeError {
@pragma("vm:entry-point")
_CastError._create(this._url, this._line, this._column, this._errorMsg);
@@ -128,12 +128,6 @@
final String _errorMsg;
}
-class _NullThrownError extends Error implements NullThrownError {
- @pragma("vm:entry-point")
- _NullThrownError();
- String toString() => "Throw of null.";
-}
-
@patch
class FallThroughError {
@patch
diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart
index 664777c..bdb1a01 100644
--- a/sdk/lib/core/errors.dart
+++ b/sdk/lib/core/errors.dart
@@ -140,14 +140,17 @@
/// Error thrown by the runtime system when a cast operation fails.
@Deprecated("Use TypeError instead")
-typedef CastError = TypeError;
+class CastError extends Error {}
/// Error thrown when attempting to throw `null`.
///
/// In null safe code, you are statically disallowed from throwing `null`,
/// so this error will go away when non-null safe code stops being supported.
-@Deprecated("Use TypeError instead")
-typedef NullThrownError = TypeError;
+class NullThrownError extends Error {
+ @pragma("vm:entry-point")
+ NullThrownError();
+ String toString() => "Throw of null.";
+}
/// Error thrown when a function is passed an unacceptable argument.
class ArgumentError extends Error {
@@ -450,12 +453,10 @@
/// Error thrown when control reaches the end of a switch case.
///
-/// The Dart specification required this error to be thrown when
+/// The Dart specification requires this error to be thrown when
/// control reaches the end of a switch case (except the last case
/// of a switch) without meeting a break or similar end of the control
/// flow.
-/// Fallthrough has been made a compile-time error in Dart 2.0.
-@Deprecated("No longer relevant in Dart 2.0")
class FallThroughError extends Error {
FallThroughError();
@pragma("vm:entry-point")
@@ -607,8 +608,8 @@
/// Error thrown when a lazily initialized variable cannot be initialized.
///
/// This is no longer used in null safe Dart code and is replaced by late
-/// variables which do not specify the error they throw when misused.
-@Deprecated("Not needed by null safe code")
+/// variables and `LateInitializationError`.
+// TODO: Deprecate?
class CyclicInitializationError extends Error {
final String? variableName;
@pragma("vm:entry-point")
diff --git a/tests/language/nnbd/syntax/null_assertion_ambiguous_test.dart b/tests/language/nnbd/syntax/null_assertion_ambiguous_test.dart
index c94b2ca..8cb6e4a 100644
--- a/tests/language/nnbd/syntax/null_assertion_ambiguous_test.dart
+++ b/tests/language/nnbd/syntax/null_assertion_ambiguous_test.dart
@@ -6,8 +6,8 @@
import 'dart:async';
class C {
- C operator *(int? other) => this;
- Object? operator -() => null;
+ C operator*(int? other) => this;
+ Object? operator-() => null;
}
// Test ambiguous cases of trailing "!" syntax. Where possible, we verify that
@@ -18,10 +18,11 @@
// `throw a!` means `throw (a!)`, not `(throw a)!`. Since it's a compile-time
// error for a thrown expression to be potentially nullable, this is
// sufficient to verify that the compiler has resolved the ambiguity
- // correctly.
+ // correctly. We check the runtime behavior by verifying that the error that
+ // is thrown is not `NullThrownError`.
Expect.throws(() {
- throw a!;
- });
+ throw a!;
+ }, (error) => error is! NullThrownError);
// `() => a!` means `() => (a!)`, not `(() => a)!`. We check the compile-time
// behavior by trying to assign to a function returning non-null. We check
@@ -30,7 +31,7 @@
var x1 = () => a!;
Object Function() x2 = x1;
Expect.throws(() {
- x1();
+ x1();
});
// `x = a!` means `x = (a!)`, not `(x = a)!`. We check the compile-time
@@ -39,11 +40,11 @@
// assignment occurs.
Object x3 = 0;
Expect.throws(() {
- x3 = a!;
+ x3 = a!;
});
var x4 = 0 as Object?;
Expect.throws(() {
- x4 = a!;
+ x4 = a!;
});
Expect.equals(x4, 0);
@@ -65,7 +66,7 @@
var x7 = new C();
i = null;
Expect.throws(() {
- x7 * i!;
+ x7 * i!;
});
// `-x!` means `-(x!)`, not `(-x)!`. We check the compile-time behavior by
diff --git a/tools/VERSION b/tools/VERSION
index 0bb2ec4..d6a09da 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 18
PATCH 0
-PRERELEASE 197
+PRERELEASE 198
PRERELEASE_PATCH 0
\ No newline at end of file