Version 2.14.0-23.0.dev
Merge commit '88a351f3d2e675e203ce6452bc39f0e06e2a037c' into 'dev'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c1377e8..dbc15dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
### Core libraries
+#### `dart:async`
+
+* The uncaught error handlers of `Zone`s are now run in the parent zone
+ of the zone where they were declared. This prevents a throwing handler
+ from causing an infinite loop by repeatedly triggering itself.
+
#### `dart:core`
* The native `DateTime` class now better handles local time around
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
index f75600c..b1cb812 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
@@ -4386,6 +4386,15 @@
tip: r"""Try removing the 'const' modifier.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Null> codeFunctionAsTypeParameter = messageFunctionAsTypeParameter;
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const MessageCode messageFunctionAsTypeParameter = const MessageCode(
+ "FunctionAsTypeParameter",
+ message:
+ r"""'Function' is a built-in identifier, could not used as a type identifier.""");
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeFunctionTypeDefaultValue = messageFunctionTypeDefaultValue;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
@@ -4407,6 +4416,30 @@
tip: r"""Try replacing the keyword with a return type.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Template<
+ Message Function(String name)> templateFunctionUsedAsDec = const Template<
+ Message Function(String name)>(
+ messageTemplate:
+ r"""'Function' is a built-in identifier, could not used as a #name name.""",
+ withArguments: _withArgumentsFunctionUsedAsDec);
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Message Function(String name)> codeFunctionUsedAsDec =
+ const Code<Message Function(String name)>(
+ "FunctionUsedAsDec",
+);
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+Message _withArgumentsFunctionUsedAsDec(String name) {
+ if (name.isEmpty) throw 'No name provided';
+ name = demangleMixinApplicationName(name);
+ return new Message(codeFunctionUsedAsDec,
+ message:
+ """'Function' is a built-in identifier, could not used as a ${name} name.""",
+ arguments: {'name': name});
+}
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeGeneratorReturnsValue = messageGeneratorReturnsValue;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
diff --git a/pkg/_fe_analyzer_shared/pubspec.yaml b/pkg/_fe_analyzer_shared/pubspec.yaml
index 221f315..b167dc0 100644
--- a/pkg/_fe_analyzer_shared/pubspec.yaml
+++ b/pkg/_fe_analyzer_shared/pubspec.yaml
@@ -1,10 +1,10 @@
name: _fe_analyzer_shared
-version: 20.0.0
+version: 21.0.0
description: Logic that is shared between the front_end and analyzer packages.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
environment:
- sdk: '>=2.12.0-0 <3.0.0'
+ sdk: '>=2.12.0 <3.0.0'
dependencies:
meta: ^1.0.2
dev_dependencies:
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/type_parameter.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/type_parameter.dart
index c818df6..5b091df 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/type_parameter.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/type_parameter.dart
@@ -12,7 +12,7 @@
void promoteNullable(T? t) {
T? s;
if (t is int) {
- s = /*analyzer.T? & int*/ /*cfe.T & int*/ t;
+ s = /*T & int*/ t;
}
}
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/why_not_promoted/data/argument_type_not_assignable_nullability_error.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/why_not_promoted/data/argument_type_not_assignable_nullability_error.dart
index 3421716..d7c28eb 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/why_not_promoted/data/argument_type_not_assignable_nullability_error.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/why_not_promoted/data/argument_type_not_assignable_nullability_error.dart
@@ -446,7 +446,7 @@
int? bad;
}
-test(C33 c) {
+explicitExtensionInvocation(C33 c) {
if (c.bad == null) return;
E33(c.
/*notPromoted(propertyNotPromoted(target: member:C33.bad, type: int?))*/ bad)
diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart
index 046c9c0..03f9e6a 100644
--- a/pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart
+++ b/pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart
@@ -38,7 +38,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('isAnalyzing');
try {
@@ -105,7 +105,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -197,7 +197,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('file');
try {
@@ -313,7 +313,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('libId');
try {
@@ -492,7 +492,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('port');
try {
@@ -590,7 +590,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -782,7 +782,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('kind');
try {
@@ -973,7 +973,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('name');
try {
@@ -1090,7 +1090,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('element');
try {
@@ -1218,7 +1218,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('packageName');
try {
@@ -1328,7 +1328,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -1419,7 +1419,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -1504,7 +1504,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -1602,7 +1602,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('insertTextFormat');
try {
diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
index 48503cb..b88f7cc 100644
--- a/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
+++ b/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
@@ -54,7 +54,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('annotationId');
try {
@@ -165,7 +165,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('label');
try {
@@ -263,7 +263,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('applied');
try {
@@ -358,7 +358,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -425,7 +425,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('from');
try {
@@ -545,7 +545,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('item');
try {
@@ -701,7 +701,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('name');
try {
@@ -873,7 +873,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -940,7 +940,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('to');
try {
@@ -1060,7 +1060,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('item');
try {
@@ -1175,7 +1175,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -1300,7 +1300,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -1393,7 +1393,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('id');
try {
@@ -1480,7 +1480,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('label');
try {
@@ -1617,7 +1617,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workspace');
try {
@@ -1777,7 +1777,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -1919,7 +1919,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('regularExpressions');
try {
@@ -2021,7 +2021,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -2231,7 +2231,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('applyEdit');
try {
@@ -2529,7 +2529,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('title');
try {
@@ -2748,7 +2748,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -2889,7 +2889,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -2965,7 +2965,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('codeActionKind');
try {
@@ -3037,7 +3037,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('properties');
try {
@@ -3129,7 +3129,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('diagnostics');
try {
@@ -3214,7 +3214,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('reason');
try {
@@ -3381,7 +3381,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('codeActionKinds');
try {
@@ -3515,7 +3515,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -3686,7 +3686,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -3793,7 +3793,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('href');
try {
@@ -3880,7 +3880,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -3961,7 +3961,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -4030,7 +4030,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('resolveProvider');
try {
@@ -4134,7 +4134,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -4247,7 +4247,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -4347,7 +4347,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('refreshSupport');
try {
@@ -4424,7 +4424,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('red');
try {
@@ -4551,7 +4551,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -4662,7 +4662,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('label');
try {
@@ -4802,7 +4802,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -4944,7 +4944,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('title');
try {
@@ -5079,7 +5079,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -5286,7 +5286,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('snippetSupport');
try {
@@ -5463,7 +5463,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -5531,7 +5531,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -5605,7 +5605,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('properties');
try {
@@ -5679,7 +5679,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -5760,7 +5760,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('triggerKind');
try {
@@ -6071,7 +6071,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('label');
try {
@@ -6420,7 +6420,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('isIncomplete');
try {
@@ -6563,7 +6563,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('triggerCharacters');
try {
@@ -6719,7 +6719,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('context');
try {
@@ -6906,7 +6906,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -7074,7 +7074,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('scopeUri');
try {
@@ -7142,7 +7142,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('items');
try {
@@ -7243,7 +7243,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('kind');
try {
@@ -7361,7 +7361,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('overwrite');
try {
@@ -7435,7 +7435,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('files');
try {
@@ -7516,7 +7516,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -7590,7 +7590,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -7693,7 +7693,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -7830,7 +7830,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -7931,7 +7931,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -8005,7 +8005,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -8107,7 +8107,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -8229,7 +8229,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -8339,7 +8339,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('kind');
try {
@@ -8457,7 +8457,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('recursive');
try {
@@ -8532,7 +8532,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('files');
try {
@@ -8692,7 +8692,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -8868,7 +8868,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('location');
try {
@@ -9023,7 +9023,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -9083,7 +9083,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
return true;
} else {
@@ -9167,7 +9167,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -9275,7 +9275,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -9338,7 +9338,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('changes');
try {
@@ -9413,7 +9413,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('watchers');
try {
@@ -9484,7 +9484,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('event');
try {
@@ -9549,7 +9549,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -9614,7 +9614,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -9687,7 +9687,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -9766,7 +9766,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -9828,7 +9828,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -9920,7 +9920,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -10039,7 +10039,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -10156,7 +10156,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('language');
try {
@@ -10240,7 +10240,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -10304,7 +10304,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -10384,7 +10384,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -10499,7 +10499,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -10590,7 +10590,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -10670,7 +10670,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -10766,7 +10766,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -10869,7 +10869,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -10997,7 +10997,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -11107,7 +11107,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -11210,7 +11210,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -11291,7 +11291,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('resolveProvider');
try {
@@ -11396,7 +11396,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -11513,7 +11513,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -11608,7 +11608,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -11685,7 +11685,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('firstTriggerCharacter');
try {
@@ -11791,7 +11791,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('ch');
try {
@@ -11945,7 +11945,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -12051,7 +12051,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -12117,7 +12117,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -12208,7 +12208,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -12342,7 +12342,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -12498,7 +12498,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('name');
try {
@@ -12726,7 +12726,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -12850,7 +12850,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -12918,7 +12918,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -13001,7 +13001,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('label');
try {
@@ -13105,7 +13105,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -13224,7 +13224,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -13370,7 +13370,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -13438,7 +13438,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('commands');
try {
@@ -13541,7 +13541,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('command');
try {
@@ -13645,7 +13645,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('commands');
try {
@@ -13805,7 +13805,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -13871,7 +13871,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -13941,7 +13941,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -14033,7 +14033,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('scheme');
try {
@@ -14141,7 +14141,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('glob');
try {
@@ -14266,7 +14266,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('ignoreCase');
try {
@@ -14329,7 +14329,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('filters');
try {
@@ -14405,7 +14405,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('oldUri');
try {
@@ -14507,7 +14507,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('globPattern');
try {
@@ -14631,7 +14631,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('startLine');
try {
@@ -14777,7 +14777,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -14894,7 +14894,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -14986,7 +14986,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -15105,7 +15105,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -15234,7 +15234,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('tabSize');
try {
@@ -15367,7 +15367,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('contents');
try {
@@ -15459,7 +15459,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -15537,7 +15537,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -15617,7 +15617,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -15725,7 +15725,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -15818,7 +15818,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -15892,7 +15892,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -15995,7 +15995,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -16133,7 +16133,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -16332,7 +16332,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('processId');
try {
@@ -16513,7 +16513,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('name');
try {
@@ -16598,7 +16598,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('capabilities');
try {
@@ -16683,7 +16683,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('name');
try {
@@ -16752,7 +16752,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
return true;
} else {
@@ -16812,7 +16812,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('newText');
try {
@@ -16999,7 +16999,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -17063,7 +17063,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -17144,7 +17144,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -17270,7 +17270,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -17374,7 +17374,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('ranges');
try {
@@ -17454,7 +17454,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -17571,7 +17571,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('originSelectionRange');
try {
@@ -17691,7 +17691,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('type');
try {
@@ -17781,7 +17781,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('message');
try {
@@ -17864,7 +17864,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('parser');
try {
@@ -17965,7 +17965,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('kind');
try {
@@ -18091,7 +18091,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('jsonrpc');
try {
@@ -18155,7 +18155,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('title');
try {
@@ -18549,7 +18549,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('scheme');
try {
@@ -18669,7 +18669,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -18763,7 +18763,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -18865,7 +18865,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -18986,7 +18986,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -19077,7 +19077,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('method');
try {
@@ -19180,7 +19180,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('version');
try {
@@ -19287,7 +19287,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('label');
try {
@@ -19442,7 +19442,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('partialResultToken');
try {
@@ -19511,7 +19511,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('line');
try {
@@ -19598,7 +19598,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -19718,7 +19718,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('token');
try {
@@ -19836,7 +19836,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('relatedInformation');
try {
@@ -19949,7 +19949,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -20038,7 +20038,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -20141,7 +20141,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('start');
try {
@@ -20225,7 +20225,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -20312,7 +20312,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -20370,7 +20370,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('includeDeclaration');
try {
@@ -20438,7 +20438,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -20546,7 +20546,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('context');
try {
@@ -20687,7 +20687,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -20780,7 +20780,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('id');
try {
@@ -20869,7 +20869,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('registrations');
try {
@@ -20949,7 +20949,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('engine');
try {
@@ -21071,7 +21071,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -21209,7 +21209,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('kind');
try {
@@ -21346,7 +21346,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('overwrite');
try {
@@ -21421,7 +21421,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('files');
try {
@@ -21500,7 +21500,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('prepareProvider');
try {
@@ -21603,7 +21603,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('newName');
try {
@@ -21740,7 +21740,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -21854,7 +21854,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('id');
try {
@@ -22009,7 +22009,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('code');
try {
@@ -22131,7 +22131,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('id');
try {
@@ -22227,7 +22227,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('includeText');
try {
@@ -22292,7 +22292,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -22374,7 +22374,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -22436,7 +22436,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -22538,7 +22538,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -22679,7 +22679,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -22836,12 +22836,12 @@
SemanticTokens({this.resultId, required this.data});
static SemanticTokens fromJson(Map<String, dynamic> json) {
final resultId = json['resultId'];
- final data = json['data']?.map((item) => item)?.cast<num>()?.toList();
+ final data = json['data']?.map((item) => item)?.cast<int>()?.toList();
return SemanticTokens(resultId: resultId, data: data);
}
/// The actual tokens.
- final List<num> data;
+ final List<int> data;
/// An optional result id. If provided and clients support delta updating the
/// client will include the result id in the next semantic token request. A
@@ -22858,7 +22858,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('resultId');
try {
@@ -22880,8 +22880,8 @@
return false;
}
if (!((obj['data'] is List &&
- (obj['data'].every((item) => item is num))))) {
- reporter.reportError('must be of type List<num>');
+ (obj['data'].every((item) => item is int))))) {
+ reporter.reportError('must be of type List<int>');
return false;
}
} finally {
@@ -22898,7 +22898,7 @@
bool operator ==(Object other) {
if (other is SemanticTokens && other.runtimeType == SemanticTokens) {
return resultId == other.resultId &&
- listEqual(data, other.data, (num a, num b) => a == b) &&
+ listEqual(data, other.data, (int a, int b) => a == b) &&
true;
}
return false;
@@ -23002,7 +23002,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -23175,7 +23175,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('delta');
try {
@@ -23229,7 +23229,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
return true;
} else {
@@ -23309,7 +23309,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -23393,7 +23393,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('resultId');
try {
@@ -23515,7 +23515,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -23629,7 +23629,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('edits');
try {
@@ -23712,7 +23712,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('start');
try {
@@ -23819,7 +23819,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('tokenTypes');
try {
@@ -23952,7 +23952,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('legend');
try {
@@ -24060,7 +24060,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('delta');
try {
@@ -24111,7 +24111,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
return true;
} else {
@@ -24192,7 +24192,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -24284,7 +24284,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('data');
try {
@@ -24391,7 +24391,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -24573,7 +24573,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -24720,7 +24720,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('refreshSupport');
try {
@@ -25328,7 +25328,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocumentSync');
try {
@@ -25863,7 +25863,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('didCreate');
try {
@@ -26011,7 +26011,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workspaceFolders');
try {
@@ -26088,7 +26088,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('value');
try {
@@ -26157,7 +26157,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('support');
try {
@@ -26257,7 +26257,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -26359,7 +26359,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('success');
try {
@@ -26429,7 +26429,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('type');
try {
@@ -26521,7 +26521,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('messageActionItem');
try {
@@ -26590,7 +26590,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('additionalPropertiesSupport');
try {
@@ -26668,7 +26668,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('type');
try {
@@ -26805,7 +26805,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('signatures');
try {
@@ -26929,7 +26929,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -27022,7 +27022,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('labelOffsetSupport');
try {
@@ -27118,7 +27118,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentationFormat');
try {
@@ -27250,7 +27250,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('triggerKind');
try {
@@ -27393,7 +27393,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('triggerCharacters');
try {
@@ -27520,7 +27520,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('context');
try {
@@ -27676,7 +27676,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -27865,7 +27865,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('label');
try {
@@ -28004,7 +28004,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('id');
try {
@@ -28122,7 +28122,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('name');
try {
@@ -28353,7 +28353,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('syncKind');
try {
@@ -28738,7 +28738,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('synchronization');
try {
@@ -29152,7 +29152,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -29249,7 +29249,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('text');
try {
@@ -29334,7 +29334,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -29438,7 +29438,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -29524,7 +29524,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -29698,7 +29698,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -29874,7 +29874,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -29989,7 +29989,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('includeText');
try {
@@ -30102,7 +30102,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -30285,7 +30285,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('openClose');
try {
@@ -30403,7 +30403,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('range');
try {
@@ -30523,7 +30523,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -30597,7 +30597,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -30700,7 +30700,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -30838,7 +30838,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentSelector');
try {
@@ -30971,7 +30971,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('id');
try {
@@ -31059,7 +31059,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('unregisterations');
try {
@@ -31138,7 +31138,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('version');
try {
@@ -31259,7 +31259,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('textDocument');
try {
@@ -31396,7 +31396,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('kind');
try {
@@ -31519,7 +31519,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('token');
try {
@@ -31589,7 +31589,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('token');
try {
@@ -31665,7 +31665,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('kind');
try {
@@ -31816,7 +31816,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -31975,7 +31975,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneToken');
try {
@@ -32076,7 +32076,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('kind');
try {
@@ -32241,7 +32241,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('changes');
try {
@@ -32407,7 +32407,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('documentChanges');
try {
@@ -32527,7 +32527,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('groupsOnLabel');
try {
@@ -32592,7 +32592,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('uri');
try {
@@ -32687,7 +32687,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('added');
try {
@@ -32802,7 +32802,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('supported');
try {
@@ -32904,7 +32904,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('dynamicRegistration');
try {
@@ -33003,7 +33003,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -33071,7 +33071,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('valueSet');
try {
@@ -33146,7 +33146,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
@@ -33238,7 +33238,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('query');
try {
@@ -33335,7 +33335,7 @@
return __result;
}
- static bool canParse(Object obj, LspJsonReporter reporter) {
+ static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, dynamic>) {
reporter.push('workDoneProgress');
try {
diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart
index 9ee8f63..9d6fe11 100644
--- a/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart
+++ b/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart
@@ -266,9 +266,9 @@
/// A helper to allow handlers to declare both a JSON validation function and
/// parse function.
class LspJsonHandler<T> {
- final bool Function(Map<String, Object>, LspJsonReporter reporter)
+ final bool Function(Map<String, Object?>?, LspJsonReporter reporter)
validateParams;
- final T Function(Map<String, Object>) convertParams;
+ final T Function(Map<String, Object?>) convertParams;
const LspJsonHandler(this.validateParams, this.convertParams);
}
diff --git a/pkg/analysis_server/lib/src/analysis_server_abstract.dart b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
index 796e555..09a9fbe 100644
--- a/pkg/analysis_server/lib/src/analysis_server_abstract.dart
+++ b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
@@ -74,7 +74,7 @@
final DartSdkManager sdkManager;
/// The [SearchEngine] for this server.
- late SearchEngine searchEngine;
+ late final SearchEngine searchEngine;
late ByteStore byteStore;
diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
index 2468770..4c5becb 100644
--- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
@@ -72,9 +72,6 @@
/// Instances of the class [EditDomainHandler] implement a [RequestHandler]
/// that handles requests in the edit domain.
class EditDomainHandler extends AbstractRequestHandler {
- /// The [SearchEngine] for this server.
- SearchEngine? searchEngine;
-
/// The workspace for rename refactorings.
RefactoringWorkspace? refactoringWorkspace;
@@ -84,9 +81,8 @@
/// Initialize a newly created handler to handle requests for the given
/// [server].
EditDomainHandler(AnalysisServer server) : super(server) {
- var search = searchEngine = server.searchEngine;
refactoringWorkspace =
- RefactoringWorkspace(server.driverMap.values, search);
+ RefactoringWorkspace(server.driverMap.values, server.searchEngine);
_newRefactoringManager();
}
@@ -815,10 +811,6 @@
}
Response _getAvailableRefactorings(Request request) {
- if (searchEngine == null) {
- var result = EditGetAvailableRefactoringsResult([]);
- return result.toResponse(request.id);
- }
_getAvailableRefactoringsImpl(request);
return Response.DELAYED_RESPONSE;
}
@@ -836,7 +828,7 @@
// add refactoring kinds
var kinds = <RefactoringKind>[];
// Check nodes.
- final searchEngine = this.searchEngine;
+ final searchEngine = server.searchEngine;
{
var resolvedUnit = await server.getResolvedUnit(file);
if (resolvedUnit != null) {
@@ -845,19 +837,15 @@
.isAvailable()) {
kinds.add(RefactoringKind.EXTRACT_LOCAL_VARIABLE);
}
- if (searchEngine != null) {
- // Try EXTRACT_METHOD.
- if (ExtractMethodRefactoring(
- searchEngine, resolvedUnit, offset, length)
- .isAvailable()) {
- kinds.add(RefactoringKind.EXTRACT_METHOD);
- }
- // Try EXTRACT_WIDGETS.
- if (ExtractWidgetRefactoring(
- searchEngine, resolvedUnit, offset, length)
- .isAvailable()) {
- kinds.add(RefactoringKind.EXTRACT_WIDGET);
- }
+ // Try EXTRACT_METHOD.
+ if (ExtractMethodRefactoring(searchEngine, resolvedUnit, offset, length)
+ .isAvailable()) {
+ kinds.add(RefactoringKind.EXTRACT_METHOD);
+ }
+ // Try EXTRACT_WIDGETS.
+ if (ExtractWidgetRefactoring(searchEngine, resolvedUnit, offset, length)
+ .isAvailable()) {
+ kinds.add(RefactoringKind.EXTRACT_WIDGET);
}
}
}
@@ -869,7 +857,7 @@
var element = server.getElementOfNode(node);
if (element != null) {
// try CONVERT_METHOD_TO_GETTER
- if (element is ExecutableElement && searchEngine != null) {
+ if (element is ExecutableElement) {
Refactoring refactoring = ConvertMethodToGetterRefactoring(
searchEngine, resolvedUnit.session, element);
var status = await refactoring.checkInitialConditions();
diff --git a/pkg/analysis_server/lib/src/lsp/client_configuration.dart b/pkg/analysis_server/lib/src/lsp/client_configuration.dart
index 26ad2d0..332330f 100644
--- a/pkg/analysis_server/lib/src/lsp/client_configuration.dart
+++ b/pkg/analysis_server/lib/src/lsp/client_configuration.dart
@@ -22,7 +22,7 @@
bool get completeFunctionCalls => _settings['completeFunctionCalls'] ?? false;
bool get enableSdkFormatter => _settings['enableSdkFormatter'] ?? true;
- int get lineLength => _settings['lineLength'];
+ int? get lineLength => _settings['lineLength'];
/// A preview flag for enabling commit characters for completions.
///
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/commands/perform_refactor.dart b/pkg/analysis_server/lib/src/lsp/handlers/commands/perform_refactor.dart
index fff5d0c..99357b7 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/commands/perform_refactor.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/commands/perform_refactor.dart
@@ -45,10 +45,10 @@
String kind = arguments[0];
String path = arguments[1];
- int docVersion = arguments[2];
+ int? docVersion = arguments[2];
int offset = arguments[3];
int length = arguments[4];
- Map<String, dynamic> options = arguments[5];
+ Map<String, dynamic>? options = arguments[5];
final result = await requireResolvedUnit(path);
return result.mapResult((result) async {
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
index c74cdb2..5bbfefc 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
@@ -178,8 +178,8 @@
/// If multiple actions have the same position, one will arbitrarily be chosen.
List<CodeAction> _dedupeActions(Iterable<CodeAction> actions, Position pos) {
final groups = groupBy(actions, (CodeAction action) => action.title);
- return groups.keys.map((title) {
- final actions = groups[title]!;
+ return groups.entries.map((entry) {
+ final actions = entry.value;
// If there's only one in the group, just return it.
if (actions.length == 1) {
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
index 751fdca..634324a 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
@@ -150,8 +150,8 @@
final key =
_createImportedSymbolKey(elementName, declaringLibraryUri);
- alreadyImportedSymbols.putIfAbsent(key, () => <String>{});
- alreadyImportedSymbols[key]!
+ alreadyImportedSymbols
+ .putIfAbsent(key, () => <String>{})
.add('${importedLibrary.librarySource.uri}');
}
}
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_exit.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_exit.dart
index a5850a5..ca28963 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_exit.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_exit.dart
@@ -9,7 +9,7 @@
import 'package:analysis_server/src/lsp/handlers/handlers.dart';
import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
-class ExitMessageHandler extends MessageHandler<void, void> {
+class ExitMessageHandler extends MessageHandler<Null, Null> {
final bool clientDidCallShutdown;
ExitMessageHandler(
@@ -21,10 +21,10 @@
Method get handlesMessage => Method.exit;
@override
- LspJsonHandler<void> get jsonHandler => NullJsonHandler;
+ LspJsonHandler<Null> get jsonHandler => NullJsonHandler;
@override
- Future<ErrorOr<void>> handle(void _, CancellationToken token) async {
+ Future<ErrorOr<Null>> handle(Null _, CancellationToken token) async {
// Set a flag that the server shutdown is being controlled here to ensure
// that the normal code that shuts down the server when the channel closes
// does not fire.
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_reject.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_reject.dart
index dbcefeb..6e82230 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_reject.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_reject.dart
@@ -9,7 +9,7 @@
/// A [MessageHandler] that rejects specific tpyes of messages with a given
/// error code/message.
-class RejectMessageHandler extends MessageHandler<Object?, void> {
+class RejectMessageHandler extends MessageHandler<Object?, Null> {
@override
final Method handlesMessage;
final ErrorCodes errorCode;
@@ -19,10 +19,10 @@
: super(server);
@override
- LspJsonHandler<Object?> get jsonHandler => NullJsonHandler;
+ LspJsonHandler<Null> get jsonHandler => NullJsonHandler;
@override
- ErrorOr<void> handle(void _, CancellationToken token) {
+ ErrorOr<Null> handle(Object? _, CancellationToken token) {
return error(errorCode, errorMessage, null);
}
}
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_shutdown.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_shutdown.dart
index b226c29..df1ff6c 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_shutdown.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_shutdown.dart
@@ -8,16 +8,16 @@
import 'package:analysis_server/src/lsp/handlers/handlers.dart';
import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
-class ShutdownMessageHandler extends MessageHandler<void, void> {
+class ShutdownMessageHandler extends MessageHandler<Null, Null> {
ShutdownMessageHandler(LspAnalysisServer server) : super(server);
@override
Method get handlesMessage => Method.shutdown;
@override
- LspJsonHandler<void> get jsonHandler => NullJsonHandler;
+ LspJsonHandler<Null> get jsonHandler => NullJsonHandler;
@override
- ErrorOr<void> handle(void _, CancellationToken token) {
+ ErrorOr<Null> handle(void _, CancellationToken token) {
// Move to the Shutting Down state so we won't process any more
// requests and the Exit notification will know it was a clean shutdown.
server.messageHandler = ShuttingDownStateMessageHandler(server);
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart b/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart
index 6e31bf2..89db7cc 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart
@@ -144,7 +144,9 @@
);
}
- final params = jsonHandler.convertParams(message.params);
+ final params = message.params != null
+ ? jsonHandler.convertParams(message.params)
+ : null as P;
return handle(params, token);
}
}
diff --git a/pkg/analysis_server/lib/src/lsp/notification_manager.dart b/pkg/analysis_server/lib/src/lsp/notification_manager.dart
index dc45460..6afaeec 100644
--- a/pkg/analysis_server/lib/src/lsp/notification_manager.dart
+++ b/pkg/analysis_server/lib/src/lsp/notification_manager.dart
@@ -30,7 +30,8 @@
String filePath, List<protocol.AnalysisError> errors) {
final diagnostics = errors
.map((error) => pluginToDiagnostic(
- // We should never errors for a file we can't get a LineInfo for
+ // We should never return errors for a file we can't get a
+ // LineInfo for
(path) => server.getLineInfo(path)!,
error,
supportedTags: server.clientCapabilities?.diagnosticTags,
diff --git a/pkg/analysis_server/lib/src/lsp/semantic_tokens/encoder.dart b/pkg/analysis_server/lib/src/lsp/semantic_tokens/encoder.dart
index f2e88e1..170ff22 100644
--- a/pkg/analysis_server/lib/src/lsp/semantic_tokens/encoder.dart
+++ b/pkg/analysis_server/lib/src/lsp/semantic_tokens/encoder.dart
@@ -109,42 +109,60 @@
/// Splits overlapping/nested tokens into descrete ranges for the "top-most"
/// token.
///
- /// Tokens must be pre-sorted by offset, with tokens having the same offset sorted
- /// with the longest first.
+ /// Tokens must be pre-sorted by offset, with tokens having the same offset
+ /// sorted with the longest first.
Iterable<SemanticTokenInfo> splitOverlappingTokens(
Iterable<SemanticTokenInfo> sortedTokens) sync* {
if (sortedTokens.isEmpty) {
return;
}
- final firstToken = sortedTokens.first;
- final stack = ListQueue<SemanticTokenInfo>()..add(firstToken);
- var pos = firstToken.offset;
+ final stack = ListQueue<SemanticTokenInfo>();
- for (final current in sortedTokens.skip(1)) {
- final last = stack.last;
- final newPos = current.offset;
- if (newPos - pos > 0) {
- // The previous region ends at either its original end or
- // the position of this next region, whichever is shorter.
- final end = math.min(last.offset + last.length, newPos);
- final length = end - pos;
- yield SemanticTokenInfo(pos, length, last.type, last.modifiers);
- pos = newPos;
+ /// Yields tokens for anything on the stack from between [fromOffset]
+ /// and [toOffset].
+ Iterable<SemanticTokenInfo> processStack(
+ int fromOffset, int toOffset) sync* {
+ // Process each item on the stack to figure out if we need to send
+ // a token for it, and pop it off the stack if we've passed the end of it.
+ while (stack.isNotEmpty) {
+ final last = stack.last;
+ final lastEnd = last.offset + last.length;
+ final end = math.min(lastEnd, toOffset);
+ final length = end - fromOffset;
+ if (length > 0) {
+ yield SemanticTokenInfo(
+ fromOffset, length, last.type, last.modifiers);
+ fromOffset = end;
+ }
+
+ // If this token is completely done with, remove it and continue
+ // through the stack. Otherwise, if this token remains then we're done
+ // for now.
+ if (lastEnd <= toOffset) {
+ stack.removeLast();
+ } else {
+ return;
+ }
}
+ }
+ var lastPos = sortedTokens.first.offset;
+ for (final current in sortedTokens) {
+ // Before processing each token, process the stack as there may be tokens
+ // on it that need filling in the gap up until this point.
+ yield* processStack(lastPos, current.offset);
+
+ // Add this token to the stack but don't process it, it will be done by
+ // the next iteration processing the stack since we don't know where this
+ // one should end until we see the start of the next one.
stack.addLast(current);
+ lastPos = current.offset;
}
// Process any remaining stack after the last region.
- while (stack.isNotEmpty) {
- final last = stack.removeLast();
- final newPos = last.offset + last.length;
- final length = newPos - pos;
- if (length > 0) {
- yield SemanticTokenInfo(pos, length, last.type, last.modifiers);
- pos = newPos;
- }
+ if (stack.isNotEmpty) {
+ yield* processStack(lastPos, stack.first.offset + stack.first.length);
}
}
}
diff --git a/pkg/analysis_server/lib/src/lsp/source_edits.dart b/pkg/analysis_server/lib/src/lsp/source_edits.dart
index cb8fe6f..39c3cf2 100644
--- a/pkg/analysis_server/lib/src/lsp/source_edits.dart
+++ b/pkg/analysis_server/lib/src/lsp/source_edits.dart
@@ -79,7 +79,7 @@
ErrorOr<List<TextEdit>?> generateEditsForFormatting(
ParsedUnitResult result,
- int lineLength, {
+ int? lineLength, {
Range? range,
}) {
final unformattedSource = result.content;
diff --git a/pkg/analysis_server/lib/src/search/search_domain.dart b/pkg/analysis_server/lib/src/search/search_domain.dart
index 0ee46f1..0ae754c 100644
--- a/pkg/analysis_server/lib/src/search/search_domain.dart
+++ b/pkg/analysis_server/lib/src/search/search_domain.dart
@@ -18,23 +18,15 @@
/// The analysis server that is using this handler to process requests.
final AnalysisServer server;
- /// The [SearchEngine] for this server.
- final SearchEngine? searchEngine;
-
/// The next search response id.
int _nextSearchId = 0;
/// Initialize a newly created handler to handle requests for the given
/// [server].
- SearchDomainHandler(this.server) : searchEngine = server.searchEngine;
+ SearchDomainHandler(this.server);
Future<void> findElementReferences(protocol.Request request) async {
- final searchEngine = this.searchEngine;
- if (searchEngine == null) {
- server.sendResponse(
- Response.unsupportedFeature(request.id, 'Search has been disabled.'));
- return;
- }
+ final searchEngine = server.searchEngine;
var params =
protocol.SearchFindElementReferencesParams.fromRequest(request);
var file = params.file;
@@ -66,12 +58,7 @@
}
Future findMemberDeclarations(protocol.Request request) async {
- final searchEngine = this.searchEngine;
- if (searchEngine == null) {
- server.sendResponse(
- Response.unsupportedFeature(request.id, 'Search has been disabled.'));
- return;
- }
+ final searchEngine = server.searchEngine;
var params =
protocol.SearchFindMemberDeclarationsParams.fromRequest(request);
await server.onAnalysisComplete;
@@ -85,12 +72,7 @@
}
Future findMemberReferences(protocol.Request request) async {
- final searchEngine = this.searchEngine;
- if (searchEngine == null) {
- server.sendResponse(
- Response.unsupportedFeature(request.id, 'Search has been disabled.'));
- return;
- }
+ final searchEngine = server.searchEngine;
var params = protocol.SearchFindMemberReferencesParams.fromRequest(request);
await server.onAnalysisComplete;
// respond
@@ -103,12 +85,7 @@
}
Future findTopLevelDeclarations(protocol.Request request) async {
- final searchEngine = this.searchEngine;
- if (searchEngine == null) {
- server.sendResponse(
- Response.unsupportedFeature(request.id, 'Search has been disabled.'));
- return;
- }
+ final searchEngine = server.searchEngine;
var params =
protocol.SearchFindTopLevelDeclarationsParams.fromRequest(request);
try {
@@ -217,12 +194,7 @@
/// Implement the `search.getTypeHierarchy` request.
Future getTypeHierarchy(protocol.Request request) async {
- final searchEngine = this.searchEngine;
- if (searchEngine == null) {
- server.sendResponse(
- Response.unsupportedFeature(request.id, 'Search has been disabled.'));
- return;
- }
+ final searchEngine = server.searchEngine;
var params = protocol.SearchGetTypeHierarchyParams.fromRequest(request);
var file = params.file;
// prepare element
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart
index 3f08723..12fe155 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart
@@ -7,7 +7,6 @@
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
/// A contributor that produces suggestions based on the members of a library
/// when the completion is in a show or hide combinator of an import or export.
@@ -22,7 +21,7 @@
// Build the list of suggestions.
var directive = node.thisOrAncestorOfType<NamespaceDirective>();
if (directive is NamespaceDirective) {
- var library = directive.uriElement as LibraryElement?;
+ var library = directive.uriElement;
if (library != null) {
var existingNames = _getCombinatorNames(directive);
for (var element in library.exportNamespace.definedNames.values) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_non_null_assertion.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_non_null_assertion.dart
index 75a93be..39814eb 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_non_null_assertion.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_non_null_assertion.dart
@@ -15,6 +15,9 @@
FixKind get fixKind => DartFixKind.REMOVE_NON_NULL_ASSERTION;
@override
+ FixKind get multiFixKind => DartFixKind.REMOVE_NON_NULL_ASSERTION_MULTI;
+
+ @override
Future<void> compute(ChangeBuilder builder) async {
final expression = node;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index 98dfce5..041bda6 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -585,6 +585,10 @@
'dart.fix.remove.nonNullAssertion',
DartFixKindPriority.DEFAULT,
"Remove the '!'");
+ static const REMOVE_NON_NULL_ASSERTION_MULTI = FixKind(
+ 'dart.fix.remove.nonNullAssertion.multi',
+ DartFixKindPriority.IN_FILE,
+ "Remove '!'s in file");
static const REMOVE_OPERATOR = FixKind('dart.fix.remove.operator',
DartFixKindPriority.DEFAULT, 'Remove the operator');
static const REMOVE_OPERATOR_MULTI = FixKind(
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 2eeadb5..3b6bbe8 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -381,8 +381,7 @@
],
StaticWarningCode.UNNECESSARY_NON_NULL_ASSERTION: [
FixInfo(
- // todo (pq): consider adding
- canBeAppliedToFile: false,
+ canBeAppliedToFile: true,
canBeBulkApplied: true,
generators: [
RemoveNonNullAssertion.newInstance,
@@ -579,7 +578,7 @@
LintNames.directives_ordering: [
FixInfo(
canBeAppliedToFile: false, // Fix will sort all directives.
- canBeBulkApplied: false,
+ canBeBulkApplied: true,
generators: [
OrganizeImports.newInstance,
],
diff --git a/pkg/analysis_server/lib/src/services/pub/pub_package_service.dart b/pkg/analysis_server/lib/src/services/pub/pub_package_service.dart
index 815711f..7d7ebbe 100644
--- a/pkg/analysis_server/lib/src/services/pub/pub_package_service.dart
+++ b/pkg/analysis_server/lib/src/services/pub/pub_package_service.dart
@@ -65,7 +65,7 @@
}
final packagesJson = json['packages'];
- if (packagesJson is! List<Object>) {
+ if (packagesJson is! List<Object?>) {
return null;
}
diff --git a/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart b/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
index 79bf48c..678166f 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
@@ -19,8 +19,8 @@
/// - OK if the name is valid;
/// - WARNING if the name is discouraged;
/// - FATAL if the name is illegal.
-RefactoringStatus validateConstructorName(String? name) {
- if (name != null && name.isEmpty) {
+RefactoringStatus validateConstructorName(String name) {
+ if (name.isEmpty) {
return RefactoringStatus();
}
return _validateLowerCamelCase(name, 'Constructor', allowBuiltIn: true);
@@ -46,8 +46,8 @@
/// - OK if the name is valid;
/// - WARNING if the name is discouraged;
/// - FATAL if the name is illegal.
-RefactoringStatus validateImportPrefixName(String? name) {
- if (name != null && name.isEmpty) {
+RefactoringStatus validateImportPrefixName(String name) {
+ if (name.isEmpty) {
return RefactoringStatus();
}
return _validateLowerCamelCase(name, 'Import prefix');
@@ -65,11 +65,7 @@
/// - OK if the name is valid;
/// - WARNING if the name is discouraged;
/// - FATAL if the name is illegal.
-RefactoringStatus validateLibraryName(String? name) {
- // null
- if (name == null) {
- return RefactoringStatus.fatal('Library name must not be null.');
- }
+RefactoringStatus validateLibraryName(String name) {
// blank
if (isBlank(name)) {
return RefactoringStatus.fatal('Library name must not be blank.');
@@ -180,14 +176,9 @@
}
/// Validates [identifier], should be lower camel case.
-RefactoringStatus _validateLowerCamelCase(String? identifier, String desc,
+RefactoringStatus _validateLowerCamelCase(String identifier, String desc,
{bool allowBuiltIn = false}) {
desc += ' name';
- // null
- if (identifier == null) {
- var message = '$desc must not be null.';
- return RefactoringStatus.fatal(message);
- }
// is not identifier
var status = _validateIdentifier(
identifier, desc, 'a lowercase letter or underscore',
@@ -213,13 +204,8 @@
}
/// Validate the given identifier, which should be upper camel case.
-RefactoringStatus _validateUpperCamelCase(String? identifier, String desc) {
+RefactoringStatus _validateUpperCamelCase(String identifier, String desc) {
desc += ' name';
- // null
- if (identifier == null) {
- var message = '$desc must not be null.';
- return RefactoringStatus.fatal(message);
- }
// is not identifier
var status = _validateIdentifier(
identifier, desc, 'an uppercase letter or underscore');
diff --git a/pkg/analysis_server/test/completion_test.dart b/pkg/analysis_server/test/completion_test.dart
index eaf324a..7d1ba63 100644
--- a/pkg/analysis_server/test/completion_test.dart
+++ b/pkg/analysis_server/test/completion_test.dart
@@ -2443,9 +2443,10 @@
++expectedFailCount;
test('$testName (expected failure $expectedFailCount)', () {
var test = CompletionTestCase();
- return Future(() => test.runTest(spec, extraFiles)).then((_) {
- fail('Test passed - expected to fail.');
- }, onError: (_) {});
+ expect(
+ () => test.runTest(spec, extraFiles),
+ throwsA(anything),
+ );
});
} else {
++expectedPassCount;
diff --git a/pkg/analysis_server/test/lsp/flutter_outline_test.dart b/pkg/analysis_server/test/lsp/flutter_outline_test.dart
index 60bb110..2059de5 100644
--- a/pkg/analysis_server/test/lsp/flutter_outline_test.dart
+++ b/pkg/analysis_server/test/lsp/flutter_outline_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -48,13 +46,13 @@
expect(outlineBeforeChange, isNotNull);
expect(outlineBeforeChange.children, hasLength(1));
- expect(outlineBeforeChange.children[0].children[0].className,
+ expect(outlineBeforeChange.children![0].children![0].className,
equals('Container'));
expect(outlineAfterChange, isNotNull);
expect(outlineAfterChange.children, hasLength(1));
expect(
- outlineAfterChange.children[0].children[0].className, equals('Icon'));
+ outlineAfterChange.children![0].children![0].className, equals('Icon'));
}
Future<void> test_initial() async {
@@ -91,7 +89,7 @@
end: Position(line: 15, character: 0))));
expect(outline.children, hasLength(1));
- final build = outline.children[0];
+ final build = outline.children![0];
expect(build.kind, equals('DART_ELEMENT'));
expect(
build.range,
@@ -103,19 +101,20 @@
equals(Range(
start: Position(line: 3, character: 0),
end: Position(line: 14, character: 6))));
- expect(build.dartElement.kind, equals('FUNCTION'));
- expect(build.dartElement.name, equals('build'));
- expect(build.dartElement.parameters, equals('(BuildContext context)'));
+ final dartElement = build.dartElement!;
+ expect(dartElement.kind, equals('FUNCTION'));
+ expect(dartElement.name, equals('build'));
+ expect(dartElement.parameters, equals('(BuildContext context)'));
expect(
- build.dartElement.range,
+ dartElement.range,
equals(Range(
start: Position(line: 3, character: 7),
end: Position(line: 3, character: 12))));
- expect(build.dartElement.returnType, equals('Widget'));
+ expect(dartElement.returnType, equals('Widget'));
expect(build.children, hasLength(1));
final icon =
- build.children[0].children[0].children[0].children[0].children[0];
+ build.children![0].children![0].children![0].children![0].children![0];
expect(icon.kind, equals('NEW_INSTANCE'));
expect(icon.className, 'Icon');
expect(
@@ -125,10 +124,11 @@
end: Position(line: 8, character: 50))));
expect(icon.codeRange, equals(icon.range));
expect(icon.attributes, hasLength(1));
- expect(icon.attributes[0].name, equals('icon'));
- expect(icon.attributes[0].label, equals('Icons.ac_unit'));
+ final attributes = icon.attributes!;
+ expect(attributes[0].name, equals('icon'));
+ expect(attributes[0].label, equals('Icons.ac_unit'));
expect(
- icon.attributes[0].valueRange,
+ attributes[0].valueRange,
equals(Range(
start: Position(line: 8, character: 36),
end: Position(line: 8, character: 49))));
diff --git a/pkg/analysis_server/test/lsp/folding_test.dart b/pkg/analysis_server/test/lsp/folding_test.dart
index bea190d..51b2eef 100644
--- a/pkg/analysis_server/test/lsp/folding_test.dart
+++ b/pkg/analysis_server/test/lsp/folding_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin;
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
@@ -271,7 +269,7 @@
expect(regions, containsAll(expectedRegions));
}
- FoldingRange _toFoldingRange(Range range, FoldingRangeKind kind) {
+ FoldingRange _toFoldingRange(Range range, FoldingRangeKind? kind) {
return FoldingRange(
startLine: range.start.line,
startCharacter: range.start.character,
diff --git a/pkg/analysis_server/test/lsp/format_test.dart b/pkg/analysis_server/test/lsp/format_test.dart
index ad5bb9c..f00bc9b 100644
--- a/pkg/analysis_server/test/lsp/format_test.dart
+++ b/pkg/analysis_server/test/lsp/format_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analysis_server/src/lsp/constants.dart';
import 'package:test/test.dart';
@@ -22,7 +20,7 @@
class FormatTest extends AbstractLspAnalysisServerTest {
Future<List<TextEdit>> expectFormattedContents(
Uri uri, String original, String expected) async {
- final formatEdits = await formatDocument(uri.toString());
+ final formatEdits = (await formatDocument(uri.toString()))!;
final formattedContents = applyTextEdits(original, formatEdits);
expect(formattedContents, equals(expected));
return formatEdits;
@@ -31,7 +29,7 @@
Future<List<TextEdit>> expectRangeFormattedContents(
Uri uri, String original, String expected) async {
final formatEdits =
- await formatRange(uri.toString(), rangeFromMarkers(original));
+ (await formatRange(uri.toString(), rangeFromMarkers(original)))!;
final formattedContents =
applyTextEdits(withoutMarkers(original), formatEdits);
expect(formattedContents, equals(expected));
@@ -96,7 +94,7 @@
{},
);
- Registration registration(Method method) =>
+ Registration? registration(Method method) =>
registrationFor(registrations, method);
// By default, the formatters should have been registered.
@@ -139,7 +137,7 @@
{},
);
- Registration registration(Method method) =>
+ Registration? registration(Method method) =>
registrationFor(registrations, method);
// By default, the formatters should have been registered.
@@ -181,9 +179,8 @@
await initialize();
await openFile(mainFileUri, withoutMarkers(contents));
- final formatEdits = await formatOnType(
- mainFileUri.toString(), positionFromMarker(contents), '}');
- expect(formatEdits, isNotNull);
+ final formatEdits = (await formatOnType(
+ mainFileUri.toString(), positionFromMarker(contents), '}'))!;
final formattedContents =
applyTextEdits(withoutMarkers(contents), formatEdits);
expect(formattedContents, equals(expected));
diff --git a/pkg/analysis_server/test/lsp/hover_test.dart b/pkg/analysis_server/test/lsp/hover_test.dart
index 0be55c5..77bb9b5 100644
--- a/pkg/analysis_server/test/lsp/hover_test.dart
+++ b/pkg/analysis_server/test/lsp/hover_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analysis_server/src/lsp/constants.dart';
import 'package:test/test.dart';
@@ -37,7 +35,7 @@
await initialAnalysis;
var hover = await getHover(mainFileUri, positionFromMarker(content));
expect(hover, isNotNull);
- expect(hover.range, equals(rangeFromMarkers(content)));
+ expect(hover!.range, equals(rangeFromMarkers(content)));
expect(_getStringContents(hover), endsWith('This is shared content.'));
}
@@ -89,7 +87,7 @@
await openFile(mainFileUri, withoutMarkers(content));
final hover = await getHover(mainFileUri, positionFromMarker(content));
expect(hover, isNotNull);
- expect(hover.range, equals(rangeFromMarkers(content)));
+ expect(hover!.range, equals(rangeFromMarkers(content)));
expect(hover.contents, isNotNull);
final markup = _getMarkupContents(hover);
expect(markup.kind, equals(MarkupKind.Markdown));
@@ -108,7 +106,7 @@
await openFile(mainFileUri, withoutMarkers(content));
final hover = await getHover(mainFileUri, positionFromMarker(content));
expect(hover, isNotNull);
- expect(hover.range, equals(rangeFromMarkers(content)));
+ expect(hover!.range, equals(rangeFromMarkers(content)));
expect(hover.contents, isNotNull);
final markup = _getMarkupContents(hover);
expect(markup.kind, equals(MarkupKind.Markdown));
@@ -151,7 +149,7 @@
await openFile(mainFileUri, withoutMarkers(content));
final hover = await getHover(mainFileUri, positionFromMarker(content));
expect(hover, isNotNull);
- expect(hover.range, equals(rangeFromMarkers(content)));
+ expect(hover!.range, equals(rangeFromMarkers(content)));
expect(hover.contents, isNotNull);
// Ensure we got PlainText back as the type, even though we're sending the
// same markdown content.
@@ -172,7 +170,7 @@
await openFile(mainFileUri, withoutMarkers(content));
final hover = await getHover(mainFileUri, positionFromMarker(content));
expect(hover, isNotNull);
- expect(hover.range, equals(rangeFromMarkers(content)));
+ expect(hover!.range, equals(rangeFromMarkers(content)));
}
Future<void> test_string_noDocComment() async {
@@ -192,7 +190,7 @@
await openFile(mainFileUri, withoutMarkers(content));
final hover = await getHover(mainFileUri, positionFromMarker(content));
expect(hover, isNotNull);
- expect(hover.range, equals(rangeFromMarkers(content)));
+ expect(hover!.range, equals(rangeFromMarkers(content)));
expect(hover.contents, isNotNull);
expect(_getStringContents(hover), equals(expectedHoverContent));
}
@@ -210,12 +208,14 @@
await initialize();
await openFile(mainFileUri, withoutMarkers(original));
var hover = await getHover(mainFileUri, positionFromMarker(original));
- var contents = _getStringContents(hover);
+ expect(hover, isNotNull);
+ var contents = _getStringContents(hover!);
expect(contents, contains('Original'));
await replaceFile(222, mainFileUri, withoutMarkers(updated));
hover = await getHover(mainFileUri, positionFromMarker(updated));
- contents = _getStringContents(hover);
+ expect(hover, isNotNull);
+ contents = _getStringContents(hover!);
expect(contents, contains('Updated'));
}
@@ -229,7 +229,7 @@
await openFile(mainFileUri, withoutMarkers(content));
final hover = await getHover(mainFileUri, positionFromMarker(content));
expect(hover, isNotNull);
- expect(hover.range, equals(rangeFromMarkers(content)));
+ expect(hover!.range, equals(rangeFromMarkers(content)));
expect(hover.contents, isNotNull);
final contents = _getStringContents(hover);
expect(contents, contains('This is a string.'));
@@ -245,7 +245,7 @@
await initialize();
final hover = await getHover(mainFileUri, positionFromMarker(content));
expect(hover, isNotNull);
- expect(hover.range, equals(rangeFromMarkers(content)));
+ expect(hover!.range, equals(rangeFromMarkers(content)));
expect(hover.contents, isNotNull);
final markup = _getStringContents(hover);
expect(markup, contains('This is a string.'));
diff --git a/pkg/analysis_server/test/lsp/implementation_test.dart b/pkg/analysis_server/test/lsp/implementation_test.dart
index 63cc7f8..195b46b 100644
--- a/pkg/analysis_server/test/lsp/implementation_test.dart
+++ b/pkg/analysis_server/test/lsp/implementation_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/lsp/initialization_test.dart b/pkg/analysis_server/test/lsp/initialization_test.dart
index 93ecc62..fb9fcdf 100644
--- a/pkg/analysis_server/test/lsp/initialization_test.dart
+++ b/pkg/analysis_server/test/lsp/initialization_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analysis_server/lsp_protocol/protocol_special.dart';
import 'package:analysis_server/src/lsp/constants.dart';
@@ -54,7 +52,7 @@
final dartOptions = CompletionRegistrationOptions.fromJson(
dartRegistration.registerOptions);
expect(dartOptions.documentSelector, hasLength(1));
- expect(dartOptions.documentSelector[0].language, dartLanguageId);
+ expect(dartOptions.documentSelector![0].language, dartLanguageId);
expect(dartOptions.triggerCharacters, isNotEmpty);
// Check non-Dart registration.
@@ -63,7 +61,7 @@
r != dartRegistration);
final nonDartOptions = CompletionRegistrationOptions.fromJson(
nonDartRegistration.registerOptions);
- final otherLanguages = nonDartOptions.documentSelector
+ final otherLanguages = nonDartOptions.documentSelector!
.map((selector) => selector.language)
.toList();
expect(otherLanguages, isNot(contains('dart')));
@@ -91,8 +89,8 @@
// static registrations for them.
// https://github.com/dart-lang/sdk/issues/38490
final initResult = InitializeResult.fromJson(initResponse.result);
- expect(initResult.serverInfo.name, 'Dart SDK LSP Analysis Server');
- expect(initResult.serverInfo.version, isNotNull);
+ expect(initResult.serverInfo!.name, 'Dart SDK LSP Analysis Server');
+ expect(initResult.serverInfo!.version, isNotNull);
expect(initResult.capabilities, isNotNull);
expect(initResult.capabilities.textDocumentSync, isNull);
@@ -113,16 +111,17 @@
// The hover capability should only specific Dart.
expect(hover, isNotNull);
expect(hover.documentSelector, hasLength(1));
- expect(hover.documentSelector.single.language, equals('dart'));
+ expect(hover.documentSelector!.single.language, equals('dart'));
// didChange should also include pubspec + analysis_options.
expect(change, isNotNull);
expect(change.documentSelector, hasLength(greaterThanOrEqualTo(3)));
- expect(change.documentSelector.any((ds) => ds.language == 'dart'), isTrue);
- expect(change.documentSelector.any((ds) => ds.pattern == '**/pubspec.yaml'),
+ expect(change.documentSelector!.any((ds) => ds.language == 'dart'), isTrue);
+ expect(
+ change.documentSelector!.any((ds) => ds.pattern == '**/pubspec.yaml'),
isTrue);
expect(
- change.documentSelector
+ change.documentSelector!
.any((ds) => ds.pattern == '**/analysis_options.yaml'),
isTrue);
@@ -149,7 +148,7 @@
// When dynamic registration is not supported, we will always statically
// request text document open/close and incremental updates.
expect(initResult.capabilities.textDocumentSync, isNotNull);
- initResult.capabilities.textDocumentSync.map(
+ initResult.capabilities.textDocumentSync!.map(
(options) {
expect(options.openClose, isTrue);
expect(options.change, equals(TextDocumentSyncKind.Incremental));
@@ -169,7 +168,7 @@
expect(initResult.capabilities.codeActionProvider, isNotNull);
expect(initResult.capabilities.renameProvider, isNotNull);
expect(initResult.capabilities.foldingRangeProvider, isNotNull);
- expect(initResult.capabilities.workspace.fileOperations.willRename,
+ expect(initResult.capabilities.workspace!.fileOperations!.willRename,
equals(ServerCapabilitiesComputer.fileOperationRegistrationOptions));
expect(initResult.capabilities.semanticTokensProvider, isNotNull);
@@ -226,7 +225,7 @@
expect(initResult.capabilities.codeActionProvider, isNull);
expect(initResult.capabilities.renameProvider, isNull);
expect(initResult.capabilities.foldingRangeProvider, isNull);
- expect(initResult.capabilities.workspace.fileOperations, isNull);
+ expect(initResult.capabilities.workspace!.fileOperations, isNull);
expect(initResult.capabilities.semanticTokensProvider, isNull);
// Ensure all expected dynamic registrations.
@@ -465,7 +464,7 @@
expect(result.capabilities, isNotNull);
// Check some basic capabilities that are unlikely to change.
expect(result.capabilities.textDocumentSync, isNotNull);
- result.capabilities.textDocumentSync.map(
+ result.capabilities.textDocumentSync!.map(
(options) {
// We'll always request open/closed notifications and incremental updates.
expect(options.openClose, isTrue);
@@ -487,7 +486,7 @@
final response = await sendRequestToServer(request);
expect(response.id, equals(request.id));
expect(response.error, isNotNull);
- expect(response.error.code, equals(ErrorCodes.InvalidParams));
+ expect(response.error!.code, equals(ErrorCodes.InvalidParams));
expect(response.result, isNull);
}
@@ -497,8 +496,8 @@
expect(response, isNotNull);
expect(response.result, isNull);
expect(response.error, isNotNull);
- expect(
- response.error.code, equals(ServerErrorCodes.ServerAlreadyInitialized));
+ expect(response.error!.code,
+ equals(ServerErrorCodes.ServerAlreadyInitialized));
}
Future<void> test_initialize_rootPath() async {
@@ -643,7 +642,9 @@
// Wait up to 1sec to ensure no error/log notifications were sent back.
var didTimeout = false;
- final notificationFromServer = await nextNotification.timeout(
+ final notificationFromServer = await nextNotification
+ .then<NotificationMessage?>((notification) => notification)
+ .timeout(
const Duration(seconds: 1),
onTimeout: () {
didTimeout = true;
@@ -661,6 +662,6 @@
expect(response.id, equals(request.id));
expect(response.result, isNull);
expect(response.error, isNotNull);
- expect(response.error.code, ErrorCodes.ServerNotInitialized);
+ expect(response.error!.code, ErrorCodes.ServerNotInitialized);
}
}
diff --git a/pkg/analysis_server/test/lsp/mapping_test.dart b/pkg/analysis_server/test/lsp/mapping_test.dart
index 6c89580..ce08941 100644
--- a/pkg/analysis_server/test/lsp/mapping_test.dart
+++ b/pkg/analysis_server/test/lsp/mapping_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart' as lsp;
import 'package:analysis_server/src/lsp/mapping.dart' as lsp;
import 'package:analysis_server/src/protocol_server.dart' as server;
diff --git a/pkg/analysis_server/test/lsp/outline_test.dart b/pkg/analysis_server/test/lsp/outline_test.dart
index 1c04b0c..4310ec9 100644
--- a/pkg/analysis_server/test/lsp/outline_test.dart
+++ b/pkg/analysis_server/test/lsp/outline_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -33,11 +31,11 @@
expect(outlineBeforeChange, isNotNull);
expect(outlineBeforeChange.children, hasLength(1));
- expect(outlineBeforeChange.children[0].element.name, equals('A'));
+ expect(outlineBeforeChange.children![0].element.name, equals('A'));
expect(outlineAfterChange, isNotNull);
expect(outlineAfterChange.children, hasLength(1));
- expect(outlineAfterChange.children[0].element.name, equals('B'));
+ expect(outlineAfterChange.children![0].element.name, equals('B'));
}
Future<void> test_extensions() async {
@@ -53,8 +51,8 @@
expect(outline, isNotNull);
expect(outline.children, hasLength(2));
- expect(outline.children[0].element.name, equals('StringExtensions'));
- expect(outline.children[1].element.name, equals('<unnamed extension>'));
+ expect(outline.children![0].element.name, equals('StringExtensions'));
+ expect(outline.children![1].element.name, equals('<unnamed extension>'));
}
Future<void> test_initial() async {
@@ -88,7 +86,7 @@
expect(outline.children, hasLength(1));
// class A
- final classA = outline.children[0];
+ final classA = outline.children![0];
expect(classA.element.name, equals('A'));
expect(classA.element.kind, equals('CLASS'));
expect(
@@ -109,7 +107,7 @@
expect(classA.children, hasLength(2));
// b()
- final methodB = classA.children[0];
+ final methodB = classA.children![0];
expect(methodB.element.name, equals('b'));
expect(methodB.element.kind, equals('METHOD'));
expect(
@@ -130,7 +128,7 @@
expect(methodB.children, hasLength(1));
// c()
- final methodC = methodB.children[0];
+ final methodC = methodB.children![0];
expect(methodC.element.name, equals('c'));
expect(methodC.element.kind, equals('FUNCTION'));
expect(
@@ -154,7 +152,7 @@
expect(methodC.children, isNull);
// num get d
- final fieldD = classA.children[1];
+ final fieldD = classA.children![1];
expect(fieldD.element.name, equals('d'));
expect(fieldD.element.kind, equals('GETTER'));
expect(
diff --git a/pkg/analysis_server/test/lsp/priority_files_test.dart b/pkg/analysis_server/test/lsp/priority_files_test.dart
index 8d5107c..028f903 100644
--- a/pkg/analysis_server/test/lsp/priority_files_test.dart
+++ b/pkg/analysis_server/test/lsp/priority_files_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/lsp/pub_package_service_test.dart b/pkg/analysis_server/test/lsp/pub_package_service_test.dart
index f40f50a..b00f285 100644
--- a/pkg/analysis_server/test/lsp/pub_package_service_test.dart
+++ b/pkg/analysis_server/test/lsp/pub_package_service_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/src/services/pub/pub_api.dart';
import 'package:analysis_server/src/services/pub/pub_package_service.dart';
import 'package:analyzer/instrumentation/service.dart';
@@ -25,12 +23,10 @@
class PubApiTest {
static const pubDefaultUrl = 'https://pub.dartlang.org';
- Uri lastCalledUrl;
- MockHttpClient httpClient;
+ Uri? lastCalledUrl;
+ late MockHttpClient httpClient;
- PubApi api;
-
- Future<void> check_pubHostedUrl(String envValue, String expectedBase) async {
+ Future<void> check_pubHostedUrl(String? envValue, String expectedBase) async {
final api =
PubApi(InstrumentationService.NULL_SERVICE, httpClient, envValue);
await api.allPackages();
@@ -303,7 +299,7 @@
await openFile(pubspecFileUri, '');
await pumpEventQueue();
- final cache = server.pubPackageService.readDiskCache();
+ final cache = server.pubPackageService.readDiskCache()!;
final packages = cache.packages.values.toList();
expect(packages.map((p) => p.packageName), equals(['one', 'two', 'three']));
diff --git a/pkg/analysis_server/test/lsp/reanalyze_test.dart b/pkg/analysis_server/test/lsp/reanalyze_test.dart
index 150c8a0..69afce8 100644
--- a/pkg/analysis_server/test/lsp/reanalyze_test.dart
+++ b/pkg/analysis_server/test/lsp/reanalyze_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/lsp/references_test.dart b/pkg/analysis_server/test/lsp/references_test.dart
index 9af7eef..350de59 100644
--- a/pkg/analysis_server/test/lsp/references_test.dart
+++ b/pkg/analysis_server/test/lsp/references_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/lsp/rename_test.dart b/pkg/analysis_server/test/lsp/rename_test.dart
index a65a4ef..0559614 100644
--- a/pkg/analysis_server/test/lsp/rename_test.dart
+++ b/pkg/analysis_server/test/lsp/rename_test.dart
@@ -2,11 +2,8 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analysis_server/src/lsp/constants.dart';
-import 'package:meta/meta.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -93,8 +90,8 @@
expect(response.id, equals(request.id));
expect(response.result, isNull);
expect(response.error, isNotNull);
- expect(response.error.code, ServerErrorCodes.RenameNotValid);
- expect(response.error.message, contains('is defined in the SDK'));
+ expect(response.error!.code, ServerErrorCodes.RenameNotValid);
+ expect(response.error!.message, contains('is defined in the SDK'));
}
Future<void> test_prepare_variable() async {
@@ -174,8 +171,9 @@
action: UserPromptActions.renameAnyway,
);
- if (response.error != null) {
- throw response.error;
+ final error = response.error;
+ if (error != null) {
+ throw error;
}
final result = WorkspaceEdit.fromJson(response.result);
@@ -186,7 +184,7 @@
};
applyDocumentChanges(
contents,
- result.documentChanges,
+ result.documentChanges!,
);
expect(contents[mainFilePath], equals(expectedContent));
}
@@ -284,12 +282,12 @@
await openFile(referencedFileUri, withoutMarkers(referencedContent),
version: referencedVersion);
- final result = await rename(
+ final result = (await rename(
mainFileUri,
mainVersion,
positionFromMarker(mainContent),
'MyNewClass',
- );
+ ))!;
// Ensure applying the changes will give us the expected content.
final contents = {
@@ -302,7 +300,7 @@
};
applyDocumentChanges(
contents,
- result.documentChanges,
+ result.documentChanges!,
expectedVersions: documentVersions,
);
expect(contents[mainFilePath], equals(expectedMainContent));
@@ -377,8 +375,8 @@
expect(response.id, equals(request.id));
expect(response.result, isNull);
expect(response.error, isNotNull);
- expect(response.error.code, ServerErrorCodes.RenameNotValid);
- expect(response.error.message, contains('is defined in the SDK'));
+ expect(response.error!.code, ServerErrorCodes.RenameNotValid);
+ expect(response.error!.message, contains('is defined in the SDK'));
}
Future<void> test_rename_usingLegacyChangeInterface() async {
@@ -396,18 +394,18 @@
await initialize();
await openFile(mainFileUri, withoutMarkers(content), version: 222);
- final result = await rename(
+ final result = (await rename(
mainFileUri,
222,
positionFromMarker(content),
'MyNewClass',
- );
+ ))!;
// Ensure applying the changes will give us the expected content.
final contents = {
mainFilePath: withoutMarkers(content),
};
- applyChanges(contents, result.changes);
+ applyChanges(contents, result.changes!);
expect(contents[mainFilePath], equals(expectedContent));
}
@@ -444,7 +442,8 @@
sendRenameVersion: false);
}
- Future<void> _test_prepare(String content, String expectedPlaceholder) async {
+ Future<void> _test_prepare(
+ String content, String? expectedPlaceholder) async {
await initialize();
await openFile(mainFileUri, withoutMarkers(content));
@@ -454,7 +453,7 @@
if (expectedPlaceholder == null) {
expect(result, isNull);
} else {
- expect(result.range, equals(rangeFromMarkers(content)));
+ expect(result!.range, equals(rangeFromMarkers(content)));
expect(result.placeholder, equals(expectedPlaceholder));
}
}
@@ -481,7 +480,7 @@
expect(result.result, isNull);
expect(result.error, isNotNull);
- return result.error;
+ return result.error!;
}
/// Tests a rename that is expected to cause an error, which will trigger
@@ -490,9 +489,9 @@
Future<ResponseMessage> _test_rename_prompt(
String content,
String newName, {
- @required String expectedMessage,
- Future<void> Function() beforeResponding,
- @required String action,
+ required String expectedMessage,
+ Future<void> Function()? beforeResponding,
+ required String action,
int openFileVersion = 222,
int renameRequestFileVersion = 222,
}) async {
@@ -519,9 +518,9 @@
expect(params.type, equals(MessageType.Warning));
expect(params.message, equals(expectedMessage));
expect(params.actions, hasLength(2));
- expect(params.actions[0],
+ expect(params.actions![0],
equals(MessageActionItem(title: UserPromptActions.renameAnyway)));
- expect(params.actions[1],
+ expect(params.actions![1],
equals(MessageActionItem(title: UserPromptActions.cancel)));
// Allow the test to run some code before we send the response.
@@ -536,8 +535,7 @@
Future<void> _test_rename_withDocumentChanges(
String content,
String newName,
- String expectedContent, {
- sendDocumentVersion = true,
+ String? expectedContent, {
sendRenameVersion = true,
}) async {
// The specific number doesn't matter here, it's just a placeholder to confirm
@@ -548,7 +546,7 @@
withDocumentChangesSupport(emptyWorkspaceClientCapabilities),
);
await openFile(mainFileUri, withoutMarkers(content),
- version: sendDocumentVersion ? documentVersion : null);
+ version: documentVersion);
final result = await rename(
mainFileUri,
@@ -568,7 +566,7 @@
};
applyDocumentChanges(
contents,
- result.documentChanges,
+ result!.documentChanges!,
expectedVersions: documentVersions,
);
expect(contents[mainFilePath], equals(expectedContent));
diff --git a/pkg/analysis_server/test/lsp/semantic_tokens_test.dart b/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
index b97795e..6fcc641 100644
--- a/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
+++ b/pkg/analysis_server/test/lsp/semantic_tokens_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analysis_server/src/lsp/constants.dart';
import 'package:analysis_server/src/lsp/semantic_tokens/legend.dart';
@@ -273,6 +271,51 @@
expect(decoded, equals(expected));
}
+ Future<void> test_dartdoc() async {
+ final content = '''
+ /// before [aaa] after
+ class MyClass {
+ String aaa;
+ }
+
+ /// before [bbb] after
+ int double(int bbb) => bbb * 2;
+ ''';
+
+ final expected = [
+ _Token('/// before [', SemanticTokenTypes.comment,
+ [SemanticTokenModifiers.documentation]),
+ _Token('aaa', SemanticTokenTypes.property),
+ _Token('] after', SemanticTokenTypes.comment,
+ [SemanticTokenModifiers.documentation]),
+ _Token('class', SemanticTokenTypes.keyword),
+ _Token('MyClass', SemanticTokenTypes.class_),
+ _Token('String', SemanticTokenTypes.class_),
+ _Token('aaa', SemanticTokenTypes.variable,
+ [SemanticTokenModifiers.declaration]),
+ _Token('/// before [', SemanticTokenTypes.comment,
+ [SemanticTokenModifiers.documentation]),
+ _Token('bbb', SemanticTokenTypes.parameter),
+ _Token('] after', SemanticTokenTypes.comment,
+ [SemanticTokenModifiers.documentation]),
+ _Token('int', SemanticTokenTypes.class_),
+ _Token('double', SemanticTokenTypes.function,
+ [SemanticTokenModifiers.declaration, SemanticTokenModifiers.static]),
+ _Token('int', SemanticTokenTypes.class_),
+ _Token('bbb', SemanticTokenTypes.parameter,
+ [SemanticTokenModifiers.declaration]),
+ _Token('bbb', SemanticTokenTypes.parameter),
+ _Token('2', SemanticTokenTypes.number)
+ ];
+
+ await initialize();
+ await openFile(mainFileUri, withoutMarkers(content));
+
+ final tokens = await getSemanticTokens(mainFileUri);
+ final decoded = decodeSemanticTokens(content, tokens);
+ expect(decoded, equals(expected));
+ }
+
Future<void> test_directives() async {
final content = '''
import 'package:flutter/material.dart';
@@ -347,8 +390,8 @@
}
''';
- // Expect toe correct tokens for the valid code before/after but don't
- // check the the tokens for the invalid code as thre are no concrete
+ // Expect the correct tokens for the valid code before/after but don't
+ // check the the tokens for the invalid code as there are no concrete
// expectations for them.
final expected1 = [
_Token('/// class docs', SemanticTokenTypes.comment,
@@ -837,10 +880,17 @@
o.type == type &&
listEqual(
// Treat nulls the same as empty lists for convenience when comparing.
- o.modifiers ?? <SemanticTokenModifiers>[],
- modifiers ?? <SemanticTokenModifiers>[],
+ o.modifiers,
+ modifiers,
(SemanticTokenModifiers a, SemanticTokenModifiers b) => a == b);
+ /// Outputs a text representation of the token in the form of constructor
+ /// args for easy copy/pasting into tests to update expectations.
@override
- String toString() => '$content (${[type, ...?modifiers]})';
+ String toString() {
+ final modifiersString = modifiers.isEmpty
+ ? ''
+ : ', [${modifiers.map((m) => 'SemanticTokenModifiers.$m').join(', ')}]';
+ return "('$content', SemanticTokenTypes.$type$modifiersString)";
+ }
}
diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart
index 8091172..986d755 100644
--- a/pkg/analysis_server/test/lsp/server_abstract.dart
+++ b/pkg/analysis_server/test/lsp/server_abstract.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'dart:async';
import 'package:analysis_server/lsp_protocol/protocol_custom_generated.dart';
@@ -26,7 +24,7 @@
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
import 'package:analyzer_plugin/protocol/protocol.dart' as plugin;
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart' as plugin;
-import 'package:meta/meta.dart';
+import 'package:collection/collection.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart' hide expect;
import 'package:test/test.dart' as test show expect;
@@ -51,10 +49,10 @@
ClientCapabilitiesHelperMixin,
LspAnalysisServerTestMixin,
ConfigurationFilesMixin {
- MockLspServerChannel channel;
- TestPluginManager pluginManager;
- LspAnalysisServer server;
- MockHttpClient httpClient;
+ late MockLspServerChannel channel;
+ late TestPluginManager pluginManager;
+ late LspAnalysisServer server;
+ late MockHttpClient httpClient;
/// The number of context builds that had already occurred the last time
/// resetContextBuildCounter() was called.
@@ -66,11 +64,12 @@
Stream<Message> get serverToClient => channel.serverToClient;
DiscoveredPluginInfo configureTestPlugin({
- plugin.ResponseResult respondWith,
- plugin.Notification notification,
+ plugin.ResponseResult? respondWith,
+ plugin.Notification? notification,
Duration respondAfter = Duration.zero,
}) {
- final info = DiscoveredPluginInfo('a', 'b', 'c', null, null);
+ final info = DiscoveredPluginInfo('a', 'b', 'c', server.notificationManager,
+ server.instrumentationService);
pluginManager.plugins.add(info);
if (respondWith != null) {
@@ -102,20 +101,21 @@
Future<T> expectSuccessfulResponseTo<T, R>(
RequestMessage request, T Function(R) fromJson) async {
final resp = await sendRequestToServer(request);
- if (resp.error != null) {
- throw resp.error;
+ final error = resp.error;
+ if (error != null) {
+ throw error;
} else {
- return resp.result == null ? null : fromJson(resp.result);
+ // resp.result should only be null when error != null if T allows null.
+ return resp.result == null ? null as T : fromJson(resp.result);
}
}
/// Finds the registration for a given LSP method.
- Registration registrationFor(
+ Registration? registrationFor(
List<Registration> registrations,
Method method,
) {
- return registrations.singleWhere((r) => r.method == method.toJson(),
- orElse: () => null);
+ return registrations.singleWhereOrNull((r) => r.method == method.toJson());
}
/// Finds the registration for a given LSP method with Dart in its
@@ -124,13 +124,12 @@
List<Registration> registrations,
Method method,
) {
- return registrations.singleWhere(
- (r) =>
- r.method == method.toJson() &&
- TextDocumentRegistrationOptions.fromJson(r.registerOptions)
+ return registrations.singleWhere((r) =>
+ r.method == method.toJson() &&
+ (TextDocumentRegistrationOptions.fromJson(r.registerOptions)
.documentSelector
- .any((selector) => selector.language == dartLanguageId),
- orElse: () => null);
+ ?.any((selector) => selector.language == dartLanguageId) ??
+ false));
}
void resetContextBuildCounter() {
@@ -514,8 +513,8 @@
void writePackageConfig(
String projectFolderPath, {
- PackageConfigFileBuilder config,
- String languageVersion,
+ PackageConfigFileBuilder? config,
+ String? languageVersion,
bool flutter = false,
bool meta = false,
bool pedantic = false,
@@ -579,8 +578,11 @@
Either2<num, String>.t2('client-test');
int _id = 0;
- String projectFolderPath, mainFilePath, pubspecFilePath, analysisOptionsPath;
- Uri projectFolderUri, mainFileUri, pubspecFileUri, analysisOptionsUri;
+ late String projectFolderPath,
+ mainFilePath,
+ pubspecFilePath,
+ analysisOptionsPath;
+ late Uri projectFolderUri, mainFileUri, pubspecFileUri, analysisOptionsUri;
final String simplePubspecContent = 'name: my_project';
final startOfDocPos = Position(line: 0, character: 0);
final startOfDocRange = Range(
@@ -590,7 +592,7 @@
/// The client capabilities sent to the server during initialization.
///
/// null if an initialization request has not yet been sent.
- ClientCapabilities _clientCapabilities;
+ ClientCapabilities? _clientCapabilities;
final validProgressTokens = <Either2<num, String>>{};
@@ -623,7 +625,7 @@
) {
changes.forEach((fileUri, edits) {
final path = Uri.parse(fileUri).toFilePath();
- fileContents[path] = applyTextEdits(fileContents[path], edits);
+ fileContents[path] = applyTextEdits(fileContents[path]!, edits);
});
}
@@ -632,7 +634,7 @@
Either2<List<TextDocumentEdit>,
List<Either4<TextDocumentEdit, CreateFile, RenameFile, DeleteFile>>>
documentChanges, {
- Map<String, int> expectedVersions,
+ Map<String, int>? expectedVersions,
}) {
// If we were supplied with expected versions, ensure that all returned
// edits match the versions.
@@ -680,7 +682,7 @@
throw 'Recieved edits for $path which was not provided as a file to be edited. '
'Perhaps a CreateFile change was missing from the edits?';
}
- oldFileContent[path] = applyTextDocumentEdit(oldFileContent[path], edit);
+ oldFileContent[path] = applyTextDocumentEdit(oldFileContent[path]!, edit);
});
}
@@ -774,13 +776,13 @@
await sendNotificationToServer(notification);
}
- Future changeWorkspaceFolders({List<Uri> add, List<Uri> remove}) async {
+ Future changeWorkspaceFolders({List<Uri>? add, List<Uri>? remove}) async {
var notification = makeNotification(
Method.workspace_didChangeWorkspaceFolders,
DidChangeWorkspaceFoldersParams(
event: WorkspaceFoldersChangeEvent(
- added: add?.map(toWorkspaceFolder)?.toList() ?? const [],
- removed: remove?.map(toWorkspaceFolder)?.toList() ?? const [],
+ added: add?.map(toWorkspaceFolder).toList() ?? const [],
+ removed: remove?.map(toWorkspaceFolder).toList() ?? const [],
),
),
);
@@ -796,17 +798,17 @@
await sendNotificationToServer(notification);
}
- Future<Object> executeCodeAction(
+ Future<Object?> executeCodeAction(
Either2<Command, CodeAction> codeAction) async {
final command = codeAction.map(
(command) => command,
- (codeAction) => codeAction.command,
+ (codeAction) => codeAction.command!,
);
return executeCommand(command);
}
- Future<Object> executeCommand(Command command,
- {Either2<num, String> workDoneToken}) async {
+ Future<Object?> executeCommand(Command command,
+ {Either2<num, String>? workDoneToken}) async {
final request = makeRequest(
Method.workspace_executeCommand,
ExecuteCommandParams(
@@ -818,7 +820,7 @@
return expectSuccessfulResponseTo(request, (result) => result);
}
- void expect(actual, matcher, {String reason}) =>
+ void expect(actual, matcher, {String? reason}) =>
test.expect(actual, matcher, reason: reason);
void expectDocumentVersion(
@@ -906,7 +908,7 @@
Future<T> expectSuccessfulResponseTo<T, R>(
RequestMessage request, T Function(R) fromJson);
- Future<List<TextEdit>> formatDocument(String fileUri) {
+ Future<List<TextEdit>?> formatDocument(String fileUri) {
final request = makeRequest(
Method.textDocument_formatting,
DocumentFormattingParams(
@@ -920,7 +922,7 @@
request, _fromJsonList(TextEdit.fromJson));
}
- Future<List<TextEdit>> formatOnType(
+ Future<List<TextEdit>?> formatOnType(
String fileUri, Position pos, String character) {
final request = makeRequest(
Method.textDocument_onTypeFormatting,
@@ -937,7 +939,7 @@
request, _fromJsonList(TextEdit.fromJson));
}
- Future<List<TextEdit>> formatRange(String fileUri, Range range) {
+ Future<List<TextEdit>?> formatRange(String fileUri, Range range) {
final request = makeRequest(
Method.textDocument_rangeFormatting,
DocumentRangeFormattingParams(
@@ -954,8 +956,8 @@
Future<List<Either2<Command, CodeAction>>> getCodeActions(
String fileUri, {
- Range range,
- List<CodeActionKind> kinds,
+ Range? range,
+ List<CodeActionKind>? kinds,
}) {
final request = makeRequest(
Method.textDocument_codeAction,
@@ -976,7 +978,7 @@
}
Future<List<CompletionItem>> getCompletion(Uri uri, Position pos,
- {CompletionContext context}) {
+ {CompletionContext? context}) {
final request = makeRequest(
Method.textDocument_completion,
CompletionParams(
@@ -1033,7 +1035,8 @@
return expectSuccessfulResponseTo(request, DartDiagnosticServer.fromJson);
}
- Future<List<DocumentHighlight>> getDocumentHighlights(Uri uri, Position pos) {
+ Future<List<DocumentHighlight>?> getDocumentHighlights(
+ Uri uri, Position pos) {
final request = makeRequest(
Method.textDocument_documentHighlight,
TextDocumentPositionParams(
@@ -1074,7 +1077,7 @@
request, _fromJsonList(FoldingRange.fromJson));
}
- Future<Hover> getHover(Uri uri, Position pos) {
+ Future<Hover?> getHover(Uri uri, Position pos) {
final request = makeRequest(
Method.textDocument_hover,
TextDocumentPositionParams(
@@ -1121,7 +1124,7 @@
Uri uri,
Position pos,
String label, {
- CompletionContext context,
+ CompletionContext? context,
}) async {
final completions = await getCompletion(uri, pos, context: context);
@@ -1152,8 +1155,8 @@
return expectSuccessfulResponseTo(request, SemanticTokens.fromJson);
}
- Future<SignatureHelp> getSignatureHelp(Uri uri, Position pos,
- [SignatureHelpContext context]) {
+ Future<SignatureHelp?> getSignatureHelp(Uri uri, Position pos,
+ [SignatureHelpContext? context]) {
final request = makeRequest(
Method.textDocument_signatureHelp,
SignatureHelpParams(
@@ -1211,10 +1214,10 @@
Method method,
R Function(Map<String, dynamic>) fromJson,
Future<T> Function() f, {
- @required FutureOr<RR> Function(R) handler,
+ required FutureOr<RR> Function(R) handler,
Duration timeout = const Duration(seconds: 5),
}) async {
- Future<T> outboundRequest;
+ late Future<T> outboundRequest;
// Run [f] and wait for the incoming request from the server.
final incomingRequest = await expectRequest(method, () {
@@ -1245,23 +1248,24 @@
/// full objects just to change one value (the types are immutable) so must
/// match the spec exactly and are not verified.
Future<ResponseMessage> initialize({
- String rootPath,
- Uri rootUri,
- List<Uri> workspaceFolders,
- TextDocumentClientCapabilities textDocumentCapabilities,
- ClientCapabilitiesWorkspace workspaceCapabilities,
- ClientCapabilitiesWindow windowCapabilities,
- Map<String, Object> experimentalCapabilities,
- Map<String, Object> initializationOptions,
+ String? rootPath,
+ Uri? rootUri,
+ List<Uri>? workspaceFolders,
+ TextDocumentClientCapabilities? textDocumentCapabilities,
+ ClientCapabilitiesWorkspace? workspaceCapabilities,
+ ClientCapabilitiesWindow? windowCapabilities,
+ Map<String, Object?>? experimentalCapabilities,
+ Map<String, Object?>? initializationOptions,
bool throwOnFailure = true,
bool allowEmptyRootUri = false,
}) async {
- _clientCapabilities = ClientCapabilities(
+ final clientCapabilities = ClientCapabilities(
workspace: workspaceCapabilities,
textDocument: textDocumentCapabilities,
window: windowCapabilities,
experimental: experimentalCapabilities,
);
+ _clientCapabilities = clientCapabilities;
// Handle any standard incoming requests that aren't test-specific, for example
// accepting requests to create progress tokens.
@@ -1291,32 +1295,33 @@
rootPath: rootPath,
rootUri: rootUri?.toString(),
initializationOptions: initializationOptions,
- capabilities: _clientCapabilities,
- workspaceFolders: workspaceFolders?.map(toWorkspaceFolder)?.toList(),
+ capabilities: clientCapabilities,
+ workspaceFolders: workspaceFolders?.map(toWorkspaceFolder).toList(),
));
final response = await sendRequestToServer(request);
expect(response.id, equals(request.id));
- if (response.error == null) {
+ final error = response.error;
+ if (error == null) {
final notification =
makeNotification(Method.initialized, InitializedParams());
await sendNotificationToServer(notification);
await pumpEventQueue();
} else if (throwOnFailure) {
throw 'Error during initialize request: '
- '${response.error.code}: ${response.error.message}';
+ '${error.code}: ${error.message}';
}
return response;
}
- NotificationMessage makeNotification(Method method, ToJsonable params) {
+ NotificationMessage makeNotification(Method method, ToJsonable? params) {
return NotificationMessage(
method: method, params: params, jsonrpc: jsonRpcVersion);
}
RequestMessage makeRenameRequest(
- int version, Uri uri, Position pos, String newName) {
+ int? version, Uri uri, Position pos, String newName) {
final docIdentifier = version != null
? VersionedTextDocumentIdentifier(version: version, uri: uri.toString())
: TextDocumentIdentifier(uri: uri.toString());
@@ -1328,7 +1333,7 @@
return request;
}
- RequestMessage makeRequest(Method method, ToJsonable params) {
+ RequestMessage makeRequest(Method method, ToJsonable? params) {
final id = Either2<num, String>.t1(_id++);
return RequestMessage(
id: id, method: method, params: params, jsonrpc: jsonRpcVersion);
@@ -1386,7 +1391,7 @@
return expectSuccessfulResponseTo(request, WorkspaceEdit.fromJson);
}
- Future openFile(Uri uri, String content, {num version = 1}) async {
+ Future openFile(Uri uri, String content, {int version = 1}) async {
var notification = makeNotification(
Method.textDocument_didOpen,
DidOpenTextDocumentParams(
@@ -1415,10 +1420,10 @@
Position positionFromOffset(int offset, String contents) {
final lineInfo = LineInfo.fromContent(withoutMarkers(contents));
- return toPosition(lineInfo.getLocation(offset));
+ return toPosition(lineInfo.getLocation(offset) as CharacterLocation);
}
- Future<RangeAndPlaceholder> prepareRename(Uri uri, Position pos) {
+ Future<RangeAndPlaceholder?> prepareRename(Uri uri, Position pos) {
final request = makeRequest(
Method.textDocument_prepareRename,
TextDocumentPositionParams(
@@ -1457,7 +1462,7 @@
}
/// Returns the range of [searchText] in [content].
- Range rangeOfString(String content, String searchText) {
+ Range? rangeOfString(String content, String searchText) {
content = withoutMarkers(content);
final startOffset = content.indexOf(searchText);
return startOffset == -1
@@ -1505,9 +1510,9 @@
return rangesFromMarkersImpl(content).toList();
}
- Future<WorkspaceEdit> rename(
+ Future<WorkspaceEdit?> rename(
Uri uri,
- int version,
+ int? version,
Position pos,
String newName,
) {
@@ -1573,7 +1578,7 @@
Future<Null> sendShutdown() {
final request = makeRequest(Method.shutdown, null);
- return expectSuccessfulResponseTo(request, (result) => result);
+ return expectSuccessfulResponseTo(request, (result) => result as Null);
}
/// Creates a [TextEdit] using the `insert` range of a [InsertReplaceEdit].
@@ -1619,7 +1624,7 @@
await serverToClient.firstWhere((message) {
if (message is NotificationMessage) {
if (message.method == CustomMethods.analyzerStatus) {
- if (_clientCapabilities.window?.workDoneProgress == true) {
+ if (_clientCapabilities!.window?.workDoneProgress == true) {
throw Exception(
'Recieved ${CustomMethods.analyzerStatus} notification '
'but client supports workDoneProgress');
@@ -1628,7 +1633,7 @@
final params = AnalyzerStatusParams.fromJson(message.params);
return params.isAnalyzing == analyzing;
} else if (message.method == Method.progress) {
- if (_clientCapabilities.window?.workDoneProgress != true) {
+ if (_clientCapabilities!.window?.workDoneProgress != true) {
throw Exception(
'Recieved ${CustomMethods.analyzerStatus} notification '
'but client supports workDoneProgress');
@@ -1660,7 +1665,7 @@
}
Future<List<ClosingLabel>> waitForClosingLabels(Uri uri) async {
- PublishClosingLabelsParams closingLabelsParams;
+ late PublishClosingLabelsParams closingLabelsParams;
await serverToClient.firstWhere((message) {
if (message is NotificationMessage &&
message.method == CustomMethods.publishClosingLabels) {
@@ -1674,13 +1679,14 @@
return closingLabelsParams.labels;
}
- Future<List<Diagnostic>> waitForDiagnostics(Uri uri) async {
- PublishDiagnosticsParams diagnosticParams;
- await serverToClient.firstWhere((message) {
+ Future<List<Diagnostic>?> waitForDiagnostics(Uri uri) async {
+ PublishDiagnosticsParams? diagnosticParams;
+ await serverToClient.map<Message?>((message) => message).firstWhere(
+ (message) {
if (message is NotificationMessage &&
message.method == Method.textDocument_publishDiagnostics) {
diagnosticParams = PublishDiagnosticsParams.fromJson(message.params);
- return diagnosticParams.uri == uri.toString();
+ return diagnosticParams!.uri == uri.toString();
}
return false;
}, orElse: () => null);
@@ -1688,7 +1694,7 @@
}
Future<FlutterOutline> waitForFlutterOutline(Uri uri) async {
- PublishFlutterOutlineParams outlineParams;
+ late PublishFlutterOutlineParams outlineParams;
await serverToClient.firstWhere((message) {
if (message is NotificationMessage &&
message.method == CustomMethods.publishFlutterOutline) {
@@ -1702,7 +1708,7 @@
}
Future<Outline> waitForOutline(Uri uri) async {
- PublishOutlineParams outlineParams;
+ late PublishOutlineParams outlineParams;
await serverToClient.firstWhere((message) {
if (message is NotificationMessage &&
message.method == CustomMethods.publishOutline) {
@@ -1748,7 +1754,7 @@
}
Future<void> _handleWorkDoneProgressCreate(RequestMessage request) async {
- if (_clientCapabilities.window?.workDoneProgress != true) {
+ if (_clientCapabilities!.window?.workDoneProgress != true) {
throw Exception('Server sent ${Method.window_workDoneProgress_create} '
'but client capabilities do not allow');
}
@@ -1775,9 +1781,10 @@
T1 Function(R) fromJson1,
bool Function(R, LspJsonReporter) canParse2,
T2 Function(R) fromJson2,
- [LspJsonReporter reporter]) {
+ [LspJsonReporter? reporter]) {
reporter ??= nullLspJsonReporter;
return (input) {
+ reporter!;
if (canParse1(input, reporter)) {
return Either2<T1, T2>.t1(fromJson1(input));
}
diff --git a/pkg/analysis_server/test/lsp/server_test.dart b/pkg/analysis_server/test/lsp/server_test.dart
index 07858b3..c5508eb 100644
--- a/pkg/analysis_server/test/lsp/server_test.dart
+++ b/pkg/analysis_server/test/lsp/server_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analysis_server/lsp_protocol/protocol_special.dart';
import 'package:test/test.dart';
@@ -79,7 +77,8 @@
// Wait up to 1sec to ensure no error/log notifications were sent back.
var didTimeout = false;
- final notificationFromServer = await firstError.timeout(
+ final notificationFromServer =
+ await firstError.then<NotificationMessage?>((error) => error).timeout(
const Duration(seconds: 1),
onTimeout: () {
didTimeout = true;
@@ -97,7 +96,7 @@
final response = await channel.sendRequestToServer(request);
expect(response.id, equals(request.id));
expect(response.error, isNotNull);
- expect(response.error.code, equals(ErrorCodes.MethodNotFound));
+ expect(response.error!.code, equals(ErrorCodes.MethodNotFound));
expect(response.result, isNull);
}
@@ -107,7 +106,7 @@
final response = await channel.sendRequestToServer(request);
expect(response.id, equals(request.id));
expect(response.error, isNotNull);
- expect(response.error.code, equals(ErrorCodes.MethodNotFound));
+ expect(response.error!.code, equals(ErrorCodes.MethodNotFound));
expect(response.result, isNull);
}
}
diff --git a/pkg/analysis_server/test/lsp/signature_help_test.dart b/pkg/analysis_server/test/lsp/signature_help_test.dart
index 13432a9..9a6300f 100644
--- a/pkg/analysis_server/test/lsp/signature_help_test.dart
+++ b/pkg/analysis_server/test/lsp/signature_help_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -23,11 +21,11 @@
String expectedLabel,
String expectedDoc,
List<ParameterInformation> expectedParams, {
- MarkupKind expectedFormat = MarkupKind.Markdown,
- SignatureHelpContext context,
+ MarkupKind? expectedFormat = MarkupKind.Markdown,
+ SignatureHelpContext? context,
}) async {
- final res = await getSignatureHelp(
- mainFileUri, positionFromMarker(fileContent), context);
+ final res = (await getSignatureHelp(
+ mainFileUri, positionFromMarker(fileContent), context))!;
// TODO(dantup): Update this when there is clarification on how to handle
// no valid selected parameter.
@@ -41,7 +39,7 @@
// Test the format matches the tests expectation.
// For clients that don't support MarkupContent it'll be a plain string,
// but otherwise it'll be a MarkupContent of type PlainText or Markdown.
- final doc = sig.documentation;
+ final doc = sig.documentation!;
if (expectedFormat == null) {
// Plain string.
expect(doc.valueEquals(expectedDoc), isTrue);
diff --git a/pkg/analysis_server/test/lsp/super_test.dart b/pkg/analysis_server/test/lsp/super_test.dart
index 29eec48..b9192d9 100644
--- a/pkg/analysis_server/test/lsp/super_test.dart
+++ b/pkg/analysis_server/test/lsp/super_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/lsp/will_rename_files_test.dart b/pkg/analysis_server/test/lsp/will_rename_files_test.dart
index 124671d..9d88945 100644
--- a/pkg/analysis_server/test/lsp/will_rename_files_test.dart
+++ b/pkg/analysis_server/test/lsp/will_rename_files_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'dart:async';
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
@@ -56,7 +54,7 @@
final contents = {
mainFilePath: withoutMarkers(mainContent),
};
- applyChanges(contents, edit.changes);
+ applyChanges(contents, edit.changes!);
expect(contents[mainFilePath], equals(expectedMainContent));
}
}
diff --git a/pkg/analysis_server/test/lsp/workspace_symbols_test.dart b/pkg/analysis_server/test/lsp/workspace_symbols_test.dart
index 915a8a3..c2715d7 100644
--- a/pkg/analysis_server/test/lsp/workspace_symbols_test.dart
+++ b/pkg/analysis_server/test/lsp/workspace_symbols_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analysis_server/lsp_protocol/protocol_special.dart';
import 'package:test/test.dart';
@@ -100,10 +98,11 @@
);
final response = await sendRequestToServer(request);
- expect(response.error.code, equals(ErrorCodes.InvalidParams));
+ final error = response.error!;
+ expect(error.code, equals(ErrorCodes.InvalidParams));
// Ensure the error is useful to the client.
expect(
- response.error.message,
+ error.message,
equals('Invalid params for workspace/symbol:\n'
'params.query must not be undefined'),
);
diff --git a/pkg/analysis_server/test/mocks_lsp.dart b/pkg/analysis_server/test/mocks_lsp.dart
index fdb402e..d8eafef 100644
--- a/pkg/analysis_server/test/mocks_lsp.dart
+++ b/pkg/analysis_server/test/mocks_lsp.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'dart:async';
import 'dart:convert';
@@ -21,8 +19,6 @@
final StreamController<lsp.Message> _serverToClient =
StreamController<lsp.Message>.broadcast();
- String name;
-
/// Completer that will be signalled when the input stream is closed.
final Completer _closed = Completer();
@@ -78,7 +74,7 @@
@override
void listen(void Function(lsp.Message message) onMessage,
- {Function onError, void Function() onDone}) {
+ {Function? onError, void Function()? onDone}) {
_clientToServer.stream.listen(onMessage, onError: onError, onDone: onDone);
}
diff --git a/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart b/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart
index 8441368..50ccb48 100644
--- a/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart
@@ -111,12 +111,6 @@
'Constructor name must begin with a lowercase letter or underscore.');
}
- void test_validateConstructorName_null() {
- assertRefactoringStatus(
- validateConstructorName(null), RefactoringProblemSeverity.FATAL,
- expectedMessage: 'Constructor name must not be null.');
- }
-
void test_validateConstructorName_OK() {
assertRefactoringStatusOK(validateConstructorName('newName'));
}
@@ -287,12 +281,6 @@
'Import prefix name must begin with a lowercase letter or underscore.');
}
- void test_validateImportPrefixName_null() {
- assertRefactoringStatus(
- validateImportPrefixName(null), RefactoringProblemSeverity.FATAL,
- expectedMessage: 'Import prefix name must not be null.');
- }
-
void test_validateImportPrefixName_OK() {
assertRefactoringStatusOK(validateImportPrefixName('newName'));
}
@@ -433,12 +421,6 @@
'Library name identifier must begin with a lowercase letter or underscore.');
}
- void test_validateLibraryName_null() {
- assertRefactoringStatus(
- validateLibraryName(null), RefactoringProblemSeverity.FATAL,
- expectedMessage: 'Library name must not be null.');
- }
-
void test_validateLibraryName_OK_oneIdentifier() {
assertRefactoringStatusOK(validateLibraryName('name'));
}
diff --git a/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart b/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
index c134d20..3e5300d 100644
--- a/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
+++ b/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
@@ -194,7 +194,7 @@
void _writeCanParseMethod(IndentableStringBuffer buffer, Interface interface) {
buffer
..writeIndentedln(
- 'static bool canParse(Object obj, LspJsonReporter reporter) {')
+ 'static bool canParse(Object? obj, LspJsonReporter reporter) {')
..indent()
..writeIndentedln('if (obj is Map<String, dynamic>) {')
..indent();
diff --git a/pkg/analysis_server/tool/lsp_spec/typescript.dart b/pkg/analysis_server/tool/lsp_spec/typescript.dart
index 7d36548..f857a6a 100644
--- a/pkg/analysis_server/tool/lsp_spec/typescript.dart
+++ b/pkg/analysis_server/tool/lsp_spec/typescript.dart
@@ -125,6 +125,9 @@
'ProgressParams': {
'value': 'object',
},
+ 'SemanticTokens': {
+ 'data': 'int[]',
+ },
'ServerCapabilities': {
'changeNotifications': 'bool',
},
diff --git a/pkg/analysis_server/tool/lsp_spec/typescript_parser.dart b/pkg/analysis_server/tool/lsp_spec/typescript_parser.dart
index 5c9065e..96f7c88 100644
--- a/pkg/analysis_server/tool/lsp_spec/typescript_parser.dart
+++ b/pkg/analysis_server/tool/lsp_spec/typescript_parser.dart
@@ -672,7 +672,10 @@
if (improveTypes) {
final improvedTypeName = getImprovedType(containerName, fieldName);
if (improvedTypeName != null) {
- type = Type.identifier(improvedTypeName);
+ type = improvedTypeName.endsWith('[]')
+ ? ArrayType(Type.identifier(
+ improvedTypeName.substring(0, improvedTypeName.length - 2)))
+ : Type.identifier(improvedTypeName);
}
}
return type;
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 9691934..762ea4b 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,4 +1,5 @@
-## 1.5.0-dev
+## 1.5.0
+* Support for the language version `2.14`.
* Deprecated `AnalysisSession.getUnitElement()`.
Use `AnalysisSession.getUnitElement2()` instead.
* Deprecated `AnalysisSession.getResolvedUnit()`.
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index 41b1d1c..4253d6f 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -4293,6 +4293,9 @@
/// Set the semicolon terminating the directive to the given [token].
@Deprecated('Clients should not build AST manually')
set semicolon(Token token);
+
+ @override
+ LibraryElement? get uriElement;
}
/// The "native" clause in an class declaration.
diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart
index ca7f2f9..6e82d71 100644
--- a/pkg/analyzer/lib/src/dart/element/type_system.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_system.dart
@@ -1506,7 +1506,10 @@
var declaration = from.element.declaration;
return TypeParameterTypeImpl(
element: declaration,
- nullabilitySuffix: from.nullabilitySuffix,
+ nullabilitySuffix: _promotedTypeParameterTypeNullability(
+ from.nullabilitySuffix,
+ to.nullabilitySuffix,
+ ),
promotedBound: to,
);
}
@@ -1866,6 +1869,35 @@
recurse(type);
return result;
}
+
+ static NullabilitySuffix _promotedTypeParameterTypeNullability(
+ NullabilitySuffix nullabilityOfType,
+ NullabilitySuffix nullabilityOfBound,
+ ) {
+ if (nullabilityOfType == NullabilitySuffix.question &&
+ nullabilityOfBound == NullabilitySuffix.none) {
+ return NullabilitySuffix.none;
+ }
+
+ if (nullabilityOfType == NullabilitySuffix.question &&
+ nullabilityOfBound == NullabilitySuffix.question) {
+ return NullabilitySuffix.question;
+ }
+
+ if (nullabilityOfType == NullabilitySuffix.star &&
+ nullabilityOfBound == NullabilitySuffix.none) {
+ return NullabilitySuffix.star;
+ }
+
+ // Intersection with a non-nullable type always yields a non-nullable type,
+ // as it's the most restrictive kind of types.
+ if (nullabilityOfType == NullabilitySuffix.none ||
+ nullabilityOfBound == NullabilitySuffix.none) {
+ return NullabilitySuffix.none;
+ }
+
+ return NullabilitySuffix.star;
+ }
}
/// TODO(scheglov) Ask the language team how to deal with it.
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index ae88729..5e98178 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,5 +1,5 @@
name: analyzer
-version: 1.5.0-dev
+version: 1.5.0
description: This package provides a library that performs static analysis of Dart code.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer
@@ -7,7 +7,7 @@
sdk: '>=2.12.0 <3.0.0'
dependencies:
- _fe_analyzer_shared: ^20.0.0
+ _fe_analyzer_shared: ^21.0.0
cli_util: ^0.3.0
collection: ^1.15.0
convert: ^3.0.0
diff --git a/pkg/analyzer/test/generated/type_system_test.dart b/pkg/analyzer/test/generated/type_system_test.dart
index 6a50ac8..492236c 100644
--- a/pkg/analyzer/test/generated/type_system_test.dart
+++ b/pkg/analyzer/test/generated/type_system_test.dart
@@ -4,6 +4,7 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/element/element.dart';
@@ -472,22 +473,51 @@
return typeSystem.tryPromoteToType(to, from) as TypeParameterTypeImpl;
}
- void check(
- TypeParameterTypeImpl type,
- TypeParameterElement expectedElement,
- DartType expectedBound,
- ) {
- expect(type.element, expectedElement);
- expect(type.promotedBound, expectedBound);
+ void check(TypeParameterTypeImpl type, String expected) {
+ expect(type.getDisplayString(withNullability: true), expected);
}
var T = typeParameter('T');
- var T0 = typeParameterTypeNone(T);
+ var T_none = typeParameterTypeNone(T);
+ var T_question = typeParameterTypeQuestion(T);
+ var T_star = typeParameterTypeStar(T);
- var T1 = tryPromote(numNone, T0);
- check(T1, T, numNone);
+ check(tryPromote(numNone, T_none), 'T & num');
+ check(tryPromote(numQuestion, T_none), 'T & num?');
+ check(tryPromote(numStar, T_none), 'T & num*');
+
+ check(tryPromote(numNone, T_question), 'T & num');
+ check(tryPromote(numQuestion, T_question), 'T? & num?');
+ check(tryPromote(numStar, T_question), 'T* & num*');
+
+ check(tryPromote(numNone, T_star), 'T* & num');
+ check(tryPromote(numQuestion, T_star), 'T* & num?');
+ check(tryPromote(numStar, T_star), 'T* & num*');
+ }
+
+ test_typeParameter_twice() {
+ TypeParameterTypeImpl tryPromote(DartType to, TypeParameterTypeImpl from) {
+ return typeSystem.tryPromoteToType(to, from) as TypeParameterTypeImpl;
+ }
+
+ void check(
+ TypeParameterTypeImpl type,
+ TypeParameterElement element,
+ NullabilitySuffix nullability,
+ DartType promotedBound,
+ ) {
+ expect(type.element, element);
+ expect(type.nullabilitySuffix, nullability);
+ expect(type.promotedBound, promotedBound);
+ }
+
+ var T = typeParameter('T');
+ var T_none = typeParameterTypeNone(T);
+
+ var T1 = tryPromote(numNone, T_none);
+ check(T1, T, NullabilitySuffix.none, numNone);
var T2 = tryPromote(intNone, T1);
- check(T2, T, intNone);
+ check(T2, T, NullabilitySuffix.none, intNone);
}
}
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
index c99d393..786b808 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
@@ -92,10 +92,9 @@
// proto-property of the classes 'prototype' field.
// Older IEs use `Object.create` and copy over the properties.
function inherit(cls, sup) {
- // Note that RTI needs cls.name, but we don't need to set it anymore.
- if (#legacyJavaScript) {
- cls.prototype.constructor = cls;
- }
+ // cls.prototype.constructor carries the cached RTI. We could avoid this by
+ // using ES6 classes, but the side effects of this need to be tested.
+ cls.prototype.constructor = cls;
cls.prototype[#operatorIsPrefix + cls.name] = cls;
// The superclass is only null for the Dart Object.
@@ -813,8 +812,7 @@
'call0selector': js.quoteName(call0Name),
'call1selector': js.quoteName(call1Name),
- 'call2selector': js.quoteName(call2Name),
- 'legacyJavaScript': _options.legacyJavaScript
+ 'call2selector': js.quoteName(call2Name)
});
if (program.hasSoftDeferredClasses) {
mainCode = js.Block([
@@ -1202,7 +1200,6 @@
properties
.add(js.Property(js.string("constructor"), classReference(cls)));
}
-
properties.add(js.Property(_namer.operatorIs(cls.element), js.number(1)));
}
diff --git a/pkg/dart_internal/CHANGELOG.md b/pkg/dart_internal/CHANGELOG.md
index 8b39127..c49fe05 100644
--- a/pkg/dart_internal/CHANGELOG.md
+++ b/pkg/dart_internal/CHANGELOG.md
@@ -1,4 +1,8 @@
-## 0.1.12-nullsafety.1
+## 0.2.1
+
+- Support the latest Dart SDK.
+
+## 0.2.0
- Support the latest Dart SDK.
diff --git a/pkg/dart_internal/pubspec.yaml b/pkg/dart_internal/pubspec.yaml
index 3be9909..130631e 100644
--- a/pkg/dart_internal/pubspec.yaml
+++ b/pkg/dart_internal/pubspec.yaml
@@ -1,19 +1,12 @@
name: dart_internal
-version: 0.2.0
+version: 0.2.1
repository: https://github.com/dart-lang/sdk/tree/master/pkg/dart_internal
-description: >
+description: >-
This package is not intended for wide use. It provides a temporary API to
solve the problem: "Given an object some generic type A, how do I construct an
instance of generic type B with the same type argument(s)?"
- This is necessary in a few rare places in order to migrate existing code to
- Dart 2's stronger type system. Eventually, the hope is to have direct
- language support for solving this problem but we don't have time to get that
- into 2.0, so this package is provided as a temporary workaround.
-
- We will very likely remove support for this in a later version of Dart.
-
environment:
# Restrict the upper bound so that we can remove support for this in a later
# version of the SDK without it being a breaking change.
- sdk: ">=2.12.0-0 <2.13.0"
+ sdk: ">=2.12.0 <2.15.0"
diff --git a/pkg/dartdev/lib/src/commands/compile.dart b/pkg/dartdev/lib/src/commands/compile.dart
index 0dea2b7..c7e2e8f 100644
--- a/pkg/dartdev/lib/src/commands/compile.dart
+++ b/pkg/dartdev/lib/src/commands/compile.dart
@@ -6,9 +6,9 @@
import 'dart:io';
import 'package:dart2native/generate.dart';
-import 'package:path/path.dart' as path;
import 'package:front_end/src/api_prototype/compiler_options.dart'
show Verbosity;
+import 'package:path/path.dart' as path;
import '../core.dart';
import '../experiments.dart';
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index a01a3b9..cba549e 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -12,11 +12,11 @@
import 'package:kernel/core_types.dart';
import 'package:kernel/kernel.dart' hide MapEntry;
import 'package:kernel/library_index.dart';
+import 'package:kernel/src/dart_type_equivalence.dart';
import 'package:kernel/type_algebra.dart';
import 'package:kernel/type_environment.dart';
-import 'package:kernel/src/dart_type_equivalence.dart';
-import 'package:source_span/source_span.dart' show SourceLocation;
import 'package:path/path.dart' as p;
+import 'package:source_span/source_span.dart' show SourceLocation;
import '../compiler/js_names.dart' as js_ast;
import '../compiler/js_utils.dart' as js_ast;
diff --git a/pkg/dev_compiler/lib/src/kernel/expression_compiler.dart b/pkg/dev_compiler/lib/src/kernel/expression_compiler.dart
index 03c94f7..7ac69c9 100644
--- a/pkg/dev_compiler/lib/src/kernel/expression_compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/expression_compiler.dart
@@ -6,19 +6,15 @@
import 'dart:async';
-import 'package:_fe_analyzer_shared/src/messages/diagnostic_message.dart'
- show DiagnosticMessage, DiagnosticMessageHandler;
-
import 'package:_fe_analyzer_shared/src/messages/codes.dart'
show Code, Message, PlainAndColorizedString;
-
+import 'package:_fe_analyzer_shared/src/messages/diagnostic_message.dart'
+ show DiagnosticMessage, DiagnosticMessageHandler;
import 'package:dev_compiler/dev_compiler.dart';
import 'package:dev_compiler/src/compiler/js_names.dart' as js_ast;
import 'package:dev_compiler/src/compiler/module_builder.dart';
import 'package:dev_compiler/src/js_ast/js_ast.dart' as js_ast;
-
import 'package:front_end/src/api_unstable/ddc.dart';
-
import 'package:kernel/ast.dart'
show
Block,
diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart
index 1f8d5f6..c585aa4 100644
--- a/pkg/dev_compiler/lib/src/kernel/target.dart
+++ b/pkg/dev_compiler/lib/src/kernel/target.dart
@@ -8,6 +8,8 @@
import 'package:_fe_analyzer_shared/src/messages/codes.dart'
show Message, LocatedMessage;
+import 'package:_js_interop_checks/js_interop_checks.dart';
+import 'package:_js_interop_checks/src/transformations/js_util_optimizer.dart';
import 'package:kernel/class_hierarchy.dart';
import 'package:kernel/core_types.dart';
import 'package:kernel/kernel.dart';
@@ -15,8 +17,6 @@
import 'package:kernel/target/changed_structure_notifier.dart';
import 'package:kernel/target/targets.dart';
import 'package:kernel/transformations/track_widget_constructor_locations.dart';
-import 'package:_js_interop_checks/js_interop_checks.dart';
-import 'package:_js_interop_checks/src/transformations/js_util_optimizer.dart';
import 'constants.dart' show DevCompilerConstantsBackend;
import 'kernel_helpers.dart';
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
index e5fa0e0..8cda5d8 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
@@ -10,14 +10,13 @@
import 'dart:isolate';
import 'package:build_integration/file_system/multi_root.dart';
+import 'package:dev_compiler/src/kernel/expression_compiler_worker.dart';
import 'package:front_end/src/api_prototype/standard_file_system.dart';
import 'package:front_end/src/compute_platform_binaries_location.dart';
import 'package:path/path.dart' as p;
import 'package:pedantic/pedantic.dart';
import 'package:test/test.dart';
-import 'package:dev_compiler/src/kernel/expression_compiler_worker.dart';
-
/// Verbose mode for debugging
bool get verbose => false;
diff --git a/pkg/dev_compiler/test/modular_suite.dart b/pkg/dev_compiler/test/modular_suite.dart
index c93b5cb..fde41a3 100644
--- a/pkg/dev_compiler/test/modular_suite.dart
+++ b/pkg/dev_compiler/test/modular_suite.dart
@@ -11,8 +11,8 @@
import 'package:modular_test/src/io_pipeline.dart';
import 'package:modular_test/src/pipeline.dart';
-import 'package:modular_test/src/suite.dart';
import 'package:modular_test/src/runner.dart';
+import 'package:modular_test/src/suite.dart';
import 'package:package_config/package_config.dart';
String packageConfigJsonPath = '.dart_tool/package_config.json';
diff --git a/pkg/dev_compiler/test/modular_suite_nnbd.dart b/pkg/dev_compiler/test/modular_suite_nnbd.dart
index 29bd656..e00e185 100644
--- a/pkg/dev_compiler/test/modular_suite_nnbd.dart
+++ b/pkg/dev_compiler/test/modular_suite_nnbd.dart
@@ -11,8 +11,8 @@
import 'package:modular_test/src/io_pipeline.dart';
import 'package:modular_test/src/pipeline.dart';
-import 'package:modular_test/src/suite.dart';
import 'package:modular_test/src/runner.dart';
+import 'package:modular_test/src/suite.dart';
import 'package:package_config/package_config.dart';
String packageConfigJsonPath = '.dart_tool/package_config.json';
diff --git a/pkg/dev_compiler/test/nullable_inference_test.dart b/pkg/dev_compiler/test/nullable_inference_test.dart
index 6177a5b..e63b928 100644
--- a/pkg/dev_compiler/test/nullable_inference_test.dart
+++ b/pkg/dev_compiler/test/nullable_inference_test.dart
@@ -6,19 +6,19 @@
import 'dart:async';
import 'dart:io';
-import 'package:front_end/src/api_unstable/ddc.dart' as fe;
-import 'package:kernel/core_types.dart';
-import 'package:kernel/kernel.dart';
-import 'package:kernel/class_hierarchy.dart';
-import 'package:kernel/type_environment.dart';
-import 'package:kernel/src/printer.dart';
-import 'package:kernel/target/targets.dart';
-import 'package:test/test.dart';
import 'package:dev_compiler/src/kernel/command.dart';
-import 'package:dev_compiler/src/kernel/nullable_inference.dart';
import 'package:dev_compiler/src/kernel/js_typerep.dart';
+import 'package:dev_compiler/src/kernel/nullable_inference.dart';
import 'package:dev_compiler/src/kernel/target.dart';
+import 'package:front_end/src/api_unstable/ddc.dart' as fe;
+import 'package:kernel/class_hierarchy.dart';
+import 'package:kernel/core_types.dart';
+import 'package:kernel/kernel.dart';
+import 'package:kernel/src/printer.dart';
+import 'package:kernel/target/targets.dart';
+import 'package:kernel/type_environment.dart';
+import 'package:test/test.dart';
const AstTextStrategy astTextStrategy = AstTextStrategy(
includeLibraryNamesInTypes: true,
diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
index 315781f..57ba7b1 100644
--- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
@@ -2218,6 +2218,44 @@
}
} else if (receiver is NullConstant) {
return createErrorConstant(node, messageConstEvalNullValue);
+ } else if (receiver is MapConstant && enableConstFunctions) {
+ if (arguments.length == 1) {
+ final Constant other = arguments[0];
+ switch (op) {
+ case '[]':
+ final ConstantMapEntry mapEntry = receiver.entries
+ .firstWhere((entry) => entry.key == other, orElse: () => null);
+ // Null value if key is not in the map.
+ return mapEntry?.value ?? new NullConstant();
+ }
+ }
+ } else if (receiver is InstanceConstant && enableConstFunctions) {
+ if (arguments.length == 1) {
+ final Constant other = arguments[0];
+ if (receiver.classNode.name == '_ImmutableMap') {
+ switch (op) {
+ case '[]':
+ final ListConstant values = receiver.fieldValues.entries
+ .firstWhere(
+ (entry) => entry.key.canonicalName.name == '_kvPairs',
+ orElse: () => null)
+ .value;
+ assert(values != null);
+
+ // Each i index element in [values] is a key whose value is the
+ // i+1 index element.
+ int keyIndex = values.entries.indexOf(other);
+ if (keyIndex != -1) {
+ int valueIndex = keyIndex + 1;
+ assert(valueIndex != values.entries.length);
+ return values.entries[valueIndex];
+ } else {
+ // Null value if key is not in the map.
+ return new NullConstant();
+ }
+ }
+ }
+ }
}
return createErrorConstant(
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index 26d0e70..1f1cd12 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -1465,6 +1465,48 @@
new VoidTypeDeclarationBuilder(const VoidType(), this, charOffset));
}
+ void _checkBadFunctionParameter(List<TypeVariableBuilder> typeVariables) {
+ if (typeVariables == null || typeVariables.isEmpty) {
+ return;
+ }
+
+ for (TypeVariableBuilder type in typeVariables) {
+ if (type.name == "Function") {
+ addProblem(messageFunctionAsTypeParameter, type.charOffset,
+ type.name.length, type.fileUri);
+ }
+ }
+ }
+
+ void _checkBadFunctionDeclUse(String className, TypeParameterScopeKind kind,
+ int charOffset) {
+ String decType;
+ switch (kind) {
+ case TypeParameterScopeKind.classDeclaration:
+ decType = "class";
+ break;
+ case TypeParameterScopeKind.mixinDeclaration:
+ decType = "mixin";
+ break;
+ case TypeParameterScopeKind.extensionDeclaration:
+ decType = "extension";
+ break;
+ default:
+ break;
+ }
+ if (className != "Function") {
+ return;
+ }
+ if (decType == "class" && importUri.scheme == "dart") {
+ // Allow declaration of class Function in the sdk.
+ return;
+ }
+ if (decType != null) {
+ addProblem(templateFunctionUsedAsDec.withArguments(decType), charOffset,
+ className?.length, fileUri);
+ }
+ }
+
/// Add a problem that might not be reported immediately.
///
/// Problems will be issued after source information has been added.
@@ -1574,6 +1616,8 @@
int nameOffset,
int endOffset,
int supertypeOffset) {
+ _checkBadFunctionDeclUse(className, kind, nameOffset);
+ _checkBadFunctionParameter(typeVariables);
// Nested declaration began in `OutlineBuilder.beginClassDeclaration`.
TypeParameterScopeBuilder declaration =
endNestedDeclaration(kind, className)
@@ -1806,6 +1850,9 @@
int startOffset,
int nameOffset,
int endOffset) {
+ _checkBadFunctionDeclUse(
+ extensionName, TypeParameterScopeKind.extensionDeclaration, nameOffset);
+ _checkBadFunctionParameter(typeVariables);
// Nested declaration began in `OutlineBuilder.beginExtensionDeclaration`.
TypeParameterScopeBuilder declaration = endNestedDeclaration(
TypeParameterScopeKind.extensionDeclaration, extensionName)
@@ -1837,7 +1884,6 @@
nameOffset,
endOffset,
referenceFrom);
-
constructorReferences.clear();
Map<String, TypeVariableBuilder> typeVariablesByName =
checkTypeVariables(typeVariables, extensionBuilder);
diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status
index d15884e..23e753f 100644
--- a/pkg/front_end/messages.status
+++ b/pkg/front_end/messages.status
@@ -369,9 +369,11 @@
ForInLoopNotAssignable/statement: Fail
ForInLoopTypeNotIterablePartNullability/example: Fail # Cannot occur but needed for symmetry with ForInLoopTypeNotIterableNullability
ForInLoopWithConstVariable/example: Fail
+FunctionAsTypeParameter/analyzerCode: Fail
FunctionTypeDefaultValue/example: Fail
FunctionTypedParameterVar/part_wrapped_script1: Fail
FunctionTypedParameterVar/script1: Fail
+FunctionUsedAsDec/analyzerCode: Fail
GeneratorReturnsValue/example: Fail
GetterNotFound/example: Fail
GetterWithFormals/example: Fail
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index dafcd5f..174bde3 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -1797,6 +1797,20 @@
T.String field;
}
+FunctionUsedAsDec:
+ template: "'Function' is a built-in identifier, could not used as a #name name."
+ script:
+ - class Function {}
+ - extension Function on int {}
+ - mixin Function {}
+
+FunctionAsTypeParameter:
+ template: "'Function' is a built-in identifier, could not used as a type identifier."
+ script:
+ - class C<Function> {}
+ - mixin A<Function> {}
+ - extension A<Function> on List<Function> {}
+
UnresolvedPrefixInTypeAnnotation:
template: "'#name.#name2' can't be used as a type because '#name' isn't defined."
analyzerCode: NOT_A_TYPE
diff --git a/pkg/front_end/testcases/const_functions/const_functions_map.dart b/pkg/front_end/testcases/const_functions/const_functions_map.dart
new file mode 100644
index 0000000..5fbdd6b
--- /dev/null
+++ b/pkg/front_end/testcases/const_functions/const_functions_map.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+// Tests map usage with const functions.
+
+import "package:expect/expect.dart";
+
+const var1 = fn({'key': 'val'}, 'key');
+
+const var2 = fn({'key': 2}, 'key');
+
+const var3 = fn({'key': 2}, 'invalid');
+
+const map = {'key1': 2, 'key2': 3, 'key3': 4};
+const var4 = fn(map, 'key1');
+const var5 = fn(map, 'key2');
+const var6 = fn(map, 'key3');
+
+Object? fn(Map<Object, Object> map, Object key) {
+ return map[key];
+}
+
+const var7 = fn2();
+int? fn2() {
+ const y = {'key': 2};
+ return y['key'];
+}
+
+void main() {
+ Expect.equals(var1, 'val');
+ Expect.equals(var2, 2);
+ Expect.equals(var3, null);
+ Expect.equals(var4, 2);
+ Expect.equals(var5, 3);
+ Expect.equals(var6, 4);
+ Expect.equals(var7, 2);
+}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_map.dart.strong.expect b/pkg/front_end/testcases/const_functions/const_functions_map.dart.strong.expect
new file mode 100644
index 0000000..1b2b117
--- /dev/null
+++ b/pkg/front_end/testcases/const_functions/const_functions_map.dart.strong.expect
@@ -0,0 +1,46 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "package:expect/expect.dart" as exp;
+
+import "package:expect/expect.dart";
+
+static const field core::Object? var1 = #C1;
+static const field core::Object? var2 = #C2;
+static const field core::Object? var3 = #C3;
+static const field core::Map<core::String, core::int> map = #C10;
+static const field core::Object? var4 = #C2;
+static const field core::Object? var5 = #C6;
+static const field core::Object? var6 = #C8;
+static const field core::int? var7 = #C2;
+static method fn(core::Map<core::Object, core::Object> map, core::Object key) → core::Object? {
+ return map.{core::Map::[]}(key);
+}
+static method fn2() → core::int? {
+ return (#C13).{core::Map::[]}("key");
+}
+static method main() → void {
+ exp::Expect::equals(#C1, "val");
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C3, null);
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C6, 3);
+ exp::Expect::equals(#C8, 4);
+ exp::Expect::equals(#C2, 2);
+}
+
+constants {
+ #C1 = "val"
+ #C2 = 2
+ #C3 = null
+ #C4 = "key1"
+ #C5 = "key2"
+ #C6 = 3
+ #C7 = "key3"
+ #C8 = 4
+ #C9 = <dynamic>[#C4, #C2, #C5, #C6, #C7, #C8]
+ #C10 = core::_ImmutableMap<core::String, core::int> {_kvPairs:#C9}
+ #C11 = "key"
+ #C12 = <dynamic>[#C11, #C2]
+ #C13 = core::_ImmutableMap<core::String, core::int> {_kvPairs:#C12}
+}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_map.dart.strong.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_map.dart.strong.transformed.expect
new file mode 100644
index 0000000..1b2b117
--- /dev/null
+++ b/pkg/front_end/testcases/const_functions/const_functions_map.dart.strong.transformed.expect
@@ -0,0 +1,46 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "package:expect/expect.dart" as exp;
+
+import "package:expect/expect.dart";
+
+static const field core::Object? var1 = #C1;
+static const field core::Object? var2 = #C2;
+static const field core::Object? var3 = #C3;
+static const field core::Map<core::String, core::int> map = #C10;
+static const field core::Object? var4 = #C2;
+static const field core::Object? var5 = #C6;
+static const field core::Object? var6 = #C8;
+static const field core::int? var7 = #C2;
+static method fn(core::Map<core::Object, core::Object> map, core::Object key) → core::Object? {
+ return map.{core::Map::[]}(key);
+}
+static method fn2() → core::int? {
+ return (#C13).{core::Map::[]}("key");
+}
+static method main() → void {
+ exp::Expect::equals(#C1, "val");
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C3, null);
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C6, 3);
+ exp::Expect::equals(#C8, 4);
+ exp::Expect::equals(#C2, 2);
+}
+
+constants {
+ #C1 = "val"
+ #C2 = 2
+ #C3 = null
+ #C4 = "key1"
+ #C5 = "key2"
+ #C6 = 3
+ #C7 = "key3"
+ #C8 = 4
+ #C9 = <dynamic>[#C4, #C2, #C5, #C6, #C7, #C8]
+ #C10 = core::_ImmutableMap<core::String, core::int> {_kvPairs:#C9}
+ #C11 = "key"
+ #C12 = <dynamic>[#C11, #C2]
+ #C13 = core::_ImmutableMap<core::String, core::int> {_kvPairs:#C12}
+}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_map.dart.textual_outline.expect b/pkg/front_end/testcases/const_functions/const_functions_map.dart.textual_outline.expect
new file mode 100644
index 0000000..1a8595a
--- /dev/null
+++ b/pkg/front_end/testcases/const_functions/const_functions_map.dart.textual_outline.expect
@@ -0,0 +1,13 @@
+import "package:expect/expect.dart";
+
+const var1 = fn({'key': 'val'}, 'key');
+const var2 = fn({'key': 2}, 'key');
+const var3 = fn({'key': 2}, 'invalid');
+const map = {'key1': 2, 'key2': 3, 'key3': 4};
+const var4 = fn(map, 'key1');
+const var5 = fn(map, 'key2');
+const var6 = fn(map, 'key3');
+Object? fn(Map<Object, Object> map, Object key) {}
+const var7 = fn2();
+int? fn2() {}
+void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_map.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/const_functions/const_functions_map.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..4f5d64b
--- /dev/null
+++ b/pkg/front_end/testcases/const_functions/const_functions_map.dart.textual_outline_modelled.expect
@@ -0,0 +1,13 @@
+import "package:expect/expect.dart";
+
+Object? fn(Map<Object, Object> map, Object key) {}
+const map = {'key1': 2, 'key2': 3, 'key3': 4};
+const var1 = fn({'key': 'val'}, 'key');
+const var2 = fn({'key': 2}, 'key');
+const var3 = fn({'key': 2}, 'invalid');
+const var4 = fn(map, 'key1');
+const var5 = fn(map, 'key2');
+const var6 = fn(map, 'key3');
+const var7 = fn2();
+int? fn2() {}
+void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.expect b/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.expect
new file mode 100644
index 0000000..836d428
--- /dev/null
+++ b/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.expect
@@ -0,0 +1,46 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "package:expect/expect.dart" as exp;
+
+import "package:expect/expect.dart";
+
+static const field core::Object? var1 = #C1;
+static const field core::Object? var2 = #C2;
+static const field core::Object? var3 = #C3;
+static const field core::Map<core::String, core::int> map = #C10;
+static const field core::Object? var4 = #C2;
+static const field core::Object? var5 = #C6;
+static const field core::Object? var6 = #C8;
+static const field core::int? var7 = #C2;
+static method fn(core::Map<core::Object, core::Object> map, core::Object key) → core::Object? {
+ return map.{core::Map::[]}(key);
+}
+static method fn2() → core::int? {
+ return (#C13).{core::Map::[]}("key");
+}
+static method main() → void {
+ exp::Expect::equals(#C1, "val");
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C3, null);
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C6, 3);
+ exp::Expect::equals(#C8, 4);
+ exp::Expect::equals(#C2, 2);
+}
+
+constants {
+ #C1 = "val"
+ #C2 = 2
+ #C3 = null
+ #C4 = "key1"
+ #C5 = "key2"
+ #C6 = 3
+ #C7 = "key3"
+ #C8 = 4
+ #C9 = <dynamic>[#C4, #C2, #C5, #C6, #C7, #C8]
+ #C10 = core::_ImmutableMap<core::String*, core::int*> {_kvPairs:#C9}
+ #C11 = "key"
+ #C12 = <dynamic>[#C11, #C2]
+ #C13 = core::_ImmutableMap<core::String*, core::int*> {_kvPairs:#C12}
+}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.outline.expect b/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.outline.expect
new file mode 100644
index 0000000..87b21de
--- /dev/null
+++ b/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.outline.expect
@@ -0,0 +1,31 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+import "package:expect/expect.dart";
+
+static const field core::Object? var1 = self::fn(const <core::Object, core::Object>{"key": "val"}, "key");
+static const field core::Object? var2 = self::fn(const <core::Object, core::Object>{"key": 2}, "key");
+static const field core::Object? var3 = self::fn(const <core::Object, core::Object>{"key": 2}, "invalid");
+static const field core::Map<core::String, core::int> map = const <core::String, core::int>{"key1": 2, "key2": 3, "key3": 4};
+static const field core::Object? var4 = self::fn(self::map, "key1");
+static const field core::Object? var5 = self::fn(self::map, "key2");
+static const field core::Object? var6 = self::fn(self::map, "key3");
+static const field core::int? var7 = self::fn2();
+static method fn(core::Map<core::Object, core::Object> map, core::Object key) → core::Object?
+ ;
+static method fn2() → core::int?
+ ;
+static method main() → void
+ ;
+
+
+Extra constant evaluation status:
+Evaluated: MapLiteral @ org-dartlang-testcase:///const_functions_map.dart:9:17 -> InstanceConstant(const _ImmutableMap<Object*, Object*>{_ImmutableMap._kvPairs: const <dynamic>["key", "val"]})
+Evaluated: MapLiteral @ org-dartlang-testcase:///const_functions_map.dart:11:17 -> InstanceConstant(const _ImmutableMap<Object*, Object*>{_ImmutableMap._kvPairs: const <dynamic>["key", 2]})
+Evaluated: MapLiteral @ org-dartlang-testcase:///const_functions_map.dart:13:17 -> InstanceConstant(const _ImmutableMap<Object*, Object*>{_ImmutableMap._kvPairs: const <dynamic>["key", 2]})
+Evaluated: MapLiteral @ org-dartlang-testcase:///const_functions_map.dart:15:13 -> InstanceConstant(const _ImmutableMap<String*, int*>{_ImmutableMap._kvPairs: const <dynamic>["key1", 2, "key2", 3, "key3", 4]})
+Evaluated: StaticGet @ org-dartlang-testcase:///const_functions_map.dart:16:17 -> InstanceConstant(const _ImmutableMap<String*, int*>{_ImmutableMap._kvPairs: const <dynamic>["key1", 2, "key2", 3, "key3", 4]})
+Evaluated: StaticGet @ org-dartlang-testcase:///const_functions_map.dart:17:17 -> InstanceConstant(const _ImmutableMap<String*, int*>{_ImmutableMap._kvPairs: const <dynamic>["key1", 2, "key2", 3, "key3", 4]})
+Evaluated: StaticGet @ org-dartlang-testcase:///const_functions_map.dart:18:17 -> InstanceConstant(const _ImmutableMap<String*, int*>{_ImmutableMap._kvPairs: const <dynamic>["key1", 2, "key2", 3, "key3", 4]})
+Extra constant evaluation: evaluated: 14, effectively constant: 7
diff --git a/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.transformed.expect
new file mode 100644
index 0000000..836d428
--- /dev/null
+++ b/pkg/front_end/testcases/const_functions/const_functions_map.dart.weak.transformed.expect
@@ -0,0 +1,46 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "package:expect/expect.dart" as exp;
+
+import "package:expect/expect.dart";
+
+static const field core::Object? var1 = #C1;
+static const field core::Object? var2 = #C2;
+static const field core::Object? var3 = #C3;
+static const field core::Map<core::String, core::int> map = #C10;
+static const field core::Object? var4 = #C2;
+static const field core::Object? var5 = #C6;
+static const field core::Object? var6 = #C8;
+static const field core::int? var7 = #C2;
+static method fn(core::Map<core::Object, core::Object> map, core::Object key) → core::Object? {
+ return map.{core::Map::[]}(key);
+}
+static method fn2() → core::int? {
+ return (#C13).{core::Map::[]}("key");
+}
+static method main() → void {
+ exp::Expect::equals(#C1, "val");
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C3, null);
+ exp::Expect::equals(#C2, 2);
+ exp::Expect::equals(#C6, 3);
+ exp::Expect::equals(#C8, 4);
+ exp::Expect::equals(#C2, 2);
+}
+
+constants {
+ #C1 = "val"
+ #C2 = 2
+ #C3 = null
+ #C4 = "key1"
+ #C5 = "key2"
+ #C6 = 3
+ #C7 = "key3"
+ #C8 = 4
+ #C9 = <dynamic>[#C4, #C2, #C5, #C6, #C7, #C8]
+ #C10 = core::_ImmutableMap<core::String*, core::int*> {_kvPairs:#C9}
+ #C11 = "key"
+ #C12 = <dynamic>[#C11, #C2]
+ #C13 = core::_ImmutableMap<core::String*, core::int*> {_kvPairs:#C12}
+}
diff --git a/pkg/front_end/testcases/general/function_bad_use.dart b/pkg/front_end/testcases/general/function_bad_use.dart
new file mode 100644
index 0000000..bc34051
--- /dev/null
+++ b/pkg/front_end/testcases/general/function_bad_use.dart
@@ -0,0 +1,7 @@
+class Function {}
+
+class C<Function> {}
+
+mixin M<Function> implements List<Function> {}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/function_bad_use.dart.textual_outline.expect b/pkg/front_end/testcases/general/function_bad_use.dart.textual_outline.expect
new file mode 100644
index 0000000..c115bf8
--- /dev/null
+++ b/pkg/front_end/testcases/general/function_bad_use.dart.textual_outline.expect
@@ -0,0 +1,6 @@
+class Function {}
+
+class C<Function> {}
+
+mixin M<Function> implements List<Function> {}
+main() {}
diff --git a/pkg/front_end/testcases/general/function_bad_use.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/function_bad_use.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..675fe74c
--- /dev/null
+++ b/pkg/front_end/testcases/general/function_bad_use.dart.textual_outline_modelled.expect
@@ -0,0 +1,6 @@
+class C<Function> {}
+
+class Function {}
+
+main() {}
+mixin M<Function> implements List<Function> {}
diff --git a/pkg/front_end/testcases/general/function_bad_use.dart.weak.expect b/pkg/front_end/testcases/general/function_bad_use.dart.weak.expect
new file mode 100644
index 0000000..044f5c0
--- /dev/null
+++ b/pkg/front_end/testcases/general/function_bad_use.dart.weak.expect
@@ -0,0 +1,32 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:1:7: Error: 'Function' is a built-in identifier, could not used as a class name.
+// class Function {}
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:3:9: Error: 'Function' is a built-in identifier, could not used as a type identifier.
+// class C<Function> {}
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:5:9: Error: 'Function' is a built-in identifier, could not used as a type identifier.
+// mixin M<Function> implements List<Function> {}
+// ^^^^^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+class Function extends core::Object {
+ synthetic constructor •() → self::Function
+ : super core::Object::•()
+ ;
+}
+class C<Function extends core::Object? = dynamic> extends core::Object {
+ synthetic constructor •() → self::C<self::C::Function%>
+ : super core::Object::•()
+ ;
+}
+abstract class M<Function extends core::Object? = dynamic> extends core::Object implements core::List<self::M::Function%> /*isMixinDeclaration*/ {
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/function_bad_use.dart.weak.outline.expect b/pkg/front_end/testcases/general/function_bad_use.dart.weak.outline.expect
new file mode 100644
index 0000000..9e4f7cf
--- /dev/null
+++ b/pkg/front_end/testcases/general/function_bad_use.dart.weak.outline.expect
@@ -0,0 +1,31 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:1:7: Error: 'Function' is a built-in identifier, could not used as a class name.
+// class Function {}
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:3:9: Error: 'Function' is a built-in identifier, could not used as a type identifier.
+// class C<Function> {}
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:5:9: Error: 'Function' is a built-in identifier, could not used as a type identifier.
+// mixin M<Function> implements List<Function> {}
+// ^^^^^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+class Function extends core::Object {
+ synthetic constructor •() → self::Function
+ ;
+}
+class C<Function extends core::Object? = dynamic> extends core::Object {
+ synthetic constructor •() → self::C<self::C::Function%>
+ ;
+}
+abstract class M<Function extends core::Object? = dynamic> extends core::Object implements core::List<self::M::Function%> /*isMixinDeclaration*/ {
+}
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/general/function_bad_use.dart.weak.transformed.expect b/pkg/front_end/testcases/general/function_bad_use.dart.weak.transformed.expect
new file mode 100644
index 0000000..044f5c0
--- /dev/null
+++ b/pkg/front_end/testcases/general/function_bad_use.dart.weak.transformed.expect
@@ -0,0 +1,32 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:1:7: Error: 'Function' is a built-in identifier, could not used as a class name.
+// class Function {}
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:3:9: Error: 'Function' is a built-in identifier, could not used as a type identifier.
+// class C<Function> {}
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/general/function_bad_use.dart:5:9: Error: 'Function' is a built-in identifier, could not used as a type identifier.
+// mixin M<Function> implements List<Function> {}
+// ^^^^^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+class Function extends core::Object {
+ synthetic constructor •() → self::Function
+ : super core::Object::•()
+ ;
+}
+class C<Function extends core::Object? = dynamic> extends core::Object {
+ synthetic constructor •() → self::C<self::C::Function%>
+ : super core::Object::•()
+ ;
+}
+abstract class M<Function extends core::Object? = dynamic> extends core::Object implements core::List<self::M::Function%> /*isMixinDeclaration*/ {
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/ignore_function.dart b/pkg/front_end/testcases/general/ignore_function.dart
index 347a8e2..2e61179 100644
--- a/pkg/front_end/testcases/general/ignore_function.dart
+++ b/pkg/front_end/testcases/general/ignore_function.dart
@@ -14,8 +14,9 @@
operator ==(other) => false;
}
+// CFE Error here: Function is built-in id, could not used as type id.
class Function {
core.bool operator ==(core.Object other) => false;
}
-main() {}
+main() {}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/general/ignore_function.dart.weak.expect b/pkg/front_end/testcases/general/ignore_function.dart.weak.expect
index c25c94e..004e6cc 100644
--- a/pkg/front_end/testcases/general/ignore_function.dart.weak.expect
+++ b/pkg/front_end/testcases/general/ignore_function.dart.weak.expect
@@ -1,4 +1,11 @@
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/ignore_function.dart:18:7: Error: 'Function' is a built-in identifier, could not used as a class name.
+// class Function {
+// ^^^^^^^^
+//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/general/ignore_function.dart.weak.outline.expect b/pkg/front_end/testcases/general/ignore_function.dart.weak.outline.expect
index 0eda64b..7b3df99 100644
--- a/pkg/front_end/testcases/general/ignore_function.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/ignore_function.dart.weak.outline.expect
@@ -1,4 +1,11 @@
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/ignore_function.dart:18:7: Error: 'Function' is a built-in identifier, could not used as a class name.
+// class Function {
+// ^^^^^^^^
+//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/general/ignore_function.dart.weak.transformed.expect b/pkg/front_end/testcases/general/ignore_function.dart.weak.transformed.expect
index c25c94e..004e6cc 100644
--- a/pkg/front_end/testcases/general/ignore_function.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/ignore_function.dart.weak.transformed.expect
@@ -1,4 +1,11 @@
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/ignore_function.dart:18:7: Error: 'Function' is a built-in identifier, could not used as a class name.
+// class Function {
+// ^^^^^^^^
+//
import self as self;
import "dart:core" as core;
diff --git a/pkg/test_runner/bin/test_runner.dart b/pkg/test_runner/bin/test_runner.dart
index 1c2d26a..654e5f8 100644
--- a/pkg/test_runner/bin/test_runner.dart
+++ b/pkg/test_runner/bin/test_runner.dart
@@ -22,8 +22,8 @@
///
/// The default test directory layout is documented in "test_suite.dart", above
/// `factory StandardTestSuite.forDirectory`.
-import "package:test_runner/src/options.dart";
import "package:test_runner/src/build_configurations.dart";
+import "package:test_runner/src/options.dart";
import "package:test_runner/src/test_configurations.dart";
/// Runs all of the tests specified by the given command line [arguments].
diff --git a/pkg/test_runner/lib/src/command_output.dart b/pkg/test_runner/lib/src/command_output.dart
index 5d8e490..d2807a7a4 100644
--- a/pkg/test_runner/lib/src/command_output.dart
+++ b/pkg/test_runner/lib/src/command_output.dart
@@ -7,10 +7,10 @@
// CommandOutput.exitCode in subclasses of CommandOutput.
import 'dart:io' as io;
+import 'package:dart2js_tools/deobfuscate_stack_trace.dart';
import 'package:status_file/expectation.dart';
import 'package:test_runner/src/repository.dart';
import 'package:test_runner/src/static_error.dart';
-import 'package:dart2js_tools/deobfuscate_stack_trace.dart';
import 'browser_controller.dart';
import 'command.dart';
@@ -1364,7 +1364,7 @@
/// The test runner only validates the first line of the message, and not the
/// suggested fixes.
static final _errorRegexp = RegExp(
- r"^([^:]+):(\d+):(\d+): (Context|Error|Warning): (.*)$",
+ r"^(?:([^:]+):(\d+):(\d+): )?(Context|Error|Warning): (.*)$",
multiLine: true);
FastaCommandOutput(
@@ -1398,11 +1398,27 @@
[List<StaticError> warnings]) {
StaticError previousError;
for (var match in regExp.allMatches(stdout)) {
- var line = int.parse(match.group(2));
- var column = int.parse(match.group(3));
+ var line = _parseNullableInt(match.group(2));
+ var column = _parseNullableInt(match.group(3));
var severity = match.group(4);
var message = match.group(5);
+ if (line == null) {
+ // No location information.
+ if (severity == 'Context' && previousError != null) {
+ // We can use the location information from the error message
+ line = previousError.line;
+ column = previousError.column;
+ } else {
+ // No good default location information, so disregard the error.
+ // TODO(45558): we should do something smarter here.
+ continue;
+ }
+ }
+ // Column information should have been present or it should have been
+ // filled in by the code above.
+ assert(column != null);
+
var error = StaticError(
severity == "Context" ? ErrorSource.context : errorSource, message,
line: line, column: column);
@@ -1426,6 +1442,15 @@
}
}
+ /// Same as `int.parse`, but allows nulls to simply pass through.
+ static int _parseNullableInt(String s) {
+ if (s == null) {
+ // ignore: avoid_returning_null
+ return null;
+ }
+ return int.parse(s);
+ }
+
/// Reported static errors, parsed from [stderr].
List<StaticError> get errors {
if (!_parsedErrors) {
diff --git a/pkg/test_runner/lib/src/options.dart b/pkg/test_runner/lib/src/options.dart
index 96be311..9fa11de 100644
--- a/pkg/test_runner/lib/src/options.dart
+++ b/pkg/test_runner/lib/src/options.dart
@@ -5,12 +5,12 @@
import 'dart:convert';
import 'dart:io';
-import 'package:test_runner/src/test_configurations.dart';
import 'package:path/path.dart' as path;
import 'configuration.dart';
import 'path.dart';
import 'repository.dart';
+import 'test_configurations.dart';
import 'utils.dart';
const _defaultTestSelectors = [
diff --git a/pkg/test_runner/test/test_runner_test.dart b/pkg/test_runner/test/test_runner_test.dart
index eea706f..3d9ab93 100644
--- a/pkg/test_runner/test/test_runner_test.dart
+++ b/pkg/test_runner/test/test_runner_test.dart
@@ -10,15 +10,14 @@
import "dart:io";
import "package:status_file/expectation.dart";
-
import "package:test_runner/src/command.dart";
import "package:test_runner/src/configuration.dart";
import "package:test_runner/src/options.dart";
import "package:test_runner/src/process_queue.dart";
import "package:test_runner/src/repository.dart";
import "package:test_runner/src/test_case.dart";
-import "package:test_runner/src/test_suite.dart";
import "package:test_runner/src/test_progress.dart" as progress;
+import "package:test_runner/src/test_suite.dart";
final DEFAULT_TIMEOUT = 20;
final LONG_TIMEOUT = 30;
diff --git a/pkg/vm_service/test/async_scope_test.dart b/pkg/vm_service/test/async_scope_test.dart
index 9451c0a..f72311b 100644
--- a/pkg/vm_service/test/async_scope_test.dart
+++ b/pkg/vm_service/test/async_scope_test.dart
@@ -3,13 +3,15 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:developer';
-import 'package:vm_service/vm_service.dart';
+
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
+
import 'common/service_test_common.dart';
import 'common/test_helper.dart';
-const int LINE_A = 19;
-const int LINE_B = 25;
+const int LINE_A = 20;
+const int LINE_B = 26;
foo() {}
diff --git a/pkg/vm_service/test/capture_stdio_test.dart b/pkg/vm_service/test/capture_stdio_test.dart
index 2edf76c..c5037d3 100644
--- a/pkg/vm_service/test/capture_stdio_test.dart
+++ b/pkg/vm_service/test/capture_stdio_test.dart
@@ -6,8 +6,10 @@
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
-import 'package:vm_service/vm_service.dart';
+
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
+
import 'common/service_test_common.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/common/service_test_common.dart b/pkg/vm_service/test/common/service_test_common.dart
index 8277753..4f616ab 100644
--- a/pkg/vm_service/test/common/service_test_common.dart
+++ b/pkg/vm_service/test/common/service_test_common.dart
@@ -5,8 +5,9 @@
library service_test_common;
import 'dart:async';
-import 'package:vm_service/vm_service.dart';
+
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
typedef IsolateTest = Future<void> Function(
VmService service, IsolateRef isolate);
diff --git a/pkg/vm_service/test/common/test_helper.dart b/pkg/vm_service/test/common/test_helper.dart
index c589177..eee241f 100644
--- a/pkg/vm_service/test/common/test_helper.dart
+++ b/pkg/vm_service/test/common/test_helper.dart
@@ -7,11 +7,14 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io' as io;
+
import 'package:process/process.dart';
-import 'package:vm_service/vm_service_io.dart';
-import 'package:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
+import 'package:vm_service/vm_service_io.dart';
+
import 'service_test_common.dart';
+
export 'service_test_common.dart' show IsolateTest, VMTest;
/// The extra arguments to use
diff --git a/pkg/vm_service/test/evaluate_with_scope_test.dart b/pkg/vm_service/test/evaluate_with_scope_test.dart
index a10aeee..0ec973c 100644
--- a/pkg/vm_service/test/evaluate_with_scope_test.dart
+++ b/pkg/vm_service/test/evaluate_with_scope_test.dart
@@ -2,8 +2,9 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
+
import 'common/test_helper.dart';
int? thing1;
diff --git a/pkg/vm_service/test/file_service_test.dart b/pkg/vm_service/test/file_service_test.dart
index e8b5713..c4a08d7 100644
--- a/pkg/vm_service/test/file_service_test.dart
+++ b/pkg/vm_service/test/file_service_test.dart
@@ -7,8 +7,8 @@
import 'dart:developer';
import 'dart:io' as io;
-import 'package:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/get_allocation_profile_rpc_test.dart b/pkg/vm_service/test/get_allocation_profile_rpc_test.dart
index 3007013..8246732 100644
--- a/pkg/vm_service/test/get_allocation_profile_rpc_test.dart
+++ b/pkg/vm_service/test/get_allocation_profile_rpc_test.dart
@@ -2,8 +2,8 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/get_cpu_samples_rpc_test.dart b/pkg/vm_service/test/get_cpu_samples_rpc_test.dart
index 37973bc..ecc6d25 100644
--- a/pkg/vm_service/test/get_cpu_samples_rpc_test.dart
+++ b/pkg/vm_service/test/get_cpu_samples_rpc_test.dart
@@ -2,8 +2,8 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/get_http_profile_test.dart b/pkg/vm_service/test/get_http_profile_test.dart
index 59219fb..b111440 100644
--- a/pkg/vm_service/test/get_http_profile_test.dart
+++ b/pkg/vm_service/test/get_http_profile_test.dart
@@ -8,8 +8,9 @@
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';
-import 'package:vm_service/vm_service.dart';
+
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/get_stack_test.dart b/pkg/vm_service/test/get_stack_test.dart
index dc7c05d..f1df2ba 100644
--- a/pkg/vm_service/test/get_stack_test.dart
+++ b/pkg/vm_service/test/get_stack_test.dart
@@ -6,8 +6,8 @@
import 'dart:developer';
-import 'package:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/service_test_common.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/get_version_rpc_test.dart b/pkg/vm_service/test/get_version_rpc_test.dart
index 57be153..d8ce3d7 100644
--- a/pkg/vm_service/test/get_version_rpc_test.dart
+++ b/pkg/vm_service/test/get_version_rpc_test.dart
@@ -2,8 +2,8 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/heap_snapshot_graph_test.dart b/pkg/vm_service/test/heap_snapshot_graph_test.dart
index 9a65d32..09592fd 100644
--- a/pkg/vm_service/test/heap_snapshot_graph_test.dart
+++ b/pkg/vm_service/test/heap_snapshot_graph_test.dart
@@ -2,8 +2,8 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/object_graph_identity_hash_test.dart b/pkg/vm_service/test/object_graph_identity_hash_test.dart
index a0e8c7d..9ada6aa 100644
--- a/pkg/vm_service/test/object_graph_identity_hash_test.dart
+++ b/pkg/vm_service/test/object_graph_identity_hash_test.dart
@@ -4,8 +4,9 @@
import 'dart:collection';
-import 'package:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
+
import 'common/test_helper.dart';
class Foo {}
diff --git a/pkg/vm_service/test/regress_44588_test.dart b/pkg/vm_service/test/regress_44588_test.dart
index 3f0564f..b9ab0b3 100644
--- a/pkg/vm_service/test/regress_44588_test.dart
+++ b/pkg/vm_service/test/regress_44588_test.dart
@@ -2,8 +2,8 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/regress_44842_test.dart b/pkg/vm_service/test/regress_44842_test.dart
index 8a794b4..f7dc88e 100644
--- a/pkg/vm_service/test/regress_44842_test.dart
+++ b/pkg/vm_service/test/regress_44842_test.dart
@@ -2,8 +2,8 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
const Map<String, dynamic> kNullInstance = {
'type': '@Instance',
diff --git a/pkg/vm_service/test/rpc_error_test.dart b/pkg/vm_service/test/rpc_error_test.dart
index c9cf1be..87e8776 100644
--- a/pkg/vm_service/test/rpc_error_test.dart
+++ b/pkg/vm_service/test/rpc_error_test.dart
@@ -2,8 +2,8 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/set_breakpoint_state_test.dart b/pkg/vm_service/test/set_breakpoint_state_test.dart
index 7bc96ab..6149418 100644
--- a/pkg/vm_service/test/set_breakpoint_state_test.dart
+++ b/pkg/vm_service/test/set_breakpoint_state_test.dart
@@ -3,8 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--verbose_debug
-import 'package:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/service_test_common.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/throws_sentinel_test.dart b/pkg/vm_service/test/throws_sentinel_test.dart
index fd95bbe..b9242b3 100644
--- a/pkg/vm_service/test/throws_sentinel_test.dart
+++ b/pkg/vm_service/test/throws_sentinel_test.dart
@@ -2,8 +2,8 @@
// 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:vm_service/vm_service.dart';
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/pkg/vm_service/test/verify_http_timeline_test.dart b/pkg/vm_service/test/verify_http_timeline_test.dart
index 033571a..ce9dbde 100644
--- a/pkg/vm_service/test/verify_http_timeline_test.dart
+++ b/pkg/vm_service/test/verify_http_timeline_test.dart
@@ -8,8 +8,9 @@
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';
-import 'package:vm_service/vm_service.dart';
+
import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
diff --git a/runtime/observatory/tests/service/regress_45684_test.dart b/runtime/observatory/tests/service/regress_45684_test.dart
new file mode 100644
index 0000000..5a2ea97
--- /dev/null
+++ b/runtime/observatory/tests/service/regress_45684_test.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// 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.
+//
+// VMOptions=--verbose_debug
+
+// Check that a try/finally is not treated as a try/catch:
+// http://dartbug.com/45684.
+
+import 'test_helper.dart';
+import 'service_test_common.dart';
+
+const int LINE_A = 25;
+
+void tryFinally(Function() code) {
+ // There is a synthetic try/catch inside try/finally but it is not authored
+ // by the user, so debugger should not consider that this try/catch is
+ // going to handle the exception.
+ try {
+ code();
+ } finally {}
+}
+
+syncThrow() {
+ throw 'Hello from syncThrow!'; // Line A.
+}
+
+testMain() {
+ tryFinally(syncThrow);
+}
+
+final tests = <IsolateTest>[
+ hasStoppedWithUnhandledException,
+ stoppedAtLine(LINE_A),
+];
+
+main([args = const <String>[]]) => runIsolateTests(args, tests,
+ testeeConcurrent: testMain, pause_on_unhandled_exceptions: true);
diff --git a/runtime/observatory/tests/service/sdk_break_with_mixin_test.dart b/runtime/observatory/tests/service/sdk_break_with_mixin_test.dart
new file mode 100644
index 0000000..620b530
--- /dev/null
+++ b/runtime/observatory/tests/service/sdk_break_with_mixin_test.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+library mixin_step_test;
+
+import 'dart:collection';
+import 'dart:developer';
+import 'service_test_common.dart';
+import 'test_helper.dart';
+
+int codeRuns = 0;
+
+code() {
+ if (++codeRuns > 1) {
+ print("Calling debugger!");
+ debugger();
+ }
+ MySet y = new MySet();
+ y.forEach((element) {
+ print(element);
+ });
+}
+
+class MySet extends Object with SetMixin {
+ bool add(value) => throw UnimplementedError();
+ bool contains(Object? element) => false;
+ Iterator get iterator => [].iterator;
+ int get length => 0;
+ lookup(Object? element) => throw UnimplementedError();
+ bool remove(Object? value) => throw UnimplementedError();
+ Set toSet() => throw UnimplementedError();
+}
+
+List<String> stops = [];
+List<String> expected = [
+ "set.dart:142:23 (sdk_break_with_mixin_test.dart:20:5)",
+];
+
+var tests = <IsolateTest>[
+ hasStoppedAtBreakpoint,
+ markDartColonLibrariesDebuggable,
+ setBreakpointAtUriAndLine(
+ "org-dartlang-sdk:///sdk/lib/collection/set.dart", 142),
+ resumeProgramRecordingStops(stops, true),
+ checkRecordedStops(stops, expected, debugPrint: true),
+];
+
+main(args) {
+ runIsolateTests(args, tests,
+ testeeBefore: code,
+ testeeConcurrent: code,
+ pause_on_start: false,
+ pause_on_exit: true);
+}
+
diff --git a/runtime/observatory_2/tests/service_2/regress_45684_test.dart b/runtime/observatory_2/tests/service_2/regress_45684_test.dart
new file mode 100644
index 0000000..5a2ea97
--- /dev/null
+++ b/runtime/observatory_2/tests/service_2/regress_45684_test.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// 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.
+//
+// VMOptions=--verbose_debug
+
+// Check that a try/finally is not treated as a try/catch:
+// http://dartbug.com/45684.
+
+import 'test_helper.dart';
+import 'service_test_common.dart';
+
+const int LINE_A = 25;
+
+void tryFinally(Function() code) {
+ // There is a synthetic try/catch inside try/finally but it is not authored
+ // by the user, so debugger should not consider that this try/catch is
+ // going to handle the exception.
+ try {
+ code();
+ } finally {}
+}
+
+syncThrow() {
+ throw 'Hello from syncThrow!'; // Line A.
+}
+
+testMain() {
+ tryFinally(syncThrow);
+}
+
+final tests = <IsolateTest>[
+ hasStoppedWithUnhandledException,
+ stoppedAtLine(LINE_A),
+];
+
+main([args = const <String>[]]) => runIsolateTests(args, tests,
+ testeeConcurrent: testMain, pause_on_unhandled_exceptions: true);
diff --git a/runtime/observatory_2/tests/service_2/sdk_break_with_mixin_test.dart b/runtime/observatory_2/tests/service_2/sdk_break_with_mixin_test.dart
new file mode 100644
index 0000000..d7b87ca
--- /dev/null
+++ b/runtime/observatory_2/tests/service_2/sdk_break_with_mixin_test.dart
@@ -0,0 +1,58 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+library mixin_step_test;
+
+import 'dart:collection';
+import 'dart:developer';
+
+import 'service_test_common.dart';
+import 'test_helper.dart';
+
+int codeRuns = 0;
+
+code() {
+ if (++codeRuns > 1) {
+ print("Calling debugger!");
+ debugger();
+ }
+ MySet y = new MySet();
+ y.forEach((element) {
+ print(element);
+ });
+}
+
+class MySet extends Object with SetMixin {
+ bool add(value) => throw UnimplementedError();
+ bool contains(Object element) => false;
+ Iterator get iterator => [].iterator;
+ int get length => 0;
+ lookup(Object element) => throw UnimplementedError();
+ bool remove(Object value) => throw UnimplementedError();
+ Set toSet() => throw UnimplementedError();
+}
+
+List<String> stops = [];
+List<String> expected = [
+ "set.dart:142:23 (sdk_break_with_mixin_test.dart:21:5)",
+];
+
+var tests = <IsolateTest>[
+ // hasPausedAtStart,
+ hasStoppedAtBreakpoint,
+ markDartColonLibrariesDebuggable,
+ setBreakpointAtUriAndLine(
+ "org-dartlang-sdk:///sdk/lib/collection/set.dart", 142),
+ resumeProgramRecordingStops(stops, true),
+ // runStepIntoThroughProgramRecordingStops(stops),
+ checkRecordedStops(stops, expected, debugPrint: true),
+];
+
+main(args) {
+ runIsolateTests(args, tests,
+ testeeBefore: code,
+ testeeConcurrent: code,
+ pause_on_start: false,
+ pause_on_exit: true);
+}
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index e75d799..4689812 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -690,10 +690,10 @@
TypeArgumentsPtr type_args = TypeArguments::RawCast(object);
objects_.Add(type_args);
- s->Push(type_args->untag()->instantiations_);
- const intptr_t length = Smi::Value(type_args->untag()->length_);
+ s->Push(type_args->untag()->instantiations());
+ const intptr_t length = Smi::Value(type_args->untag()->length());
for (intptr_t i = 0; i < length; i++) {
- s->Push(type_args->untag()->types()[i]);
+ s->Push(type_args->untag()->element(i));
}
}
@@ -706,7 +706,7 @@
TypeArgumentsPtr type_args = objects_[i];
s->AssignRef(type_args);
AutoTraceObject(type_args);
- const intptr_t length = Smi::Value(type_args->untag()->length_);
+ const intptr_t length = Smi::Value(type_args->untag()->length());
s->WriteUnsigned(length);
target_memory_size_ +=
compiler::target::TypeArguments::InstanceSize(length);
@@ -719,15 +719,16 @@
for (intptr_t i = 0; i < count; i++) {
TypeArgumentsPtr type_args = objects_[i];
AutoTraceObject(type_args);
- const intptr_t length = Smi::Value(type_args->untag()->length_);
+ const intptr_t length = Smi::Value(type_args->untag()->length());
s->WriteUnsigned(length);
- intptr_t hash = Smi::Value(type_args->untag()->hash_);
+ intptr_t hash = Smi::Value(type_args->untag()->hash());
s->Write<int32_t>(hash);
- const intptr_t nullability = Smi::Value(type_args->untag()->nullability_);
+ const intptr_t nullability =
+ Smi::Value(type_args->untag()->nullability());
s->WriteUnsigned(nullability);
- WriteField(type_args, instantiations_);
+ WriteField(type_args, instantiations());
for (intptr_t j = 0; j < length; j++) {
- s->WriteElementRef(type_args->untag()->types()[j], j);
+ s->WriteElementRef(type_args->untag()->element(j), j);
}
}
}
diff --git a/runtime/vm/compiler/assembler/assembler_arm.h b/runtime/vm/compiler/assembler/assembler_arm.h
index 68bcae0..accbb47 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.h
+++ b/runtime/vm/compiler/assembler/assembler_arm.h
@@ -410,6 +410,9 @@
void CompareWithFieldValue(Register value, FieldAddress address) {
CompareWithMemoryValue(value, address);
}
+ void CompareWithCompressedFieldValue(Register value, FieldAddress address) {
+ CompareWithMemoryValue(value, address);
+ }
void CompareWithMemoryValue(Register value, Address address) {
ldr(TMP, address);
@@ -946,14 +949,21 @@
// For loading indexed payloads out of tagged objects like Arrays. If the
// payload objects are word-sized, use TIMES_HALF_WORD_SIZE if the contents of
// [index] is a Smi, otherwise TIMES_WORD_SIZE if unboxed.
- void LoadIndexedPayload(Register reg,
+ void LoadIndexedPayload(Register dst,
Register base,
int32_t payload_start,
Register index,
ScaleFactor scale,
OperandSize type = kFourBytes) {
- add(reg, base, Operand(index, LSL, scale));
- LoadFromOffset(reg, reg, payload_start - kHeapObjectTag, type);
+ add(dst, base, Operand(index, LSL, scale));
+ LoadFromOffset(dst, dst, payload_start - kHeapObjectTag, type);
+ }
+ void LoadIndexedCompressed(Register dst,
+ Register base,
+ int32_t offset,
+ Register index) {
+ add(dst, base, Operand(index, LSL, TIMES_COMPRESSED_WORD_SIZE));
+ LoadCompressedFieldFromOffset(dst, dst, offset);
}
void LoadFromStack(Register dst, intptr_t depth);
void StoreToStack(Register src, intptr_t depth);
diff --git a/runtime/vm/compiler/assembler/assembler_arm64.h b/runtime/vm/compiler/assembler/assembler_arm64.h
index 9953c0a..949711e 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64.h
+++ b/runtime/vm/compiler/assembler/assembler_arm64.h
@@ -310,8 +310,9 @@
switch (cid) {
case kArrayCid:
case kImmutableArrayCid:
- case kTypeArgumentsCid:
return kEightBytes;
+ case kTypeArgumentsCid:
+ return kObjectBytes;
case kOneByteStringCid:
case kExternalOneByteStringCid:
return kByte;
@@ -576,10 +577,15 @@
void CompareWithFieldValue(Register value, FieldAddress address) {
CompareWithMemoryValue(value, address);
}
+ void CompareWithCompressedFieldValue(Register value, FieldAddress address) {
+ CompareWithMemoryValue(value, address, kObjectBytes);
+ }
- void CompareWithMemoryValue(Register value, Address address) {
- ldr(TMP, address);
- cmp(value, Operand(TMP));
+ void CompareWithMemoryValue(Register value,
+ Address address,
+ OperandSize sz = kEightBytes) {
+ ldr(TMP, address, sz);
+ cmp(value, Operand(TMP), sz);
}
void CompareTypeNullabilityWith(Register type, int8_t value) {
@@ -1707,6 +1713,13 @@
add(dest, base, Operand(index, LSL, scale));
LoadFromOffset(dest, dest, payload_offset - kHeapObjectTag, sz);
}
+ void LoadIndexedCompressed(Register dest,
+ Register base,
+ int32_t offset,
+ Register index) {
+ add(dest, base, Operand(index, LSL, TIMES_COMPRESSED_WORD_SIZE));
+ LoadCompressedFieldFromOffset(dest, dest, offset);
+ }
void LoadSFromOffset(VRegister dest, Register base, int32_t offset);
void LoadDFromOffset(VRegister dest, Register base, int32_t offset);
void LoadDFieldFromOffset(VRegister dest, Register base, int32_t offset) {
diff --git a/runtime/vm/compiler/assembler/assembler_ia32.h b/runtime/vm/compiler/assembler/assembler_ia32.h
index a46152c..4cc8cd5 100644
--- a/runtime/vm/compiler/assembler/assembler_ia32.h
+++ b/runtime/vm/compiler/assembler/assembler_ia32.h
@@ -624,6 +624,13 @@
OperandSize sz = kFourBytes) {
LoadFromOffset(dst, FieldAddress(base, index, scale, payload_offset), sz);
}
+ void LoadIndexedCompressed(Register dst,
+ Register base,
+ int32_t offset,
+ Register index) {
+ LoadCompressedField(
+ dst, FieldAddress(base, index, TIMES_COMPRESSED_WORD_SIZE, offset));
+ }
void LoadFromStack(Register dst, intptr_t depth);
void StoreToStack(Register src, intptr_t depth);
void CompareToStack(Register src, intptr_t depth);
diff --git a/runtime/vm/compiler/assembler/assembler_x64.h b/runtime/vm/compiler/assembler/assembler_x64.h
index 75822c0..7627c588 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.h
+++ b/runtime/vm/compiler/assembler/assembler_x64.h
@@ -969,6 +969,13 @@
OperandSize sz = kEightBytes) {
LoadFromOffset(dst, FieldAddress(base, index, scale, payload_offset), sz);
}
+ void LoadIndexedCompressed(Register dst,
+ Register base,
+ int32_t offset,
+ Register index) {
+ LoadCompressed(
+ dst, FieldAddress(base, index, TIMES_COMPRESSED_WORD_SIZE, offset));
+ }
void StoreFieldToOffset(Register src,
Register base,
int32_t offset,
@@ -999,6 +1006,9 @@
}
void CompareWithFieldValue(Register value, FieldAddress address) {
+ cmpq(value, address);
+ }
+ void CompareWithCompressedFieldValue(Register value, FieldAddress address) {
OBJ(cmp)(value, address);
}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.cc b/runtime/vm/compiler/backend/flow_graph_compiler.cc
index e2a8d34..995ce73 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler.cc
@@ -2702,7 +2702,7 @@
// Check if type arguments are null, i.e. equivalent to vector of dynamic.
__ CompareObject(kTypeArgumentsReg, Object::null_object());
__ BranchIf(EQUAL, is_instance_lbl);
- __ LoadFieldFromOffset(
+ __ LoadCompressedFieldFromOffset(
kScratchReg, kTypeArgumentsReg,
compiler::target::TypeArguments::type_at_offset(type_param.index()));
// kScratchReg: Concrete type of type.
@@ -3036,7 +3036,7 @@
__ BranchIf(EQUAL, done);
// Put the instantiated type parameter into the scratch register, so its
// TTS can be called by the caller.
- __ LoadField(
+ __ LoadCompressedField(
TypeTestABI::kScratchReg,
compiler::FieldAddress(kTypeArgumentsReg,
compiler::target::TypeArguments::type_at_offset(
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index a0ee87a..1935dac 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -1783,7 +1783,11 @@
ASSERT(representation() == kTagged);
ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid) ||
(class_id() == kTypeArgumentsCid));
- __ ldr(result, element_address);
+ if (class_id() == kTypeArgumentsCid) {
+ __ LoadCompressed(result, element_address);
+ } else {
+ __ ldr(result, element_address);
+ }
break;
}
}
diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc
index 9eaa60c..e24c972 100644
--- a/runtime/vm/compiler/backend/il_x64.cc
+++ b/runtime/vm/compiler/backend/il_x64.cc
@@ -1809,7 +1809,11 @@
ASSERT(representation() == kTagged);
ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid) ||
(class_id() == kTypeArgumentsCid));
- __ movq(result, element_address);
+ if (class_id() == kTypeArgumentsCid) {
+ __ LoadCompressed(result, element_address);
+ } else {
+ __ movq(result, element_address);
+ }
break;
}
}
diff --git a/runtime/vm/compiler/backend/slot.cc b/runtime/vm/compiler/backend/slot.cc
index 3cb6371..6248192 100644
--- a/runtime/vm/compiler/backend/slot.cc
+++ b/runtime/vm/compiler/backend/slot.cc
@@ -238,8 +238,9 @@
const intptr_t offset =
compiler::target::TypeArguments::type_at_offset(index);
const Slot& slot =
- Slot(Kind::kTypeArgumentsIndex, IsImmutableBit::encode(true), kDynamicCid,
- offset, ":argument", /*static_type=*/nullptr, kTagged);
+ Slot(Kind::kTypeArgumentsIndex,
+ IsImmutableBit::encode(true) | IsCompressedBit::encode(true),
+ kDynamicCid, offset, ":argument", /*static_type=*/nullptr, kTagged);
return SlotCache::Instance(thread).Canonicalize(slot);
}
diff --git a/runtime/vm/compiler/backend/slot.h b/runtime/vm/compiler/backend/slot.h
index 8dec3c8..4465d4b 100644
--- a/runtime/vm/compiler/backend/slot.h
+++ b/runtime/vm/compiler/backend/slot.h
@@ -106,7 +106,7 @@
V(ArgumentsDescriptor, UntaggedArray, count, Smi, FINAL) \
V(ArgumentsDescriptor, UntaggedArray, size, Smi, FINAL) \
V(PointerBase, UntaggedPointerBase, data_field, Dynamic, FINAL) \
- V(TypeArguments, UntaggedTypeArguments, length, Smi, FINAL) \
+ V(TypeArguments, UntaggedTypeArguments, length, Smi, FINAL_COMPRESSED) \
V(TypeParameter, UntaggedTypeParameter, bound, Dynamic, FINAL_COMPRESSED) \
V(TypeParameter, UntaggedTypeParameter, name, Dynamic, FINAL_COMPRESSED) \
V(UnhandledException, UntaggedUnhandledException, exception, Dynamic, \
diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc
index 5d294d8..94867c4 100644
--- a/runtime/vm/compiler/frontend/kernel_to_il.cc
+++ b/runtime/vm/compiler/frontend/kernel_to_il.cc
@@ -2556,7 +2556,8 @@
Fragment loop_body(more);
loop_body += LoadLocal(info.type_parameters);
loop_body += LoadLocal(info.vars->current_param_index);
- loop_body += LoadIndexed(kTypeArgumentsCid);
+ loop_body += LoadIndexed(
+ kTypeArgumentsCid, /*index_scale*/ compiler::target::kCompressedWordSize);
LocalVariable* current_param = MakeTemporary("current_param"); // Read-only.
// One read-only local variable on stack (param) to drop after joining.
diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc
index 0db035c..182ae35 100644
--- a/runtime/vm/compiler/runtime_api.cc
+++ b/runtime/vm/compiler/runtime_api.cc
@@ -473,8 +473,9 @@
switch (cid) {
case kArrayCid:
case kImmutableArrayCid:
- case kTypeArgumentsCid:
return kWordSize;
+ case kTypeArgumentsCid:
+ return kCompressedWordSize;
case kOneByteStringCid:
return dart::OneByteString::kBytesPerElement;
case kTwoByteStringCid:
diff --git a/runtime/vm/compiler/runtime_api.h b/runtime/vm/compiler/runtime_api.h
index de71523..519bf31 100644
--- a/runtime/vm/compiler/runtime_api.h
+++ b/runtime/vm/compiler/runtime_api.h
@@ -297,6 +297,12 @@
static constexpr word kBitsPerWordLog2 = kWordSizeLog2 + kBitsPerByteLog2;
static constexpr word kBitsPerWord = 1 << kBitsPerWordLog2;
+#if !defined(DART_COMPRESSED_POINTERS)
+static constexpr int kCompressedWordSize = kWordSize;
+#else
+static constexpr int kCompressedWordSize = sizeof(uint32_t);
+#endif
+
using ObjectAlignment = dart::ObjectAlignment<kWordSize, kWordSizeLog2>;
constexpr word kWordMax = (static_cast<uword>(1) << (kBitsPerWord - 1)) - 1;
diff --git a/runtime/vm/compiler/runtime_offsets_extracted.h b/runtime/vm/compiler/runtime_offsets_extracted.h
index 1337ee3..74b682a 100644
--- a/runtime/vm/compiler/runtime_offsets_extracted.h
+++ b/runtime/vm/compiler/runtime_offsets_extracted.h
@@ -2221,7 +2221,7 @@
SubtypeTestCache_kTestEntryLength = 8;
static constexpr dart::compiler::target::word SubtypeTestCache_kTestResult = 0;
static constexpr dart::compiler::target::word TypeArguments_kMaxElements =
- 134217727;
+ 268435455;
static constexpr dart::compiler::target::word
AbstractType_type_test_stub_entry_point_offset = 8;
static constexpr dart::compiler::target::word ArgumentsDescriptor_count_offset =
@@ -2569,10 +2569,10 @@
43;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
-static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
+static constexpr dart::compiler::target::word TypeArguments_length_offset = 12;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
- 32;
-static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
+ 20;
+static constexpr dart::compiler::target::word TypeArguments_types_offset = 24;
static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
@@ -2598,8 +2598,8 @@
static constexpr dart::compiler::target::word Array_elements_start_offset = 24;
static constexpr dart::compiler::target::word Array_element_size = 8;
static constexpr dart::compiler::target::word
- TypeArguments_elements_start_offset = 40;
-static constexpr dart::compiler::target::word TypeArguments_element_size = 8;
+ TypeArguments_elements_start_offset = 24;
+static constexpr dart::compiler::target::word TypeArguments_element_size = 4;
static constexpr dart::compiler::target::word ClassTable_elements_start_offset =
0;
static constexpr dart::compiler::target::word ClassTable_element_size = 1;
@@ -2694,7 +2694,7 @@
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word TwoByteString_InstanceSize = 16;
static constexpr dart::compiler::target::word Type_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 24;
static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_InstanceSize = 24;
@@ -2762,7 +2762,7 @@
SubtypeTestCache_kTestEntryLength = 8;
static constexpr dart::compiler::target::word SubtypeTestCache_kTestResult = 0;
static constexpr dart::compiler::target::word TypeArguments_kMaxElements =
- 134217727;
+ 268435455;
static constexpr dart::compiler::target::word
AbstractType_type_test_stub_entry_point_offset = 8;
static constexpr dart::compiler::target::word ArgumentsDescriptor_count_offset =
@@ -3110,10 +3110,10 @@
43;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
-static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
+static constexpr dart::compiler::target::word TypeArguments_length_offset = 12;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
- 32;
-static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
+ 20;
+static constexpr dart::compiler::target::word TypeArguments_types_offset = 24;
static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
@@ -3139,8 +3139,8 @@
static constexpr dart::compiler::target::word Array_elements_start_offset = 24;
static constexpr dart::compiler::target::word Array_element_size = 8;
static constexpr dart::compiler::target::word
- TypeArguments_elements_start_offset = 40;
-static constexpr dart::compiler::target::word TypeArguments_element_size = 8;
+ TypeArguments_elements_start_offset = 24;
+static constexpr dart::compiler::target::word TypeArguments_element_size = 4;
static constexpr dart::compiler::target::word ClassTable_elements_start_offset =
0;
static constexpr dart::compiler::target::word ClassTable_element_size = 1;
@@ -3236,7 +3236,7 @@
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word TwoByteString_InstanceSize = 16;
static constexpr dart::compiler::target::word Type_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 24;
static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_InstanceSize = 24;
@@ -5434,7 +5434,7 @@
SubtypeTestCache_kTestEntryLength = 8;
static constexpr dart::compiler::target::word SubtypeTestCache_kTestResult = 0;
static constexpr dart::compiler::target::word TypeArguments_kMaxElements =
- 134217727;
+ 268435455;
static constexpr dart::compiler::target::word
AbstractType_type_test_stub_entry_point_offset = 8;
static constexpr dart::compiler::target::word ArgumentsDescriptor_count_offset =
@@ -5779,10 +5779,10 @@
43;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
-static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
+static constexpr dart::compiler::target::word TypeArguments_length_offset = 12;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
- 32;
-static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
+ 20;
+static constexpr dart::compiler::target::word TypeArguments_types_offset = 24;
static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
@@ -5808,8 +5808,8 @@
static constexpr dart::compiler::target::word Array_elements_start_offset = 24;
static constexpr dart::compiler::target::word Array_element_size = 8;
static constexpr dart::compiler::target::word
- TypeArguments_elements_start_offset = 40;
-static constexpr dart::compiler::target::word TypeArguments_element_size = 8;
+ TypeArguments_elements_start_offset = 24;
+static constexpr dart::compiler::target::word TypeArguments_element_size = 4;
static constexpr dart::compiler::target::word Code_entry_point_offset[] = {
8, 24, 16, 32};
static constexpr dart::compiler::target::word
@@ -5901,7 +5901,7 @@
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word TwoByteString_InstanceSize = 16;
static constexpr dart::compiler::target::word Type_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 24;
static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_InstanceSize = 24;
@@ -5969,7 +5969,7 @@
SubtypeTestCache_kTestEntryLength = 8;
static constexpr dart::compiler::target::word SubtypeTestCache_kTestResult = 0;
static constexpr dart::compiler::target::word TypeArguments_kMaxElements =
- 134217727;
+ 268435455;
static constexpr dart::compiler::target::word
AbstractType_type_test_stub_entry_point_offset = 8;
static constexpr dart::compiler::target::word ArgumentsDescriptor_count_offset =
@@ -6314,10 +6314,10 @@
43;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
-static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
+static constexpr dart::compiler::target::word TypeArguments_length_offset = 12;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
- 32;
-static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
+ 20;
+static constexpr dart::compiler::target::word TypeArguments_types_offset = 24;
static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
@@ -6343,8 +6343,8 @@
static constexpr dart::compiler::target::word Array_elements_start_offset = 24;
static constexpr dart::compiler::target::word Array_element_size = 8;
static constexpr dart::compiler::target::word
- TypeArguments_elements_start_offset = 40;
-static constexpr dart::compiler::target::word TypeArguments_element_size = 8;
+ TypeArguments_elements_start_offset = 24;
+static constexpr dart::compiler::target::word TypeArguments_element_size = 4;
static constexpr dart::compiler::target::word Code_entry_point_offset[] = {
8, 24, 16, 32};
static constexpr dart::compiler::target::word
@@ -6437,7 +6437,7 @@
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word TwoByteString_InstanceSize = 16;
static constexpr dart::compiler::target::word Type_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 24;
static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_InstanceSize = 24;
@@ -8310,7 +8310,7 @@
static constexpr dart::compiler::target::word AOT_SubtypeTestCache_kTestResult =
0;
static constexpr dart::compiler::target::word AOT_TypeArguments_kMaxElements =
- 134217727;
+ 268435455;
static constexpr dart::compiler::target::word
AOT_AbstractType_type_test_stub_entry_point_offset = 8;
static constexpr dart::compiler::target::word
@@ -8690,11 +8690,11 @@
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
- 16;
+ 12;
static constexpr dart::compiler::target::word
- AOT_TypeArguments_nullability_offset = 32;
+ AOT_TypeArguments_nullability_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
28;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
@@ -8727,9 +8727,9 @@
24;
static constexpr dart::compiler::target::word AOT_Array_element_size = 8;
static constexpr dart::compiler::target::word
- AOT_TypeArguments_elements_start_offset = 40;
+ AOT_TypeArguments_elements_start_offset = 24;
static constexpr dart::compiler::target::word AOT_TypeArguments_element_size =
- 8;
+ 4;
static constexpr dart::compiler::target::word
AOT_ClassTable_elements_start_offset = 0;
static constexpr dart::compiler::target::word AOT_ClassTable_element_size = 1;
@@ -8836,7 +8836,7 @@
16;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeArguments_InstanceSize =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
48;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
@@ -8910,7 +8910,7 @@
static constexpr dart::compiler::target::word AOT_SubtypeTestCache_kTestResult =
0;
static constexpr dart::compiler::target::word AOT_TypeArguments_kMaxElements =
- 134217727;
+ 268435455;
static constexpr dart::compiler::target::word
AOT_AbstractType_type_test_stub_entry_point_offset = 8;
static constexpr dart::compiler::target::word
@@ -9290,11 +9290,11 @@
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
- 16;
+ 12;
static constexpr dart::compiler::target::word
- AOT_TypeArguments_nullability_offset = 32;
+ AOT_TypeArguments_nullability_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
28;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
@@ -9327,9 +9327,9 @@
24;
static constexpr dart::compiler::target::word AOT_Array_element_size = 8;
static constexpr dart::compiler::target::word
- AOT_TypeArguments_elements_start_offset = 40;
+ AOT_TypeArguments_elements_start_offset = 24;
static constexpr dart::compiler::target::word AOT_TypeArguments_element_size =
- 8;
+ 4;
static constexpr dart::compiler::target::word
AOT_ClassTable_elements_start_offset = 0;
static constexpr dart::compiler::target::word AOT_ClassTable_element_size = 1;
@@ -9437,7 +9437,7 @@
16;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeArguments_InstanceSize =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
48;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
@@ -11292,7 +11292,7 @@
static constexpr dart::compiler::target::word AOT_SubtypeTestCache_kTestResult =
0;
static constexpr dart::compiler::target::word AOT_TypeArguments_kMaxElements =
- 134217727;
+ 268435455;
static constexpr dart::compiler::target::word
AOT_AbstractType_type_test_stub_entry_point_offset = 8;
static constexpr dart::compiler::target::word
@@ -11668,11 +11668,11 @@
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
- 16;
+ 12;
static constexpr dart::compiler::target::word
- AOT_TypeArguments_nullability_offset = 32;
+ AOT_TypeArguments_nullability_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
28;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
@@ -11705,9 +11705,9 @@
24;
static constexpr dart::compiler::target::word AOT_Array_element_size = 8;
static constexpr dart::compiler::target::word
- AOT_TypeArguments_elements_start_offset = 40;
+ AOT_TypeArguments_elements_start_offset = 24;
static constexpr dart::compiler::target::word AOT_TypeArguments_element_size =
- 8;
+ 4;
static constexpr dart::compiler::target::word AOT_Code_entry_point_offset[] = {
8, 24, 16, 32};
static constexpr dart::compiler::target::word
@@ -11811,7 +11811,7 @@
16;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeArguments_InstanceSize =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
48;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
@@ -11885,7 +11885,7 @@
static constexpr dart::compiler::target::word AOT_SubtypeTestCache_kTestResult =
0;
static constexpr dart::compiler::target::word AOT_TypeArguments_kMaxElements =
- 134217727;
+ 268435455;
static constexpr dart::compiler::target::word
AOT_AbstractType_type_test_stub_entry_point_offset = 8;
static constexpr dart::compiler::target::word
@@ -12261,11 +12261,11 @@
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
- 16;
+ 12;
static constexpr dart::compiler::target::word
- AOT_TypeArguments_nullability_offset = 32;
+ AOT_TypeArguments_nullability_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
28;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
@@ -12298,9 +12298,9 @@
24;
static constexpr dart::compiler::target::word AOT_Array_element_size = 8;
static constexpr dart::compiler::target::word
- AOT_TypeArguments_elements_start_offset = 40;
+ AOT_TypeArguments_elements_start_offset = 24;
static constexpr dart::compiler::target::word AOT_TypeArguments_element_size =
- 8;
+ 4;
static constexpr dart::compiler::target::word AOT_Code_entry_point_offset[] = {
8, 24, 16, 32};
static constexpr dart::compiler::target::word
@@ -12405,7 +12405,7 @@
16;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeArguments_InstanceSize =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
48;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
diff --git a/runtime/vm/compiler/stub_code_compiler.cc b/runtime/vm/compiler/stub_code_compiler.cc
index 0058e1a..604aeaa 100644
--- a/runtime/vm/compiler/stub_code_compiler.cc
+++ b/runtime/vm/compiler/stub_code_compiler.cc
@@ -358,7 +358,7 @@
__ CompareObject(scratch2_reg, Object::null_object());
// If the arguments are null, then unwrapping gives dynamic, a top type.
__ BranchIf(EQUAL, &is_top_type, compiler::Assembler::kNearJump);
- __ LoadField(
+ __ LoadCompressedField(
scratch1_reg,
compiler::FieldAddress(
scratch2_reg, compiler::target::TypeArguments::type_at_offset(0)));
@@ -457,7 +457,7 @@
// If the arguments are null, then unwrapping gives the dynamic type,
// which can take null.
__ BranchIf(EQUAL, &is_assignable);
- __ LoadField(
+ __ LoadCompressedField(
kCurrentTypeReg,
compiler::FieldAddress(
kScratchReg, compiler::target::TypeArguments::type_at_offset(0)));
@@ -483,9 +483,9 @@
// Resolve the type parameter to its instantiated type and loop.
__ LoadFieldFromOffset(kIndexReg, kCurrentTypeReg,
target::TypeParameter::index_offset(), kTwoBytes);
- __ LoadIndexedPayload(kCurrentTypeReg, tav,
- target::TypeArguments::types_offset(), kIndexReg,
- TIMES_WORD_SIZE);
+ __ LoadIndexedCompressed(kCurrentTypeReg, tav,
+ target::TypeArguments::types_offset(),
+ kIndexReg);
__ Jump(&check_null_assignable);
};
@@ -598,9 +598,9 @@
// instantiated type's TTS.
__ LoadFieldFromOffset(TypeTestABI::kScratchReg, TypeTestABI::kDstTypeReg,
target::TypeParameter::index_offset(), kTwoBytes);
- __ LoadIndexedPayload(TypeTestABI::kScratchReg, tav,
- target::TypeArguments::types_offset(),
- TypeTestABI::kScratchReg, TIMES_WORD_SIZE);
+ __ LoadIndexedCompressed(TypeTestABI::kScratchReg, tav,
+ target::TypeArguments::types_offset(),
+ TypeTestABI::kScratchReg);
__ Jump(FieldAddress(
TypeTestABI::kScratchReg,
target::AbstractType::type_test_stub_entry_point_offset()));
diff --git a/runtime/vm/compiler/stub_code_compiler_arm64.cc b/runtime/vm/compiler/stub_code_compiler_arm64.cc
index 0d7cacc..c3492c4 100644
--- a/runtime/vm/compiler/stub_code_compiler_arm64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_arm64.cc
@@ -3459,8 +3459,9 @@
void StubCodeCompiler::GenerateInstantiateTypeArgumentsStub(
Assembler* assembler) {
// Lookup cache before calling runtime.
- __ LoadFieldFromOffset(R0, InstantiationABI::kUninstantiatedTypeArgumentsReg,
- target::TypeArguments::instantiations_offset());
+ __ LoadCompressedFieldFromOffset(
+ R0, InstantiationABI::kUninstantiatedTypeArgumentsReg,
+ target::TypeArguments::instantiations_offset());
__ AddImmediate(R0, Array::data_offset() - kHeapObjectTag);
// The instantiations cache is initialized with Object::zero_array() and is
// therefore guaranteed to contain kNoInstantiator. No length check needed.
@@ -3513,10 +3514,12 @@
// Return the instantiator type arguments if its nullability is compatible for
// sharing, otherwise proceed to instantiation cache lookup.
compiler::Label cache_lookup;
- __ LoadFieldFromOffset(R0, InstantiationABI::kUninstantiatedTypeArgumentsReg,
- target::TypeArguments::nullability_offset());
- __ LoadFieldFromOffset(R4, InstantiationABI::kInstantiatorTypeArgumentsReg,
- target::TypeArguments::nullability_offset());
+ __ LoadCompressedSmi(
+ R0, FieldAddress(InstantiationABI::kUninstantiatedTypeArgumentsReg,
+ target::TypeArguments::nullability_offset()));
+ __ LoadCompressedSmi(
+ R4, FieldAddress(InstantiationABI::kInstantiatorTypeArgumentsReg,
+ target::TypeArguments::nullability_offset()));
__ and_(R4, R4, Operand(R0));
__ cmp(R4, Operand(R0));
__ b(&cache_lookup, NE);
@@ -3533,10 +3536,12 @@
// Return the function type arguments if its nullability is compatible for
// sharing, otherwise proceed to instantiation cache lookup.
compiler::Label cache_lookup;
- __ LoadFieldFromOffset(R0, InstantiationABI::kUninstantiatedTypeArgumentsReg,
- target::TypeArguments::nullability_offset());
- __ LoadFieldFromOffset(R4, InstantiationABI::kFunctionTypeArgumentsReg,
- target::TypeArguments::nullability_offset());
+ __ LoadCompressedSmi(
+ R0, FieldAddress(InstantiationABI::kUninstantiatedTypeArgumentsReg,
+ target::TypeArguments::nullability_offset()));
+ __ LoadCompressedSmi(
+ R4, FieldAddress(InstantiationABI::kFunctionTypeArgumentsReg,
+ target::TypeArguments::nullability_offset()));
__ and_(R4, R4, Operand(R0));
__ cmp(R4, Operand(R0));
__ b(&cache_lookup, NE);
diff --git a/runtime/vm/compiler/stub_code_compiler_x64.cc b/runtime/vm/compiler/stub_code_compiler_x64.cc
index 611e083..d6b0a51 100644
--- a/runtime/vm/compiler/stub_code_compiler_x64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_x64.cc
@@ -3388,9 +3388,9 @@
void StubCodeCompiler::GenerateInstantiateTypeArgumentsStub(
Assembler* assembler) {
// Lookup cache before calling runtime.
- __ movq(RAX, compiler::FieldAddress(
- InstantiationABI::kUninstantiatedTypeArgumentsReg,
- target::TypeArguments::instantiations_offset()));
+ __ LoadCompressed(RAX, compiler::FieldAddress(
+ InstantiationABI::kUninstantiatedTypeArgumentsReg,
+ target::TypeArguments::instantiations_offset()));
__ leaq(RAX, compiler::FieldAddress(RAX, Array::data_offset()));
// The instantiations cache is initialized with Object::zero_array() and is
@@ -3446,12 +3446,13 @@
// Return the instantiator type arguments if its nullability is compatible for
// sharing, otherwise proceed to instantiation cache lookup.
compiler::Label cache_lookup;
- __ movq(RAX, compiler::FieldAddress(
- InstantiationABI::kUninstantiatedTypeArgumentsReg,
- target::TypeArguments::nullability_offset()));
- __ movq(RDI, compiler::FieldAddress(
- InstantiationABI::kInstantiatorTypeArgumentsReg,
- target::TypeArguments::nullability_offset()));
+ __ LoadCompressedSmi(
+ RAX,
+ compiler::FieldAddress(InstantiationABI::kUninstantiatedTypeArgumentsReg,
+ target::TypeArguments::nullability_offset()));
+ __ LoadCompressedSmi(RDI, compiler::FieldAddress(
+ InstantiationABI::kInstantiatorTypeArgumentsReg,
+ target::TypeArguments::nullability_offset()));
__ andq(RDI, RAX);
__ cmpq(RDI, RAX);
__ j(NOT_EQUAL, &cache_lookup, compiler::Assembler::kNearJump);
@@ -3468,12 +3469,13 @@
// Return the function type arguments if its nullability is compatible for
// sharing, otherwise proceed to instantiation cache lookup.
compiler::Label cache_lookup;
- __ movq(RAX, compiler::FieldAddress(
- InstantiationABI::kUninstantiatedTypeArgumentsReg,
- target::TypeArguments::nullability_offset()));
- __ movq(RDI,
- compiler::FieldAddress(InstantiationABI::kFunctionTypeArgumentsReg,
- target::TypeArguments::nullability_offset()));
+ __ LoadCompressedSmi(
+ RAX,
+ compiler::FieldAddress(InstantiationABI::kUninstantiatedTypeArgumentsReg,
+ target::TypeArguments::nullability_offset()));
+ __ LoadCompressedSmi(
+ RDI, compiler::FieldAddress(InstantiationABI::kFunctionTypeArgumentsReg,
+ target::TypeArguments::nullability_offset()));
__ andq(RDI, RAX);
__ cmpq(RDI, RAX);
__ j(NOT_EQUAL, &cache_lookup, compiler::Assembler::kNearJump);
diff --git a/runtime/vm/constants_arm.h b/runtime/vm/constants_arm.h
index be35d85..9bb97a5 100644
--- a/runtime/vm/constants_arm.h
+++ b/runtime/vm/constants_arm.h
@@ -760,6 +760,11 @@
#else
#error "Unexpected word size"
#endif
+#if !defined(DART_COMPRESSED_POINTERS)
+ TIMES_COMPRESSED_WORD_SIZE = TIMES_WORD_SIZE,
+#else
+#error Cannot compress ARM32
+#endif
};
// The class Instr enables access to individual fields defined in the ARM
diff --git a/runtime/vm/constants_arm64.h b/runtime/vm/constants_arm64.h
index cf35be9..0ce8f19 100644
--- a/runtime/vm/constants_arm64.h
+++ b/runtime/vm/constants_arm64.h
@@ -1112,6 +1112,11 @@
#else
#error "Unexpected word size"
#endif
+#if !defined(DART_COMPRESSED_POINTERS)
+ TIMES_COMPRESSED_WORD_SIZE = TIMES_WORD_SIZE,
+#else
+ TIMES_COMPRESSED_WORD_SIZE = TIMES_HALF_WORD_SIZE,
+#endif
};
// The class Instr enables access to individual fields defined in the ARM
diff --git a/runtime/vm/constants_ia32.h b/runtime/vm/constants_ia32.h
index 33096bb..1e95ec1 100644
--- a/runtime/vm/constants_ia32.h
+++ b/runtime/vm/constants_ia32.h
@@ -236,6 +236,11 @@
#else
#error "Unexpected word size"
#endif
+#if !defined(DART_COMPRESSED_POINTERS)
+ TIMES_COMPRESSED_WORD_SIZE = TIMES_WORD_SIZE,
+#else
+#error Cannot compress IA32
+#endif
};
class Instr {
diff --git a/runtime/vm/constants_x64.h b/runtime/vm/constants_x64.h
index ac85998..f2ae0ad 100644
--- a/runtime/vm/constants_x64.h
+++ b/runtime/vm/constants_x64.h
@@ -318,6 +318,11 @@
#else
#error "Unexpected word size"
#endif
+#if !defined(DART_COMPRESSED_POINTERS)
+ TIMES_COMPRESSED_WORD_SIZE = TIMES_WORD_SIZE,
+#else
+ TIMES_COMPRESSED_WORD_SIZE = TIMES_HALF_WORD_SIZE,
+#endif
};
#define R(reg) (1 << (reg))
diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc
index cfa5e5e..9fc8ea7 100644
--- a/runtime/vm/debugger.cc
+++ b/runtime/vm/debugger.cc
@@ -57,15 +57,16 @@
#ifndef PRODUCT
// Create an unresolved breakpoint in given token range and script.
-BreakpointLocation::BreakpointLocation(Debugger* debugger,
- const Script& script,
- TokenPosition token_pos,
- TokenPosition end_token_pos,
- intptr_t requested_line_number,
- intptr_t requested_column_number)
+BreakpointLocation::BreakpointLocation(
+ Debugger* debugger,
+ const GrowableHandlePtrArray<const Script>& scripts,
+ TokenPosition token_pos,
+ TokenPosition end_token_pos,
+ intptr_t requested_line_number,
+ intptr_t requested_column_number)
: debugger_(debugger),
- script_(script.ptr()),
- url_(script.url()),
+ scripts_(MallocGrowableArray<ScriptPtr>(scripts.length())),
+ url_(scripts.At(0).url()),
line_number_lock_(new SafepointRwLock()),
line_number_(-1), // lazily computed
token_pos_(token_pos),
@@ -75,8 +76,11 @@
requested_line_number_(requested_line_number),
requested_column_number_(requested_column_number),
code_token_pos_(TokenPosition::kNoSource) {
- ASSERT(!script.IsNull());
+ ASSERT(scripts.length() > 0);
ASSERT(token_pos_.IsReal());
+ for (intptr_t i = 0; i < scripts.length(); ++i) {
+ scripts_.Add(scripts.At(i).ptr());
+ }
}
// Create a latent breakpoint at given url and line number.
@@ -85,7 +89,7 @@
intptr_t requested_line_number,
intptr_t requested_column_number)
: debugger_(debugger),
- script_(Script::null()),
+ scripts_(MallocGrowableArray<ScriptPtr>(0)),
url_(url.ptr()),
line_number_lock_(new SafepointRwLock()),
line_number_(-1), // lazily computed
@@ -121,8 +125,13 @@
void BreakpointLocation::SetResolved(const Function& func,
TokenPosition token_pos) {
+#if defined(DEBUG)
+ const Script& func_script = Script::Handle(func.script());
+ const String& func_url = String::Handle(func_script.url());
+ const String& script_url = String::Handle(url_);
+ ASSERT(script_url.Equals(func_url));
+#endif // defined(DEBUG)
ASSERT(!IsLatent());
- ASSERT(func.script() == script_);
ASSERT(token_pos.IsWithin(func.token_pos(), func.end_token_pos()));
ASSERT(func.is_debuggable());
token_pos_ = token_pos;
@@ -167,7 +176,9 @@
}
void BreakpointLocation::VisitObjectPointers(ObjectPointerVisitor* visitor) {
- visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&script_));
+ for (intptr_t i = 0; i < scripts_.length(); ++i) {
+ visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&scripts_.data()[i]));
+ }
visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&url_));
Breakpoint* bpt = conditions_;
@@ -209,8 +220,7 @@
BufferFormatter f(buffer, sizeof(buffer));
// Pick the first, all other should have same script/line number.
BreakpointLocation* breakpoint_location = breakpoint_locations_.At(0);
- Script& script = Script::Handle(breakpoint_location->script());
- String& source_url = String::Handle(script.url());
+ String& source_url = String::Handle(breakpoint_location->url());
intptr_t line_number = breakpoint_location->line_number();
f.Printf("breakpoint at %s:%" Pd, source_url.ToCString(), line_number);
@@ -435,14 +445,16 @@
// Returns true if the function |func| overlaps the token range
// [|token_pos|, |end_token_pos|] in |script|.
static bool FunctionOverlaps(const Function& func,
- const Script& script,
+ const String& script_url,
TokenPosition token_pos,
TokenPosition end_token_pos) {
const TokenPosition& func_start = func.token_pos();
if (token_pos.IsWithin(func_start, func.end_token_pos()) ||
func_start.IsWithin(token_pos, end_token_pos)) {
// Check script equality last because it allocates handles as a side effect.
- return func.script() == script.ptr();
+ Script& func_script = Script::Handle(func.script());
+ String& url = String::Handle(func_script.url());
+ return script_url.Equals(url);
}
return false;
}
@@ -776,8 +788,9 @@
// Detect circles in the exception handler data.
num_handlers_checked++;
ASSERT(num_handlers_checked <= handlers.num_entries());
- // Only consider user written handlers for async methods.
- if (!is_async || !handlers.IsGenerated(try_index)) {
+ // Only consider user written handlers and ignore synthesized try/catch in
+ // async methods as well as synthetic try/catch hiding inside try/finally.
+ if (!handlers.IsGenerated(try_index)) {
handled_types = handlers.GetHandledTypes(try_index);
const intptr_t num_types = handled_types.Length();
for (intptr_t k = 0; k < num_types; k++) {
@@ -2587,67 +2600,72 @@
}
void Debugger::FindCompiledFunctions(
- const Script& script,
+ const GrowableHandlePtrArray<const Script>& scripts,
TokenPosition start_pos,
TokenPosition end_pos,
GrowableObjectArray* code_function_list) {
auto thread = Thread::Current();
auto zone = thread->zone();
-
- ClosureFunctionsCache::ForAllClosureFunctions([&](const Function& function) {
- ASSERT(!function.IsNull());
- if ((function.token_pos() == start_pos) &&
- (function.end_token_pos() == end_pos) &&
- (function.script() == script.ptr())) {
- if (function.is_debuggable() && function.HasCode()) {
- code_function_list->Add(function);
- }
- ASSERT(!function.HasImplicitClosureFunction());
- }
- return true; // Continue iteration.
- });
-
- Class& cls = Class::Handle(zone);
- Function& function = Function::Handle(zone);
- Array& functions = Array::Handle(zone);
-
- const ClassTable& class_table = *isolate_->group()->class_table();
- const intptr_t num_classes = class_table.NumCids();
- const intptr_t num_tlc_classes = class_table.NumTopLevelCids();
- for (intptr_t i = 1; i < num_classes + num_tlc_classes; i++) {
- const classid_t cid =
- i < num_classes ? i : ClassTable::CidFromTopLevelIndex(i - num_classes);
- if (class_table.HasValidClassAt(cid)) {
- cls = class_table.At(cid);
- // If the class is not finalized, e.g. if it hasn't been parsed
- // yet entirely, we can ignore it. If it contains a function with
- // an unresolved breakpoint, we will detect it if and when the
- // function gets compiled.
- if (!cls.is_finalized()) {
- continue;
- }
- // Note: we need to check the functions of this class even if
- // the class is defined in a different 'script'. There could
- // be mixin functions from the given script in this class.
- functions = cls.current_functions();
- if (!functions.IsNull()) {
- const intptr_t num_functions = functions.Length();
- for (intptr_t pos = 0; pos < num_functions; pos++) {
- function ^= functions.At(pos);
+ Script& script = Script::Handle(zone);
+ for (intptr_t i = 0; i < scripts.length(); ++i) {
+ script = scripts.At(i).ptr();
+ ClosureFunctionsCache::ForAllClosureFunctions(
+ [&](const Function& function) {
ASSERT(!function.IsNull());
- bool function_added = false;
- if (function.is_debuggable() && function.HasCode() &&
- function.token_pos() == start_pos &&
- function.end_token_pos() == end_pos &&
- function.script() == script.ptr()) {
- code_function_list->Add(function);
- function_added = true;
- }
- if (function_added && function.HasImplicitClosureFunction()) {
- function = function.ImplicitClosureFunction();
+ if ((function.token_pos() == start_pos) &&
+ (function.end_token_pos() == end_pos) &&
+ (function.script() == script.ptr())) {
if (function.is_debuggable() && function.HasCode()) {
code_function_list->Add(function);
}
+ ASSERT(!function.HasImplicitClosureFunction());
+ }
+ return true; // Continue iteration.
+ });
+
+ Class& cls = Class::Handle(zone);
+ Function& function = Function::Handle(zone);
+ Array& functions = Array::Handle(zone);
+
+ const ClassTable& class_table = *isolate_->group()->class_table();
+ const intptr_t num_classes = class_table.NumCids();
+ const intptr_t num_tlc_classes = class_table.NumTopLevelCids();
+ for (intptr_t i = 1; i < num_classes + num_tlc_classes; i++) {
+ const classid_t cid =
+ i < num_classes ? i
+ : ClassTable::CidFromTopLevelIndex(i - num_classes);
+ if (class_table.HasValidClassAt(cid)) {
+ cls = class_table.At(cid);
+ // If the class is not finalized, e.g. if it hasn't been parsed
+ // yet entirely, we can ignore it. If it contains a function with
+ // an unresolved breakpoint, we will detect it if and when the
+ // function gets compiled.
+ if (!cls.is_finalized()) {
+ continue;
+ }
+ // Note: we need to check the functions of this class even if
+ // the class is defined in a different 'script'. There could
+ // be mixin functions from the given script in this class.
+ functions = cls.current_functions();
+ if (!functions.IsNull()) {
+ const intptr_t num_functions = functions.Length();
+ for (intptr_t pos = 0; pos < num_functions; pos++) {
+ function ^= functions.At(pos);
+ ASSERT(!function.IsNull());
+ bool function_added = false;
+ if (function.is_debuggable() && function.HasCode() &&
+ function.token_pos() == start_pos &&
+ function.end_token_pos() == end_pos &&
+ function.script() == script.ptr()) {
+ code_function_list->Add(function);
+ function_added = true;
+ }
+ if (function_added && function.HasImplicitClosureFunction()) {
+ function = function.ImplicitClosureFunction();
+ if (function.is_debuggable() && function.HasCode()) {
+ code_function_list->Add(function);
+ }
+ }
}
}
}
@@ -2710,8 +2728,9 @@
continue;
}
+ const String& script_url = String::Handle(zone, script.url());
ClosureFunctionsCache::ForAllClosureFunctions([&](const Function& fun) {
- if (FunctionOverlaps(fun, script, token_pos, last_token_pos)) {
+ if (FunctionOverlaps(fun, script_url, token_pos, last_token_pos)) {
// Select the inner most closure.
UpdateBestFit(best_fit, fun);
}
@@ -2767,7 +2786,8 @@
// location.
continue;
}
- if (FunctionOverlaps(function, script, token_pos, last_token_pos)) {
+ if (FunctionOverlaps(function, script_url, token_pos,
+ last_token_pos)) {
// Closures and inner functions within a class method are not
// present in the functions of a class. Hence, we can return
// right away as looking through other functions of a class
@@ -2812,7 +2832,7 @@
}
BreakpointLocation* Debugger::SetCodeBreakpoints(
- const Script& script,
+ const GrowableHandlePtrArray<const Script>& scripts,
TokenPosition token_pos,
TokenPosition last_token_pos,
intptr_t requested_line,
@@ -2826,15 +2846,16 @@
if (!breakpoint_pos.IsReal()) {
return nullptr;
}
+ const String& script_url = String::Handle(scripts.At(0).url());
BreakpointLocation* loc =
- GetResolvedBreakpointLocation(script, breakpoint_pos);
+ GetResolvedBreakpointLocation(script_url, breakpoint_pos);
if (loc == nullptr) {
// Find an existing unresolved breakpoint location.
- loc = GetBreakpointLocation(script, token_pos, requested_line,
+ loc = GetBreakpointLocation(script_url, token_pos, requested_line,
requested_column);
}
- if (loc == NULL) {
- loc = new BreakpointLocation(this, script, breakpoint_pos, breakpoint_pos,
+ if (loc == nullptr) {
+ loc = new BreakpointLocation(this, scripts, breakpoint_pos, breakpoint_pos,
requested_line, requested_column);
RegisterBreakpointLocation(loc);
}
@@ -2856,7 +2877,8 @@
if (FLAG_verbose_debug) {
intptr_t line_number = -1;
intptr_t column_number = -1;
- script.GetTokenLocation(breakpoint_pos, &line_number, &column_number);
+ scripts.At(0).GetTokenLocation(breakpoint_pos, &line_number,
+ &column_number);
OS::PrintErr("Resolved code breakpoint for function '%s' at line %" Pd
" col %" Pd "\n",
func.ToFullyQualifiedCString(), line_number, column_number);
@@ -2876,7 +2898,21 @@
intptr_t requested_line,
intptr_t requested_column,
const Function& function) {
+ GrowableHandlePtrArray<const Script> scripts(Thread::Current()->zone(), 1);
+ scripts.Add(script);
+ return SetBreakpoint(scripts, token_pos, last_token_pos, requested_line,
+ requested_column, function);
+}
+
+BreakpointLocation* Debugger::SetBreakpoint(
+ const GrowableHandlePtrArray<const Script>& scripts,
+ TokenPosition token_pos,
+ TokenPosition last_token_pos,
+ intptr_t requested_line,
+ intptr_t requested_column,
+ const Function& function) {
Function& func = Function::Handle();
+ const Script& script = scripts.At(0);
if (function.IsNull()) {
if (!FindBestFit(script, token_pos, last_token_pos, &func)) {
return NULL;
@@ -2896,7 +2932,7 @@
// function we found.
GrowableObjectArray& code_functions =
GrowableObjectArray::Handle(GrowableObjectArray::New());
- FindCompiledFunctions(script, func.token_pos(), func.end_token_pos(),
+ FindCompiledFunctions(scripts, func.token_pos(), func.end_token_pos(),
&code_functions);
if (code_functions.Length() > 0) {
@@ -2913,7 +2949,7 @@
}
DeoptimizeWorld();
BreakpointLocation* loc =
- SetCodeBreakpoints(script, token_pos, last_token_pos, requested_line,
+ SetCodeBreakpoints(scripts, token_pos, last_token_pos, requested_line,
requested_column, exact_token_pos, code_functions);
if (loc != NULL) {
return loc;
@@ -2939,10 +2975,11 @@
func.ToFullyQualifiedCString(), line_number, column_number);
}
}
+ const String& script_url = String::Handle(script.url());
BreakpointLocation* loc =
- GetBreakpointLocation(script, token_pos, -1, requested_column);
+ GetBreakpointLocation(script_url, token_pos, -1, requested_column);
if (loc == NULL) {
- loc = new BreakpointLocation(this, script, token_pos, last_token_pos,
+ loc = new BreakpointLocation(this, scripts, token_pos, last_token_pos,
requested_line, requested_column);
RegisterBreakpointLocation(loc);
}
@@ -3074,7 +3111,7 @@
intptr_t column_number) {
Zone* zone = Thread::Current()->zone();
Library& lib = Library::Handle(zone);
- Script& script = Script::Handle(zone);
+ GrowableHandlePtrArray<const Script> scripts(zone, 1);
const GrowableObjectArray& libs = GrowableObjectArray::Handle(
isolate_->group()->object_store()->libraries());
bool is_package = script_url.StartsWith(Symbols::PackageScheme());
@@ -3087,18 +3124,10 @@
lib.EnsureTopLevelClassIsFinalized();
script_for_lib = lib.LookupScript(script_url, !is_package);
if (!script_for_lib.IsNull()) {
- if (script.IsNull()) {
- script = script_for_lib.ptr();
- } else if (script.ptr() != script_for_lib.ptr()) {
- if (FLAG_verbose_debug) {
- OS::PrintErr("Multiple scripts match url '%s'\n",
- script_url.ToCString());
- }
- return NULL;
- }
+ scripts.Add(script_for_lib);
}
}
- if (script.IsNull()) {
+ if (scripts.length() == 0) {
// No script found with given url. Create a latent breakpoint which
// will be set if the url is loaded later.
BreakpointLocation* latent_bpt =
@@ -3113,7 +3142,9 @@
}
TokenPosition first_token_idx = TokenPosition::kNoSource;
TokenPosition last_token_idx = TokenPosition::kNoSource;
- script.TokenRangeAtLine(line_number, &first_token_idx, &last_token_idx);
+ // Assume all scripts with the same URL have the same token positions.
+ scripts.At(0).TokenRangeAtLine(line_number, &first_token_idx,
+ &last_token_idx);
if (!first_token_idx.IsReal()) {
// Script does not contain the given line number.
if (FLAG_verbose_debug) {
@@ -3133,7 +3164,7 @@
BreakpointLocation* loc = NULL;
ASSERT(first_token_idx <= last_token_idx);
while ((loc == NULL) && (first_token_idx <= last_token_idx)) {
- loc = SetBreakpoint(script, first_token_idx, last_token_idx, line_number,
+ loc = SetBreakpoint(scripts, first_token_idx, last_token_idx, line_number,
column_number, Function::Handle());
first_token_idx = first_token_idx.Next();
}
@@ -3174,8 +3205,8 @@
bool GroupDebugger::EnsureLocationIsInFunction(Zone* zone,
const Function& function,
BreakpointLocation* location) {
- const Script& script = Script::Handle(zone, location->script());
- if (!FunctionOverlaps(function, script, location->token_pos(),
+ const String& url = String::Handle(zone, location->url());
+ if (!FunctionOverlaps(function, url, location->token_pos(),
location->end_token_pos())) {
return false;
}
@@ -3187,6 +3218,7 @@
// Narrow down the token position range to a single value
// if requested column number is provided so that inner
// Closure won't be missed.
+ const Script& script = Script::Handle(location->script());
token_pos = FindExactTokenPosition(script, token_pos,
location->requested_column_number());
}
@@ -3730,11 +3762,11 @@
bool GroupDebugger::HasBreakpoint(Thread* thread, const Function& function) {
if (RunUnderReadLockIfNeeded(thread, breakpoint_locations_lock(), [&]() {
// Check if function has any breakpoints.
- Script& script = Script::Handle(thread->zone());
+ String& url = String::Handle(thread->zone());
for (intptr_t i = 0; i < breakpoint_locations_.length(); i++) {
BreakpointLocation* location = breakpoint_locations_.At(i);
- script = location->script();
- if (FunctionOverlaps(function, script, location->token_pos(),
+ url = location->url();
+ if (FunctionOverlaps(function, url, location->token_pos(),
location->end_token_pos())) {
return true;
}
@@ -4134,6 +4166,8 @@
BreakpointLocation* prev_loc = NULL;
const GrowableObjectArray& libs =
GrowableObjectArray::Handle(isolate_group->object_store()->libraries());
+
+ GrowableHandlePtrArray<const Script> scripts(zone, 1);
while (loc != NULL) {
url = loc->url();
bool found_match = false;
@@ -4142,83 +4176,87 @@
lib ^= libs.At(i);
script = lib.LookupScript(url, !is_package);
if (!script.IsNull()) {
- // Found a script with matching url for this latent breakpoint.
- // Unlink the latent breakpoint from the list.
- found_match = true;
- BreakpointLocation* matched_loc = loc;
- loc = loc->next();
- if (prev_loc == NULL) {
- latent_locations_ = loc;
- } else {
- prev_loc->set_next(loc);
- }
- // Now find the token range at the requested line and make a
- // new unresolved source breakpoint.
- intptr_t line_number = matched_loc->requested_line_number();
- intptr_t column_number = matched_loc->requested_column_number();
- ASSERT(line_number >= 0);
- TokenPosition first_token_pos = TokenPosition::kNoSource;
- TokenPosition last_token_pos = TokenPosition::kNoSource;
- script.TokenRangeAtLine(line_number, &first_token_pos, &last_token_pos);
- if (!first_token_pos.IsDebugPause() || !last_token_pos.IsDebugPause()) {
- // Script does not contain the given line number or there are no
- // tokens on the line. Drop the breakpoint silently.
- Breakpoint* bpt = matched_loc->breakpoints();
- while (bpt != NULL) {
- if (FLAG_verbose_debug) {
- OS::PrintErr("No code found at line %" Pd
- ": "
- "dropping latent breakpoint %" Pd " in '%s'\n",
- line_number, bpt->id(), url.ToCString());
- }
- Breakpoint* prev = bpt;
- bpt = bpt->next();
- delete prev;
+ scripts.Add(script);
+ }
+ }
+ if (scripts.length() > 0) {
+ // Found a script with matching url for this latent breakpoint.
+ // Unlink the latent breakpoint from the list.
+ found_match = true;
+ BreakpointLocation* matched_loc = loc;
+ loc = loc->next();
+ if (prev_loc == NULL) {
+ latent_locations_ = loc;
+ } else {
+ prev_loc->set_next(loc);
+ }
+ // Now find the token range at the requested line and make a
+ // new unresolved source breakpoint.
+ intptr_t line_number = matched_loc->requested_line_number();
+ intptr_t column_number = matched_loc->requested_column_number();
+ ASSERT(line_number >= 0);
+ TokenPosition first_token_pos = TokenPosition::kNoSource;
+ TokenPosition last_token_pos = TokenPosition::kNoSource;
+ scripts.At(0).TokenRangeAtLine(line_number, &first_token_pos,
+ &last_token_pos);
+ if (!first_token_pos.IsDebugPause() || !last_token_pos.IsDebugPause()) {
+ // Script does not contain the given line number or there are no
+ // tokens on the line. Drop the breakpoint silently.
+ Breakpoint* bpt = matched_loc->breakpoints();
+ while (bpt != NULL) {
+ if (FLAG_verbose_debug) {
+ OS::PrintErr("No code found at line %" Pd
+ ": "
+ "dropping latent breakpoint %" Pd " in '%s'\n",
+ line_number, bpt->id(), url.ToCString());
}
- delete matched_loc;
- } else {
- // We don't expect to already have a breakpoint for this location.
- // If there is one, assert in debug build but silently drop
- // the latent breakpoint in release build.
- BreakpointLocation* existing_loc =
- GetBreakpointLocation(script, first_token_pos, -1, column_number);
- ASSERT(existing_loc == NULL);
- if (existing_loc == NULL) {
- // Create and register a new source breakpoint for the
- // latent breakpoint.
- BreakpointLocation* unresolved_loc = new BreakpointLocation(
- this, script, first_token_pos, last_token_pos, line_number,
- column_number);
- RegisterBreakpointLocation(unresolved_loc);
+ Breakpoint* prev = bpt;
+ bpt = bpt->next();
+ delete prev;
+ }
+ delete matched_loc;
+ } else {
+ // We don't expect to already have a breakpoint for this location.
+ // If there is one, assert in debug build but silently drop
+ // the latent breakpoint in release build.
+ BreakpointLocation* existing_loc =
+ GetBreakpointLocation(url, first_token_pos, -1, column_number);
+ ASSERT(existing_loc == NULL);
+ if (existing_loc == NULL) {
+ // Create and register a new source breakpoint for the
+ // latent breakpoint.
+ BreakpointLocation* unresolved_loc = new BreakpointLocation(
+ this, scripts, first_token_pos, last_token_pos, line_number,
+ column_number);
+ RegisterBreakpointLocation(unresolved_loc);
- // Move breakpoints over.
- Breakpoint* bpt = matched_loc->breakpoints();
- unresolved_loc->set_breakpoints(bpt);
- matched_loc->set_breakpoints(NULL);
- while (bpt != NULL) {
- bpt->set_bpt_location(unresolved_loc);
- if (FLAG_verbose_debug) {
- OS::PrintErr(
- "Converted latent breakpoint "
- "%" Pd " in '%s' at line %" Pd " col %" Pd "\n",
- bpt->id(), url.ToCString(), line_number, column_number);
- }
- bpt = bpt->next();
+ // Move breakpoints over.
+ Breakpoint* bpt = matched_loc->breakpoints();
+ unresolved_loc->set_breakpoints(bpt);
+ matched_loc->set_breakpoints(NULL);
+ while (bpt != NULL) {
+ bpt->set_bpt_location(unresolved_loc);
+ if (FLAG_verbose_debug) {
+ OS::PrintErr(
+ "Converted latent breakpoint "
+ "%" Pd " in '%s' at line %" Pd " col %" Pd "\n",
+ bpt->id(), url.ToCString(), line_number, column_number);
}
- group_debugger()->SyncBreakpointLocation(unresolved_loc);
+ bpt = bpt->next();
}
- delete matched_loc;
- // Break out of the iteration over loaded libraries. If the
- // same url has been loaded into more than one library, we
- // only set a breakpoint in the first one.
- // TODO(hausner): There is one possible pitfall here.
- // If the user sets a latent breakpoint using a partial url that
- // ends up matching more than one script, the breakpoint might
- // get set in the wrong script.
- // It would be better if we could warn the user if multiple
- // scripts are matching.
- break;
+ group_debugger()->SyncBreakpointLocation(unresolved_loc);
}
+ delete matched_loc;
+ // Break out of the iteration over loaded libraries. If the
+ // same url has been loaded into more than one library, we
+ // only set a breakpoint in the first one.
+ // TODO(hausner): There is one possible pitfall here.
+ // If the user sets a latent breakpoint using a partial url that
+ // ends up matching more than one script, the breakpoint might
+ // get set in the wrong script.
+ // It would be better if we could warn the user if multiple
+ // scripts are matching.
+ break;
}
}
if (!found_match) {
@@ -4443,12 +4481,13 @@
}
BreakpointLocation* Debugger::GetResolvedBreakpointLocation(
- const Script& script,
+ const String& script_url,
TokenPosition code_token_pos) {
BreakpointLocation* loc = breakpoint_locations_;
+ String& loc_url = String::Handle();
while (loc != nullptr) {
- if (loc->script_ == script.ptr() &&
- loc->code_token_pos_ == code_token_pos) {
+ loc_url = loc->url();
+ if (script_url.Equals(loc_url) && loc->code_token_pos_ == code_token_pos) {
return loc;
}
loc = loc->next();
@@ -4457,14 +4496,16 @@
}
BreakpointLocation* Debugger::GetBreakpointLocation(
- const Script& script,
+ const String& script_url,
TokenPosition token_pos,
intptr_t requested_line,
intptr_t requested_column,
TokenPosition code_token_pos) {
BreakpointLocation* loc = breakpoint_locations_;
+ String& loc_url = String::Handle();
while (loc != NULL) {
- if (loc->script_ == script.ptr() &&
+ loc_url = loc->url();
+ if (script_url.Equals(loc_url) &&
(!token_pos.IsReal() || (loc->token_pos_ == token_pos)) &&
((requested_line == -1) ||
(loc->requested_line_number_ == requested_line)) &&
diff --git a/runtime/vm/debugger.h b/runtime/vm/debugger.h
index 6dd2515..f02e84e 100644
--- a/runtime/vm/debugger.h
+++ b/runtime/vm/debugger.h
@@ -138,7 +138,7 @@
public:
// Create a new unresolved breakpoint.
BreakpointLocation(Debugger* debugger,
- const Script& script,
+ const GrowableHandlePtrArray<const Script>& scripts,
TokenPosition token_pos,
TokenPosition end_token_pos,
intptr_t requested_line_number,
@@ -155,7 +155,12 @@
intptr_t line_number();
TokenPosition end_token_pos() const { return end_token_pos_; }
- ScriptPtr script() const { return script_; }
+ ScriptPtr script() const {
+ if (scripts_.length() == 0) {
+ return Script::null();
+ }
+ return scripts_.At(0);
+ }
StringPtr url() const { return url_; }
intptr_t requested_line_number() const { return requested_line_number_; }
@@ -197,7 +202,7 @@
SafepointRwLock* line_number_lock() { return line_number_lock_.get(); }
Debugger* debugger_;
- ScriptPtr script_;
+ MallocGrowableArray<ScriptPtr> scripts_;
StringPtr url_;
std::unique_ptr<SafepointRwLock> line_number_lock_;
intptr_t line_number_; // lazily computed for token_pos_
@@ -271,8 +276,7 @@
ASSERT(breakpoint_locations_.length() == 0 ||
(breakpoint_location->token_pos() ==
breakpoint_locations_.At(0)->token_pos() &&
- breakpoint_location->script() ==
- breakpoint_locations_.At(0)->script()));
+ breakpoint_location->url() == breakpoint_locations_.At(0)->url()));
breakpoint_locations_.Add(breakpoint_location);
}
@@ -821,29 +825,38 @@
void SendBreakpointEvent(ServiceEvent::EventKind kind, Breakpoint* bpt);
- void FindCompiledFunctions(const Script& script,
- TokenPosition start_pos,
- TokenPosition end_pos,
- GrowableObjectArray* code_function_list);
+ void FindCompiledFunctions(
+ const GrowableHandlePtrArray<const Script>& scripts,
+ TokenPosition start_pos,
+ TokenPosition end_pos,
+ GrowableObjectArray* code_function_list);
bool FindBestFit(const Script& script,
TokenPosition token_pos,
TokenPosition last_token_pos,
Function* best_fit);
void DeoptimizeWorld();
void NotifySingleStepping(bool value) const;
- BreakpointLocation* SetCodeBreakpoints(const Script& script,
- TokenPosition token_pos,
- TokenPosition last_token_pos,
- intptr_t requested_line,
- intptr_t requested_column,
- TokenPosition exact_token_pos,
- const GrowableObjectArray& functions);
+ BreakpointLocation* SetCodeBreakpoints(
+ const GrowableHandlePtrArray<const Script>& scripts,
+ TokenPosition token_pos,
+ TokenPosition last_token_pos,
+ intptr_t requested_line,
+ intptr_t requested_column,
+ TokenPosition exact_token_pos,
+ const GrowableObjectArray& functions);
BreakpointLocation* SetBreakpoint(const Script& script,
TokenPosition token_pos,
TokenPosition last_token_pos,
intptr_t requested_line,
intptr_t requested_column,
const Function& function);
+ BreakpointLocation* SetBreakpoint(
+ const GrowableHandlePtrArray<const Script>& scripts,
+ TokenPosition token_pos,
+ TokenPosition last_token_pos,
+ intptr_t requested_line,
+ intptr_t requested_column,
+ const Function& function);
bool RemoveBreakpointFromTheList(intptr_t bp_id, BreakpointLocation** list);
Breakpoint* GetBreakpointByIdInTheList(intptr_t id, BreakpointLocation* list);
BreakpointLocation* GetLatentBreakpoint(const String& url,
@@ -851,10 +864,10 @@
intptr_t column);
void RegisterBreakpointLocation(BreakpointLocation* bpt);
BreakpointLocation* GetResolvedBreakpointLocation(
- const Script& script,
+ const String& script_url,
TokenPosition code_token_pos);
BreakpointLocation* GetBreakpointLocation(
- const Script& script,
+ const String& script_url,
TokenPosition token_pos,
intptr_t requested_line,
intptr_t requested_column,
diff --git a/runtime/vm/globals.h b/runtime/vm/globals.h
index be0584f..3efe11c 100644
--- a/runtime/vm/globals.h
+++ b/runtime/vm/globals.h
@@ -33,6 +33,12 @@
const intptr_t kSmiMax32 = (static_cast<intptr_t>(1) << kSmiBits32) - 1;
const intptr_t kSmiMin32 = -(static_cast<intptr_t>(1) << kSmiBits32);
+#if !defined(DART_COMPRESSED_POINTERS)
+const intptr_t kCompressedWordSize = kWordSize;
+#else
+const intptr_t kCompressedWordSize = sizeof(uint32_t);
+#endif
+
// Number of bytes per BigInt digit.
const intptr_t kBytesPerBigIntDigit = 4;
diff --git a/runtime/vm/heap/become.cc b/runtime/vm/heap/become.cc
index e51678a..1e733b8 100644
--- a/runtime/vm/heap/become.cc
+++ b/runtime/vm/heap/become.cc
@@ -126,9 +126,11 @@
if (visiting_object_ == nullptr) {
*p = new_target;
} else if (visiting_object_->untag()->IsCardRemembered()) {
- visiting_object_->untag()->StoreArrayPointer(p, new_target, thread_);
+ visiting_object_->untag()->StoreCompressedArrayPointer(p, new_target,
+ thread_);
} else {
- visiting_object_->untag()->StorePointer(p, new_target, thread_);
+ visiting_object_->untag()->StoreCompressedPointer(p, new_target,
+ thread_);
}
}
}
diff --git a/runtime/vm/kernel_loader.cc b/runtime/vm/kernel_loader.cc
index 45a4edd..fb284d0 100644
--- a/runtime/vm/kernel_loader.cc
+++ b/runtime/vm/kernel_loader.cc
@@ -1098,6 +1098,7 @@
toplevel_class.set_is_abstract();
toplevel_class.set_is_declaration_loaded();
toplevel_class.set_is_type_finalized();
+ toplevel_class.set_num_type_arguments_unsafe(0);
library.set_toplevel_class(toplevel_class);
library_helper.ReadUntilExcluding(LibraryHelper::kDependencies);
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index a00fa04..ac92f8f 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -1045,7 +1045,7 @@
{
uword address = heap->Allocate(TypeArguments::InstanceSize(0), Heap::kOld);
InitializeObject(address, kTypeArgumentsCid, TypeArguments::InstanceSize(0),
- /*compressed*/ false);
+ /*compressed*/ true);
TypeArguments::initializeHandle(
empty_type_arguments_,
static_cast<TypeArgumentsPtr>(address + kHeapObjectTag));
@@ -6689,7 +6689,7 @@
{
ObjectPtr raw = Object::Allocate(TypeArguments::kClassId,
TypeArguments::InstanceSize(len), space,
- /*compressed*/ false);
+ /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
// Length must be set before we start storing into the array.
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index f43d2d0..b5d335c 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -7491,7 +7491,7 @@
return OFFSET_OF_RETURNED_VALUE(UntaggedTypeArguments, types);
}
static intptr_t type_at_offset(intptr_t index) {
- return types_offset() + index * kWordSize;
+ return types_offset() + index * kCompressedWordSize;
}
void SetTypeAt(intptr_t index, const AbstractType& value) const;
@@ -7500,7 +7500,7 @@
return TypeArguments::types_offset();
}
- static constexpr intptr_t kElementSize = kWordSize;
+ static constexpr intptr_t kElementSize = kCompressedWordSize;
};
// The nullability of a type argument vector represents the nullability of its
@@ -7683,7 +7683,7 @@
return OFFSET_OF(UntaggedTypeArguments, instantiations_);
}
- static const intptr_t kBytesPerElement = kWordSize;
+ static const intptr_t kBytesPerElement = kCompressedWordSize;
static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
static intptr_t InstanceSize() {
@@ -7696,7 +7696,7 @@
// Ensure that the types() is not adding to the object size, which includes
// 4 fields: instantiations_, length_, hash_, and nullability_.
ASSERT(sizeof(UntaggedTypeArguments) ==
- (sizeof(UntaggedObject) + (kNumFields * kWordSize)));
+ (sizeof(UntaggedObject) + (kNumFields * kCompressedWordSize)));
ASSERT(0 <= len && len <= kMaxElements);
return RoundedAllocationSize(sizeof(UntaggedTypeArguments) +
(len * kBytesPerElement));
diff --git a/runtime/vm/raw_object.cc b/runtime/vm/raw_object.cc
index 7e32ade..d99acc8 100644
--- a/runtime/vm/raw_object.cc
+++ b/runtime/vm/raw_object.cc
@@ -180,7 +180,7 @@
case kTypeArgumentsCid: {
const TypeArgumentsPtr raw_array =
static_cast<const TypeArgumentsPtr>(this);
- intptr_t array_length = Smi::Value(raw_array->untag()->length_);
+ intptr_t array_length = Smi::Value(raw_array->untag()->length());
instance_size = TypeArguments::InstanceSize(array_length);
break;
}
@@ -572,7 +572,8 @@
COMPRESSED_VISITOR(UserTag)
REGULAR_VISITOR(SubtypeTestCache)
COMPRESSED_VISITOR(LoadingUnit)
-VARIABLE_VISITOR(TypeArguments, Smi::Value(raw_obj->untag()->length_))
+VARIABLE_COMPRESSED_VISITOR(TypeArguments,
+ Smi::Value(raw_obj->untag()->length()))
VARIABLE_COMPRESSED_VISITOR(LocalVarDescriptors, raw_obj->untag()->num_entries_)
VARIABLE_COMPRESSED_VISITOR(ExceptionHandlers, raw_obj->untag()->num_entries_)
VARIABLE_VISITOR(Context, raw_obj->untag()->num_variables_)
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index 308284a..33003af 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -166,7 +166,7 @@
}
static constexpr bool SizeFits(intptr_t size) {
- DEBUG_ASSERT(Utils::IsAligned(size, kObjectAlignment));
+ assert(Utils::IsAligned(size, kObjectAlignment));
return (size <= kMaxSizeTag);
}
@@ -585,10 +585,11 @@
}
}
- void StorePointer(CompressedObjectPtr* addr,
- ObjectPtr value,
- Thread* thread) {
- *addr = value;
+ template <typename type, typename compressed_type>
+ void StoreCompressedPointer(compressed_type const* addr,
+ type value,
+ Thread* thread) {
+ *const_cast<compressed_type*>(addr) = value;
if (value->IsHeapObject()) {
CheckHeapPointerStore(value, thread);
}
@@ -619,10 +620,23 @@
}
}
- void StoreArrayPointer(CompressedObjectPtr* addr,
- ObjectPtr value,
- Thread* thread) {
- *addr = value;
+ template <typename type,
+ typename compressed_type,
+ std::memory_order order = std::memory_order_relaxed>
+ void StoreCompressedArrayPointer(compressed_type const* addr, type value) {
+ reinterpret_cast<std::atomic<compressed_type>*>(
+ const_cast<compressed_type*>(addr))
+ ->store(static_cast<compressed_type>(value), order);
+ if (value->IsHeapObject()) {
+ CheckArrayPointerStore(addr, value, Thread::Current());
+ }
+ }
+
+ template <typename type, typename compressed_type>
+ void StoreCompressedArrayPointer(compressed_type const* addr,
+ type value,
+ Thread* thread) {
+ *const_cast<compressed_type*>(addr) = value;
if (value->IsHeapObject()) {
CheckArrayPointerStore(addr, value, thread);
}
@@ -844,6 +858,27 @@
type* array_name() { OPEN_ARRAY_START(type, type); } \
type const* array_name() const { OPEN_ARRAY_START(type, type); }
+#define COMPRESSED_VARIABLE_POINTER_FIELDS(type, accessor_name, array_name) \
+ public: \
+ template <std::memory_order order = std::memory_order_relaxed> \
+ type accessor_name(intptr_t index) const { \
+ return LoadCompressedPointer<type, Compressed##type, order>( \
+ &array_name()[index]); \
+ } \
+ template <std::memory_order order = std::memory_order_relaxed> \
+ void set_##accessor_name(intptr_t index, type value) { \
+ StoreCompressedArrayPointer<type, Compressed##type, order>( \
+ &array_name()[index], value); \
+ } \
+ \
+ protected: \
+ Compressed##type* array_name() { \
+ OPEN_ARRAY_START(Compressed##type, Compressed##type); \
+ } \
+ Compressed##type const* array_name() const { \
+ OPEN_ARRAY_START(Compressed##type, Compressed##type); \
+ }
+
#define SMI_FIELD(type, name) \
public: \
template <std::memory_order order = std::memory_order_relaxed> \
@@ -2443,17 +2478,17 @@
private:
RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments);
- VISIT_FROM(ObjectPtr, instantiations)
+ VISIT_FROM(CompressedObjectPtr, instantiations)
// The instantiations_ array remains empty for instantiated type arguments.
- POINTER_FIELD(ArrayPtr,
- instantiations) // Of 3-tuple: 2 instantiators, result.
- SMI_FIELD(SmiPtr, length)
- SMI_FIELD(SmiPtr, hash)
- SMI_FIELD(SmiPtr, nullability)
+ // Of 3-tuple: 2 instantiators, result.
+ COMPRESSED_POINTER_FIELD(ArrayPtr, instantiations)
+ COMPRESSED_SMI_FIELD(SmiPtr, length)
+ COMPRESSED_SMI_FIELD(SmiPtr, hash)
+ COMPRESSED_SMI_FIELD(SmiPtr, nullability)
// Variable length data follows here.
- VARIABLE_POINTER_FIELDS(AbstractTypePtr, element, types)
- ObjectPtr* to(intptr_t length) {
- return reinterpret_cast<ObjectPtr*>(&types()[length - 1]);
+ COMPRESSED_VARIABLE_POINTER_FIELDS(AbstractTypePtr, element, types)
+ CompressedObjectPtr* to(intptr_t length) {
+ return reinterpret_cast<CompressedObjectPtr*>(&types()[length - 1]);
}
friend class Object;
@@ -2473,11 +2508,10 @@
protected:
static constexpr intptr_t kTypeStateBitSize = 2;
- uword type_test_stub_entry_point_; // Accessed from generated code.
- COMPRESSED_POINTER_FIELD(
- CodePtr,
- type_test_stub) // Must be the last field, since subclasses use it
- // in their VISIT_FROM.
+ // Accessed from generated code.
+ uword type_test_stub_entry_point_;
+ // Must be the last field, since subclasses use it in their VISIT_FROM.
+ COMPRESSED_POINTER_FIELD(CodePtr, type_test_stub)
private:
RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractType);
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index 9f8b670..924f0a4 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -354,7 +354,7 @@
// across (isolates spawned using spawnURI) we send them as dynamic.
if (!writer->can_send_any_object()) {
// Lookup the type class.
- TypePtr raw_type = Type::RawCast(types()[i]);
+ TypePtr raw_type = Type::RawCast(element(i));
SmiPtr raw_type_class_id =
Smi::RawCast(raw_type->untag()->type_class_id());
ClassPtr type_class = writer->isolate_group()->class_table()->At(
@@ -362,10 +362,10 @@
if (!writer->AllowObjectsInDartLibrary(type_class->untag()->library())) {
writer->WriteVMIsolateObject(kDynamicType);
} else {
- writer->WriteObjectImpl(types()[i], as_reference);
+ writer->WriteObjectImpl(element(i), as_reference);
}
} else {
- writer->WriteObjectImpl(types()[i], as_reference);
+ writer->WriteObjectImpl(element(i), as_reference);
}
}
}
diff --git a/runtime/vm/type_testing_stubs.cc b/runtime/vm/type_testing_stubs.cc
index 34e5f63..165c7b5 100644
--- a/runtime/vm/type_testing_stubs.cc
+++ b/runtime/vm/type_testing_stubs.cc
@@ -464,12 +464,12 @@
__ CompareObject(kTypeArgumentsReg, Object::null_object());
__ BranchIf(EQUAL, &is_dynamic);
- __ LoadField(
+ __ LoadCompressedField(
TTSInternalRegs::kScratchReg,
compiler::FieldAddress(kTypeArgumentsReg,
compiler::target::TypeArguments::type_at_offset(
type_param.index())));
- __ CompareWithFieldValue(
+ __ CompareWithCompressedFieldValue(
TTSInternalRegs::kScratchReg,
compiler::FieldAddress(TTSInternalRegs::kInstanceTypeArgumentsReg,
compiler::target::TypeArguments::type_at_offset(
@@ -483,12 +483,12 @@
/*include_abstract=*/true,
/*exclude_null=*/!null_is_assignable);
- __ LoadField(
+ __ LoadCompressedField(
TTSInternalRegs::kScratchReg,
compiler::FieldAddress(TTSInternalRegs::kInstanceTypeArgumentsReg,
compiler::target::TypeArguments::type_at_offset(
type_param_value_offset_i)));
- __ LoadField(
+ __ LoadCompressedField(
TTSInternalRegs::kScratchReg,
compiler::FieldAddress(TTSInternalRegs::kScratchReg,
compiler::target::Type::type_class_id_offset()));
@@ -515,11 +515,12 @@
// Nullable type is not a subtype of non-nullable type.
// TODO(dartbug.com/40736): Allocate a register for instance type argument
// and avoid reloading it.
- __ LoadField(TTSInternalRegs::kScratchReg,
- compiler::FieldAddress(
- TTSInternalRegs::kInstanceTypeArgumentsReg,
- compiler::target::TypeArguments::type_at_offset(
- type_param_value_offset_i)));
+ __ LoadCompressedField(
+ TTSInternalRegs::kScratchReg,
+ compiler::FieldAddress(
+ TTSInternalRegs::kInstanceTypeArgumentsReg,
+ compiler::target::TypeArguments::type_at_offset(
+ type_param_value_offset_i)));
__ CompareTypeNullabilityWith(TTSInternalRegs::kScratchReg,
compiler::target::Nullability::kNullable);
__ BranchIf(EQUAL, check_failed);
diff --git a/runtime/vm/v8_snapshot_writer.h b/runtime/vm/v8_snapshot_writer.h
index 63544c9..ea844ce 100644
--- a/runtime/vm/v8_snapshot_writer.h
+++ b/runtime/vm/v8_snapshot_writer.h
@@ -32,7 +32,8 @@
struct ObjectId {
ObjectId() : ObjectId(IdSpace::kInvalid, -1) {}
ObjectId(IdSpace space, int64_t nonce)
- : encoded_((nonce << kIdSpaceBits) | static_cast<intptr_t>(space)) {
+ : encoded_((static_cast<uint64_t>(nonce) << kIdSpaceBits) |
+ static_cast<intptr_t>(space)) {
ASSERT(Utils::IsInt(kBitsPerInt64 - kIdSpaceBits, nonce));
}
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index a5e1837..cfaaeee 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -54,11 +54,7 @@
import 'dart:_native_typed_data';
-import 'dart:_js_names'
- show
- extractKeys,
- unmangleGlobalNameIfPreservedAnyways,
- unmangleAllIdentifiersIfPreservedAnyways;
+import 'dart:_js_names' show unmangleGlobalNameIfPreservedAnyways;
import 'dart:_rti' as newRti
show
@@ -1003,29 +999,6 @@
}
}
-/// Helper class for allocating and using JS object literals as caches.
-class JsCache {
- /// Returns a JavaScript object suitable for use as a cache.
- static allocate() {
- var result = JS('=Object', 'Object.create(null)');
- // Deleting a property makes V8 assume that it shouldn't create a hidden
- // class for [result] and map transitions. Although these map transitions
- // pay off if there are many cache hits for the same keys, it becomes
- // really slow when there aren't many repeated hits.
- JS('void', '#.x=0', result);
- JS('void', 'delete #.x', result);
- return result;
- }
-
- static fetch(cache, String key) {
- return JS('', '#[#]', cache, key);
- }
-
- static void update(cache, String key, value) {
- JS('void', '#[#] = #', cache, key, value);
- }
-}
-
/// Called by generated code to throw an illegal-argument exception,
/// for example, if a non-integer index is given to an optimized
/// indexed access.
diff --git a/sdk/lib/_internal/js_runtime/lib/js_names.dart b/sdk/lib/_internal/js_runtime/lib/js_names.dart
index 10efacf..678df00 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_names.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_names.dart
@@ -4,164 +4,21 @@
library dart._js_names;
-import 'dart:_js_embedded_names'
- show JsGetName, MANGLED_GLOBAL_NAMES, MANGLED_NAMES;
+import 'dart:_js_embedded_names' show MANGLED_GLOBAL_NAMES;
-import 'dart:_foreign_helper' show JS, JS_EMBEDDED_GLOBAL, JS_GET_NAME;
+import 'dart:_foreign_helper' show JS, JS_EMBEDDED_GLOBAL;
-import 'dart:_js_helper' show JsCache, NoInline;
-
-import 'dart:_interceptors' show JSArray;
-
-/// No-op method that is called to inform the compiler that unmangled named
-/// must be preserved.
-preserveNames() {}
-
-/// A map from mangled names to "reflective" names, that is, unmangled names
-/// with some additional information, such as, number of required arguments.
-/// This map is for mangled names used as instance members.
-final _LazyMangledNamesMap mangledNames = new _LazyMangledInstanceNamesMap(
- JS_EMBEDDED_GLOBAL('=Object', MANGLED_NAMES));
-
-/// A map from "reflective" names to mangled names (the reverse of
-/// [mangledNames]).
-final _LazyReflectiveNamesMap reflectiveNames = new _LazyReflectiveNamesMap(
- JS_EMBEDDED_GLOBAL('=Object', MANGLED_NAMES), true);
-
-/// A map from mangled names to "reflective" names (see [mangledNames]). This
-/// map is for globals, that is, static and top-level members.
-final _LazyMangledNamesMap mangledGlobalNames = new _LazyMangledNamesMap(
- JS_EMBEDDED_GLOBAL('=Object', MANGLED_GLOBAL_NAMES));
-
-/// A map from "reflective" names to mangled names (the reverse of
-/// [mangledGlobalNames]).
-final _LazyReflectiveNamesMap reflectiveGlobalNames =
- new _LazyReflectiveNamesMap(
- JS_EMBEDDED_GLOBAL('=Object', MANGLED_GLOBAL_NAMES), false);
-
-/// Implements a mapping from mangled names to their reflective counterparts.
-/// The propertiy names of [_jsMangledNames] are the mangled names, and the
-/// values are the "reflective" names.
-class _LazyMangledNamesMap {
- /// [_jsMangledNames] is a JavaScript object literal.
- var _jsMangledNames;
-
- _LazyMangledNamesMap(this._jsMangledNames);
-
- String? operator [](String key) {
- var result = JS('var', '#[#]', _jsMangledNames, key);
- // Filter out all non-string values to protect against polution from
- // ancillary fields in [_jsMangledNames].
- bool filter = JS('bool', 'typeof # !== "string"', result);
- // To ensure that the inferrer sees that result is a String, we explicitly
- // give it a better type here.
- return filter ? null : JS('String', '#', result);
- }
-}
-
-/// Extends [_LazyMangledNamesMap] with additional support for adding mappings
-/// from mangled setter names to their reflective counterpart by rewriting a
-/// corresponding entry for a getter name, if it exists.
-class _LazyMangledInstanceNamesMap extends _LazyMangledNamesMap {
- _LazyMangledInstanceNamesMap(_jsMangledNames) : super(_jsMangledNames);
-
- String? operator [](String key) {
- String? result = super[key];
- String setterPrefix = JS_GET_NAME(JsGetName.SETTER_PREFIX);
- if (result == null && key.startsWith(setterPrefix)) {
- String getterPrefix = JS_GET_NAME(JsGetName.GETTER_PREFIX);
- int setterPrefixLength = setterPrefix.length;
-
- // Generate the setter name from the getter name.
- key = '$getterPrefix${key.substring(setterPrefixLength)}';
- result = super[key];
- return (result != null) ? "${result}=" : null;
- }
- return result;
- }
-}
-
-/// Implements the inverse of [_LazyMangledNamesMap]. As it would be too
-/// expensive to search the mangled names map for a value that corresponds to
-/// the lookup key on each invocation, we compute the full mapping in demand
-/// and cache it. The cache is invalidated when the underlying [_jsMangledNames]
-/// object changes its length. This condition is sufficient as the name mapping
-/// can only grow over time.
-/// When [_isInstance] is true, we also apply the inverse of the setter/getter
-/// name conversion implemented by [_LazyMangledInstanceNamesMap].
-class _LazyReflectiveNamesMap {
- /// [_jsMangledNames] is a JavaScript object literal.
- final _jsMangledNames;
- final bool _isInstance;
- int _cacheLength = 0;
- Map<String, String>? _cache;
-
- _LazyReflectiveNamesMap(this._jsMangledNames, this._isInstance);
-
- Map<String, String> _updateReflectiveNames() {
- preserveNames();
- Map<String, String> result = <String, String>{};
- List keys = JS('List', 'Object.keys(#)', _jsMangledNames);
- for (String key in keys) {
- var reflectiveName = JS('var', '#[#]', _jsMangledNames, key);
- // Filter out all non-string values to protect against polution from
- // ancillary fields in [_jsMangledNames].
- bool filter = JS('bool', 'typeof # !== "string"', reflectiveName);
- if (filter) continue;
- result[reflectiveName] = JS('String', '#', key);
-
- String getterPrefix = JS_GET_NAME(JsGetName.GETTER_PREFIX);
- if (_isInstance && key.startsWith(getterPrefix)) {
- int getterPrefixLength = getterPrefix.length;
- String setterPrefix = JS_GET_NAME(JsGetName.SETTER_PREFIX);
- result['$reflectiveName='] =
- '$setterPrefix${key.substring(getterPrefixLength)}';
- }
- }
- return result;
- }
-
- int get _jsMangledNamesLength =>
- JS('int', 'Object.keys(#).length', _jsMangledNames);
-
- String? operator [](String key) {
- if (_cache == null || _jsMangledNamesLength != _cacheLength) {
- _cache = _updateReflectiveNames();
- _cacheLength = _jsMangledNamesLength;
- }
- return _cache![key];
- }
-}
-
-@pragma('dart2js:noInline')
-List extractKeys(victim) {
- var result = JS('', '# ? Object.keys(#) : []', victim, victim);
- return new JSArray.markFixed(result);
-}
-
-/// Returns the (global) unmangled version of [name].
+/// Returns the (global) unminified version of [name], or (usual case) `null` if
+/// the name is not known.
///
-/// Normally, you should use [mangledGlobalNames] directly, but this method
-/// doesn't tell the compiler to preserve names. So this method only returns a
-/// non-null value if some other component has made the compiler preserve names.
-///
-/// This is used, for example, to return unmangled names from TypeImpl.toString
-/// *if* names are being preserved for other reasons (use of dart:mirrors, for
-/// example).
+/// The generated app contains a small table that translates a few minified
+/// names to their unminified text. This is used to return unminified names in
+/// some parts of Type.toString. Historically a much more comprehensive and
+/// large table was generated to support 'dart:mirrors', but 'dart:mirrors' is
+/// no longer supported on the web platforms, in part due to the size of tables
+/// like this. The names included are chosen by the emitter, but limited to a
+/// few primitives and `List`.
String? unmangleGlobalNameIfPreservedAnyways(String name) {
var names = JS_EMBEDDED_GLOBAL('', MANGLED_GLOBAL_NAMES);
- return JS('String|Null', '#', JsCache.fetch(names, name));
-}
-
-String unmangleAllIdentifiersIfPreservedAnyways(String str) {
- return JS(
- 'String',
- r'''
- (function(str, names) {
- return str.replace(
- /[^<,> ]+/g,
- function(m) { return names[m] || m; });
- })(#, #)''',
- str,
- JS_EMBEDDED_GLOBAL('', MANGLED_GLOBAL_NAMES));
+ return JS('String|Null', '#[#]', names, name);
}
diff --git a/sdk/lib/async/zone.dart b/sdk/lib/async/zone.dart
index 9301ce3..fe6dcf0 100644
--- a/sdk/lib/async/zone.dart
+++ b/sdk/lib/async/zone.dart
@@ -17,6 +17,15 @@
///
/// The [error] and [stackTrace] are the error and stack trace that
/// was uncaught in [zone].
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
+///
+/// If the uncaught error handler throws, the error will be passed
+/// to `parent.handleUncaughtError`. If the thrown object is [error],
+/// the throw is considered a re-throw and the original [stackTrace]
+/// is retained. This allows an asynchronous error to leave the error zone.
typedef HandleUncaughtErrorHandler = void Function(Zone self,
ZoneDelegate parent, Zone zone, Object error, StackTrace stackTrace);
@@ -34,6 +43,10 @@
/// to call [f] in the current zone, [zone].
/// A custom handler can do things before, after or instead of
/// calling [f].
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef RunHandler = R Function<R>(
Zone self, ZoneDelegate parent, Zone zone, R Function() f);
@@ -51,6 +64,10 @@
/// to call [f] with argument [arg] in the current zone, [zone].
/// A custom handler can do things before, after or instead of
/// calling [f].
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef RunUnaryHandler = R Function<R, T>(
Zone self, ZoneDelegate parent, Zone zone, R Function(T arg) f, T arg);
@@ -68,6 +85,10 @@
/// to call [f] with arguments [arg1] and [arg2] in the current zone, [zone].
/// A custom handler can do things before, after or instead of
/// calling [f].
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef RunBinaryHandler = R Function<R, T1, T2>(Zone self, ZoneDelegate parent,
Zone zone, R Function(T1 arg1, T2 arg2) f, T1 arg1, T2 arg2);
@@ -85,6 +106,10 @@
/// or another function replacing [f],
/// typically by wrapping [f] in a function
/// which does something extra before and after invoking [f]
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef RegisterCallbackHandler = ZoneCallback<R> Function<R>(
Zone self, ZoneDelegate parent, Zone zone, R Function() f);
@@ -102,6 +127,10 @@
/// or another function replacing [f],
/// typically by wrapping [f] in a function
/// which does something extra before and after invoking [f]
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef RegisterUnaryCallbackHandler = ZoneUnaryCallback<R, T> Function<R, T>(
Zone self, ZoneDelegate parent, Zone zone, R Function(T arg) f);
@@ -137,6 +166,12 @@
/// to replace the original error and stack trace,
/// or an [AsyncError] containing a replacement error and stack trace
/// which will be used to replace the originals.
+///
+/// The error callback handler must not throw.
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef AsyncError? ErrorCallbackHandler(Zone self, ZoneDelegate parent,
Zone zone, Object error, StackTrace? stackTrace);
@@ -155,6 +190,10 @@
/// and then call `parent.scheduleMicrotask(zone, replacement)`.
/// or it can implement its own microtask scheduling queue, which typically
/// still depends on `parent.scheduleMicrotask` to as a way to get started.
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef void ScheduleMicrotaskHandler(
Zone self, ZoneDelegate parent, Zone zone, void f());
@@ -177,6 +216,10 @@
///
/// The function should return a [Timer] object which can be used
/// to inspect and control the scheduled timer callback.
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef Timer CreateTimerHandler(
Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f());
@@ -199,6 +242,10 @@
///
/// The function should return a [Timer] object which can be used
/// to inspect and control the scheduled timer callbacks.
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef Timer CreatePeriodicTimerHandler(Zone self, ZoneDelegate parent,
Zone zone, Duration period, void f(Timer timer));
@@ -214,6 +261,10 @@
///
/// The custom handler can intercept print operations and
/// redirect them to other targets than the console.
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef void PrintHandler(
Zone self, ZoneDelegate parent, Zone zone, String line);
@@ -235,6 +286,10 @@
/// values before calling `parent.fork(zone, specification, zoneValues)`,
/// but it has to call the [parent]'s [ZoneDelegate.fork] in order
/// to create a valid [Zone] object.
+///
+/// The function must only access zone-related functionality through
+/// [self], [parent] or [zone].
+/// It should not depend on the current zone ([Zone.current]).
typedef Zone ForkHandler(Zone self, ZoneDelegate parent, Zone zone,
ZoneSpecification? specification, Map<Object?, Object?>? zoneValues);
@@ -915,10 +970,7 @@
_ZoneDelegate(this._delegationTarget);
void handleUncaughtError(Zone zone, Object error, StackTrace stackTrace) {
- var implementation = _delegationTarget._handleUncaughtError;
- _Zone implZone = implementation.zone;
- HandleUncaughtErrorHandler handler = implementation.function;
- return handler(implZone, implZone._parentDelegate, zone, error, stackTrace);
+ _delegationTarget._processUncaughtError(zone, error, stackTrace);
}
R run<R>(Zone zone, R f()) {
@@ -1040,6 +1092,28 @@
return identical(this, otherZone) ||
identical(errorZone, otherZone.errorZone);
}
+
+ void _processUncaughtError(Zone zone, Object error, StackTrace stackTrace) {
+ var implementation = _handleUncaughtError;
+ _Zone implZone = implementation.zone;
+ if (identical(implZone, _rootZone)) {
+ _rootHandleError(error, stackTrace);
+ return;
+ }
+ HandleUncaughtErrorHandler handler = implementation.function;
+ ZoneDelegate parentDelegate = implZone._parentDelegate;
+ _Zone parentZone = implZone.parent!; // Not null for non-root zones.
+ _Zone currentZone = Zone._current;
+ try {
+ Zone._current = parentZone;
+ handler(implZone, parentDelegate, zone, error, stackTrace);
+ Zone._current = currentZone;
+ } catch (e, s) {
+ Zone._current = currentZone;
+ parentZone._processUncaughtError(
+ implZone, e, identical(error, e) ? stackTrace : s);
+ }
+ }
}
class _CustomZone extends _Zone {
@@ -1235,11 +1309,7 @@
// Methods that can be customized by the zone specification.
void handleUncaughtError(Object error, StackTrace stackTrace) {
- var implementation = this._handleUncaughtError;
- ZoneDelegate parentDelegate = implementation.zone._parentDelegate;
- HandleUncaughtErrorHandler handler = implementation.function;
- return handler(
- implementation.zone, parentDelegate, this, error, stackTrace);
+ _processUncaughtError(this, error, stackTrace);
}
Zone fork(
@@ -1335,6 +1405,10 @@
void _rootHandleUncaughtError(Zone? self, ZoneDelegate? parent, Zone zone,
Object error, StackTrace stackTrace) {
+ _rootHandleError(error, stackTrace);
+}
+
+void _rootHandleError(Object error, StackTrace stackTrace) {
_schedulePriorityAsyncCallback(() {
_rethrow(error, stackTrace);
});
diff --git a/tests/language/const_functions/const_functions_map_test.dart b/tests/language/const_functions/const_functions_map_test.dart
new file mode 100644
index 0000000..1dae725
--- /dev/null
+++ b/tests/language/const_functions/const_functions_map_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+// Tests map usage with const functions.
+
+// SharedOptions=--enable-experiment=const-functions
+
+import "package:expect/expect.dart";
+
+const var1 = fn({'key': 'val'}, 'key');
+// ^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+
+const var2 = fn({'key': 2}, 'key');
+// ^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+
+const var3 = fn({'key': 2}, 'invalid');
+// ^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+
+const map = {'key1': 2, 'key2': 3, 'key3': 4};
+const var4 = fn(map, 'key1');
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+const var5 = fn(map, 'key2');
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+const var6 = fn(map, 'key3');
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+
+Object? fn(Map<Object, Object> map, Object key) {
+ return map[key];
+}
+
+const var7 = fn2();
+// ^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+int? fn2() {
+ const y = {'key': 2};
+ return y['key'];
+}
+
+void main() {
+ Expect.equals(var1, 'val');
+ Expect.equals(var2, 2);
+ Expect.equals(var3, null);
+ Expect.equals(var4, 2);
+ Expect.equals(var5, 3);
+ Expect.equals(var6, 4);
+ Expect.equals(var7, 2);
+}
diff --git a/tests/language/why_not_promoted/argument_type_not_assignable_nullability_error_test.dart b/tests/language/why_not_promoted/argument_type_not_assignable_nullability_error_test.dart
index c74a8b2..9ff7eb0 100644
--- a/tests/language/why_not_promoted/argument_type_not_assignable_nullability_error_test.dart
+++ b/tests/language/why_not_promoted/argument_type_not_assignable_nullability_error_test.dart
@@ -655,7 +655,7 @@
// [context 94] 'bad' refers to a property so it couldn't be promoted.
}
-test(C33 c) {
+explicitExtensionInvocation(C33 c) {
if (c.bad == null) return;
E33(c.bad).f();
// ^^^^^
diff --git a/tests/language/why_not_promoted/this_error_test.dart b/tests/language/why_not_promoted/this_error_test.dart
index 2d836ee..87d98c9 100644
--- a/tests/language/why_not_promoted/this_error_test.dart
+++ b/tests/language/why_not_promoted/this_error_test.dart
@@ -11,22 +11,22 @@
extension on int? {
extension_explicit_this() {
- // TODO(paulberry): get this to work with the CFE.
if (this == null) return;
this.isEven;
// ^^^^^^
-// [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// [context 2] 'this' can't be promoted. See http://dart.dev/go/non-promo-this
-// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [context 1] 'this' can't be promoted. See http://dart.dev/go/non-promo-this
+// [cfe 3] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [context 3] 'this' can't be promoted.
}
extension_implicit_this() {
- // TODO(paulberry): get this to work with the CFE.
if (this == null) return;
isEven;
// ^^^^^^
-// [analyzer 1] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
-// [context 1] 'this' can't be promoted. See http://dart.dev/go/non-promo-this
-// [cfe] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [analyzer 2] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
+// [context 2] 'this' can't be promoted. See http://dart.dev/go/non-promo-this
+// [cfe 4] Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
+// [context 4] 'this' can't be promoted.
}
}
diff --git a/tests/lib/async/uncaught_error_handler_throws_test.dart b/tests/lib/async/uncaught_error_handler_throws_test.dart
new file mode 100644
index 0000000..f70f098
--- /dev/null
+++ b/tests/lib/async/uncaught_error_handler_throws_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// 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:expect/expect.dart';
+import 'package:async_helper/async_helper.dart';
+import 'dart:async';
+
+void main() async {
+ asyncStart();
+ await testThrowSame();
+ await testThrowOther();
+ asyncEnd();
+}
+
+Future<void> testThrowSame() async {
+ asyncStart();
+ var object1 = Object();
+ var stack1 = StackTrace.current;
+ var outerZone = Zone.current;
+ var firstZone = Zone.current.fork(specification: onError((error, stack) {
+ // Uncaught error handlers run in the parent zone.
+ Expect.identical(outerZone, Zone.current);
+ Expect.identical(object1, error);
+ Expect.identical(stack1, stack); // Get same stack trace.
+ asyncEnd();
+ }));
+ firstZone.run(() async {
+ Expect.identical(firstZone, Zone.current);
+ var secondZone = Zone.current.fork(specification: onError((error, stack) {
+ // Uncaught error handlers run in the parent zone.
+ Expect.identical(firstZone, Zone.current);
+ Expect.identical(object1, error);
+ Expect.identical(stack1, stack);
+ throw error; // Throw same object
+ }));
+ secondZone.run(() async {
+ Expect.identical(secondZone, Zone.current);
+ Future.error(object1, stack1); // Unhandled async error.
+ await Future(() {});
+ });
+ });
+}
+
+Future<void> testThrowOther() async {
+ asyncStart();
+ var object1 = Object();
+ var object2 = Object();
+ var stack1 = StackTrace.current;
+ var outerZone = Zone.current;
+ var firstZone = Zone.current.fork(specification: onError((error, stack) {
+ Expect.identical(outerZone, Zone.current);
+ Expect.identical(object2, error);
+ Expect.notIdentical(stack1, stack); // Get different stack trace.
+ asyncEnd();
+ }));
+ firstZone.run(() async {
+ Expect.identical(firstZone, Zone.current);
+ var secondZone = Zone.current.fork(specification: onError((error, stack) {
+ Expect.identical(firstZone, Zone.current);
+ Expect.identical(object1, error);
+ Expect.identical(stack1, stack);
+ throw object2; // Throw different object
+ }));
+ secondZone.run(() async {
+ Expect.identical(secondZone, Zone.current);
+ Future.error(object1, stack1); // Unhandled async error.
+ await Future(() {});
+ });
+ });
+}
+
+ZoneSpecification onError(void Function(Object, StackTrace) handler) {
+ return ZoneSpecification(
+ handleUncaughtError: (s, p, z, e, st) => handler(e, st));
+}
diff --git a/tests/lib_2/async/slow_consumer2_test.dart b/tests/lib_2/async/slow_consumer2_test.dart
index de37668..23a001a 100644
--- a/tests/lib_2/async/slow_consumer2_test.dart
+++ b/tests/lib_2/async/slow_consumer2_test.dart
@@ -88,7 +88,7 @@
listSize -= sentCount - targetCount;
sentCount = targetCount;
}
- controller.add(new List(listSize));
+ controller.add(new List<int>(listSize));
int ms = listSize * 1000 ~/ bytesPerSecond;
Duration duration = new Duration(milliseconds: ms);
if (!controller.isPaused) new Timer(duration, send);
diff --git a/tests/lib_2/async/uncaught_error_handler_throws_test.dart b/tests/lib_2/async/uncaught_error_handler_throws_test.dart
new file mode 100644
index 0000000..f70f098
--- /dev/null
+++ b/tests/lib_2/async/uncaught_error_handler_throws_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// 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:expect/expect.dart';
+import 'package:async_helper/async_helper.dart';
+import 'dart:async';
+
+void main() async {
+ asyncStart();
+ await testThrowSame();
+ await testThrowOther();
+ asyncEnd();
+}
+
+Future<void> testThrowSame() async {
+ asyncStart();
+ var object1 = Object();
+ var stack1 = StackTrace.current;
+ var outerZone = Zone.current;
+ var firstZone = Zone.current.fork(specification: onError((error, stack) {
+ // Uncaught error handlers run in the parent zone.
+ Expect.identical(outerZone, Zone.current);
+ Expect.identical(object1, error);
+ Expect.identical(stack1, stack); // Get same stack trace.
+ asyncEnd();
+ }));
+ firstZone.run(() async {
+ Expect.identical(firstZone, Zone.current);
+ var secondZone = Zone.current.fork(specification: onError((error, stack) {
+ // Uncaught error handlers run in the parent zone.
+ Expect.identical(firstZone, Zone.current);
+ Expect.identical(object1, error);
+ Expect.identical(stack1, stack);
+ throw error; // Throw same object
+ }));
+ secondZone.run(() async {
+ Expect.identical(secondZone, Zone.current);
+ Future.error(object1, stack1); // Unhandled async error.
+ await Future(() {});
+ });
+ });
+}
+
+Future<void> testThrowOther() async {
+ asyncStart();
+ var object1 = Object();
+ var object2 = Object();
+ var stack1 = StackTrace.current;
+ var outerZone = Zone.current;
+ var firstZone = Zone.current.fork(specification: onError((error, stack) {
+ Expect.identical(outerZone, Zone.current);
+ Expect.identical(object2, error);
+ Expect.notIdentical(stack1, stack); // Get different stack trace.
+ asyncEnd();
+ }));
+ firstZone.run(() async {
+ Expect.identical(firstZone, Zone.current);
+ var secondZone = Zone.current.fork(specification: onError((error, stack) {
+ Expect.identical(firstZone, Zone.current);
+ Expect.identical(object1, error);
+ Expect.identical(stack1, stack);
+ throw object2; // Throw different object
+ }));
+ secondZone.run(() async {
+ Expect.identical(secondZone, Zone.current);
+ Future.error(object1, stack1); // Unhandled async error.
+ await Future(() {});
+ });
+ });
+}
+
+ZoneSpecification onError(void Function(Object, StackTrace) handler) {
+ return ZoneSpecification(
+ handleUncaughtError: (s, p, z, e, st) => handler(e, st));
+}
diff --git a/tools/VERSION b/tools/VERSION
index 6eca443..b292fbb 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 22
+PRERELEASE 23
PRERELEASE_PATCH 0
\ No newline at end of file