Version 2.18.0-52.0.dev
Merge commit 'ee5a62ff4e3777eba3072f45da3c02235f1c800a' into 'dev'
diff --git a/pkg/analysis_server/test/analysis_abstract.dart b/pkg/analysis_server/test/analysis_abstract.dart
index ae3a12c..61de747 100644
--- a/pkg/analysis_server/test/analysis_abstract.dart
+++ b/pkg/analysis_server/test/analysis_abstract.dart
@@ -2,24 +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.
-import 'package:analysis_server/protocol/protocol.dart';
-import 'package:analysis_server/protocol/protocol_constants.dart';
-import 'package:analysis_server/protocol/protocol_generated.dart'
- hide AnalysisOptions;
-import 'package:analysis_server/src/analysis_server.dart';
-import 'package:analysis_server/src/server/crash_reporting_attachments.dart';
-import 'package:analysis_server/src/utilities/mocks.dart';
-import 'package:analyzer/instrumentation/instrumentation.dart';
-import 'package:analyzer/src/dart/analysis/driver.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/sdk.dart';
-import 'package:analyzer/src/test_utilities/mock_sdk.dart';
-import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
-import 'package:meta/meta.dart';
-import 'package:test/test.dart';
-
-import 'mocks.dart';
-
int findIdentifierLength(String search) {
var length = 0;
while (length < search.length) {
@@ -34,157 +16,3 @@
}
return length;
}
-
-/// An abstract base for all 'analysis' domain tests.
-class AbstractAnalysisTest with ResourceProviderMixin {
- late MockServerChannel serverChannel;
- late TestPluginManager pluginManager;
- late AnalysisServer server;
-
- final List<GeneralAnalysisService> generalServices =
- <GeneralAnalysisService>[];
- final Map<AnalysisService, List<String>> analysisSubscriptions = {};
-
- late String projectPath;
- late String testFolder;
- late String testFile;
- late String testCode;
-
- AbstractAnalysisTest();
-
- AnalysisOptions get analysisOptions => testDiver.analysisOptions;
-
- AnalysisDriver get testDiver => server.getAnalysisDriver(testFile)!;
-
- Future<void> addAnalysisSubscription(
- AnalysisService service, String file) async {
- // add file to subscription
- var files = analysisSubscriptions[service];
- if (files == null) {
- files = <String>[];
- analysisSubscriptions[service] = files;
- }
- files.add(file);
- // set subscriptions
- var request =
- AnalysisSetSubscriptionsParams(analysisSubscriptions).toRequest('0');
- await waitResponse(request);
- }
-
- String addTestFile(String content) {
- newFile(testFile, content);
- testCode = content;
- return testFile;
- }
-
- AnalysisServer createAnalysisServer() {
- //
- // Create an SDK in the mock file system.
- //
- var sdkRoot = newFolder('/sdk');
- createMockSdk(
- resourceProvider: resourceProvider,
- root: sdkRoot,
- );
-
- //
- // Create server
- //
- var options = AnalysisServerOptions();
- return AnalysisServer(
- serverChannel,
- resourceProvider,
- options,
- DartSdkManager(sdkRoot.path),
- CrashReportingAttachmentsBuilder.empty,
- InstrumentationService.NULL_SERVICE);
- }
-
- /// Creates a project [projectPath].
- Future<void> createProject({Map<String, String>? packageRoots}) async {
- newFolder(projectPath);
- await setRoots(included: [projectPath], excluded: []);
- }
-
- void doAllDeclarationsTrackerWork() {
- while (server.declarationsTracker!.hasWork) {
- server.declarationsTracker!.doWork();
- }
- }
-
- /// Returns the offset of [search] in the file at the given [path].
- /// Fails if not found.
- int findFileOffset(String path, String search) {
- var file = getFile(path);
- var code = file.createSource().contents.data;
- var offset = code.indexOf(search);
- expect(offset, isNot(-1), reason: '"$search" in\n$code');
- return offset;
- }
-
- /// Returns the offset of [search] in [testCode].
- /// Fails if not found.
- int findOffset(String search) {
- var offset = testCode.indexOf(search);
- expect(offset, isNot(-1));
- return offset;
- }
-
- String modifyTestFile(String content) {
- modifyFile(testFile, content);
- testCode = content;
- return testFile;
- }
-
- void processNotification(Notification notification) {
- if (notification.event == SERVER_NOTIFICATION_ERROR) {
- fail('${notification.toJson()}');
- }
- }
-
- Future<Response> setRoots({
- required List<String> included,
- required List<String> excluded,
- bool validateSuccessResponse = true,
- }) async {
- var request = AnalysisSetAnalysisRootsParams(
- included.map(convertPath).toList(),
- excluded.map(convertPath).toList(),
- packageRoots: {},
- ).toRequest('0');
- var response = await waitResponse(request);
- if (validateSuccessResponse) {
- expect(response, isResponseSuccess(request.id));
- }
- return response;
- }
-
- @mustCallSuper
- void setUp() async {
- serverChannel = MockServerChannel();
- projectPath = convertPath('/project');
- testFolder = convertPath('/project/bin');
- testFile = convertPath('/project/bin/test.dart');
- pluginManager = TestPluginManager();
- server = createAnalysisServer();
- server.pluginManager = pluginManager;
- serverChannel.notifications.listen(processNotification);
- }
-
- @mustCallSuper
- void tearDown() {
- server.done();
- }
-
- /// Returns a [Future] that completes when the server's analysis is complete.
- Future<void> waitForTasksFinished() {
- return server.onAnalysisComplete;
- }
-
- /// Completes with a successful [Response] for the given [request].
- /// Otherwise fails.
- Future<Response> waitResponse(Request request,
- {bool throwOnError = true}) async {
- return serverChannel.sendRequest(request, throwOnError: throwOnError);
- }
-}
diff --git a/pkg/compiler/test/dump_info/data/deferred/lib.dart b/pkg/compiler/test/dump_info/data/deferred/lib.dart
new file mode 100644
index 0000000..6339eb2
--- /dev/null
+++ b/pkg/compiler/test/dump_info/data/deferred/lib.dart
@@ -0,0 +1,73 @@
+// Copyright (c) 2017, 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: library=[{
+ "id": "library/memory:sdk/tests/web/native/lib.dart::",
+ "kind": "library",
+ "name": "<unnamed>",
+ "size": 289,
+ "children": [
+ "function/memory:sdk/tests/web/native/lib.dart::defaultArg",
+ "function/memory:sdk/tests/web/native/lib.dart::funky"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/lib.dart"
+}]*/
+
+// @dart = 2.7
+
+/*member: defaultArg:function=[{
+ "id": "function/memory:sdk/tests/web/native/lib.dart::defaultArg",
+ "kind": "function",
+ "name": "defaultArg",
+ "size": 95,
+ "outputUnit": "outputUnit/1",
+ "parent": "library/memory:sdk/tests/web/native/lib.dart::",
+ "children": [],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "dynamic",
+ "inferredReturnType": "Value([exact=JSString], value: \"\")",
+ "parameters": [],
+ "sideEffects": "SideEffects(reads nothing; writes nothing)",
+ "inlinedCount": 0,
+ "code": "_static_0(A, \"lib__defaultArg$closure\", \"defaultArg\", 0);\n\ndefaultArg() {\n return \"\";\n }",
+ "type": "dynamic Function()"
+}]*/
+defaultArg() => "";
+
+/*member: funky:function=[{
+ "id": "function/memory:sdk/tests/web/native/lib.dart::funky",
+ "kind": "function",
+ "name": "funky",
+ "size": 194,
+ "outputUnit": "outputUnit/1",
+ "parent": "library/memory:sdk/tests/web/native/lib.dart::",
+ "children": [],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "dynamic",
+ "inferredReturnType": "[null|subclass=Object]",
+ "parameters": [
+ {
+ "name": "x",
+ "type": "[subclass=Closure]",
+ "declaredType": "dynamic"
+ }
+ ],
+ "sideEffects": "SideEffects(reads anything; writes anything)",
+ "inlinedCount": 0,
+ "code": "_static(A, \"lib__funky$closure\", 0, null, [\"call$1\", \"call$0\"], [\"funky\", function() {\n return A.funky(A.lib__defaultArg$closure());\n }], 1, 0);\n\nfunky(x) {\n return x.call$0();\n }",
+ "type": "dynamic Function([dynamic])"
+}]*/
+funky([x = defaultArg]) => x();
+
+final int notUsed = 3;
diff --git a/pkg/compiler/test/dump_info/data/deferred/main.dart b/pkg/compiler/test/dump_info/data/deferred/main.dart
new file mode 100644
index 0000000..7e1cee2
--- /dev/null
+++ b/pkg/compiler/test/dump_info/data/deferred/main.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2017, 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.
+
+// @dart = 2.7
+
+/*library: library=[{
+ "id": "library/memory:sdk/tests/web/native/main.dart::",
+ "kind": "library",
+ "name": "<unnamed>",
+ "size": 301,
+ "children": [
+ "function/memory:sdk/tests/web/native/main.dart::main"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/main.dart"
+}]*/
+
+import 'lib.dart' deferred as lib;
+
+/*member: main:
+ function=[{
+ "id": "function/memory:sdk/tests/web/native/main.dart::main",
+ "kind": "function",
+ "name": "main",
+ "size": 301,
+ "outputUnit": "outputUnit/main",
+ "parent": "library/memory:sdk/tests/web/native/main.dart::",
+ "children": [
+ "closure/memory:sdk/tests/web/native/main.dart::main.main_closure"
+ ],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "dynamic",
+ "inferredReturnType": "[exact=_Future]",
+ "parameters": [],
+ "sideEffects": "SideEffects(reads anything; writes anything)",
+ "inlinedCount": 0,
+ "code": "main() {\n return A.loadDeferredLibrary(\"lib\").then$1$1(new A.main_closure(), type$.Null);\n }",
+ "type": "dynamic Function()"
+}],
+ holding=[
+ {"id":"function/dart:_js_helper::loadDeferredLibrary","mask":null},
+ {"id":"function/dart:_rti::_setArrayType","mask":null},
+ {"id":"function/dart:_rti::findType","mask":null},
+ {"id":"function/dart:async::_Future.then","mask":"[exact=_Future]"},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::main.main_closure.call","mask":null},
+ {"id":"function/memory:sdk/tests/web/native/main.dart::main.main_closure.call","mask":null}]
+*/
+main() => lib.loadLibrary().then((_) {
+ (lib.funky)();
+ });
diff --git a/pkg/compiler/test/dump_info/data/deferred_future/lib1.dart b/pkg/compiler/test/dump_info/data/deferred_future/lib1.dart
new file mode 100644
index 0000000..4c3cfcd
--- /dev/null
+++ b/pkg/compiler/test/dump_info/data/deferred_future/lib1.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2019, 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: library=[{
+ "id": "library/memory:sdk/tests/web/native/lib1.dart::",
+ "kind": "library",
+ "name": "<unnamed>",
+ "size": 0,
+ "children": [],
+ "canonicalUri": "memory:sdk/tests/web/native/lib1.dart"
+}]*/
+
+// @dart = 2.7
+
+import 'lib2.dart';
+
+const dynamic field = const A();
diff --git a/pkg/compiler/test/dump_info/data/deferred_future/lib2.dart b/pkg/compiler/test/dump_info/data/deferred_future/lib2.dart
new file mode 100644
index 0000000..81cc3a1
--- /dev/null
+++ b/pkg/compiler/test/dump_info/data/deferred_future/lib2.dart
@@ -0,0 +1,44 @@
+// Copyright (c) 2019, 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: library=[{
+ "id": "library/memory:sdk/tests/web/native/lib2.dart::",
+ "kind": "library",
+ "name": "<unnamed>",
+ "size": 68,
+ "children": [
+ "class/memory:sdk/tests/web/native/lib2.dart::A"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/lib2.dart"
+}]*/
+
+// @dart = 2.7
+
+class A {
+ const A();
+
+ /*member: A.method:function=[{
+ "id": "function/memory:sdk/tests/web/native/lib2.dart::A.method",
+ "kind": "function",
+ "name": "method",
+ "size": 0,
+ "outputUnit": "outputUnit/1",
+ "parent": "class/memory:sdk/tests/web/native/lib2.dart::A",
+ "children": [],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "dynamic",
+ "inferredReturnType": "[null]",
+ "parameters": [],
+ "sideEffects": "SideEffects(reads nothing; writes nothing)",
+ "inlinedCount": 1,
+ "code": "",
+ "type": "dynamic Function()"
+}]*/
+ method() {}
+}
diff --git a/pkg/compiler/test/dump_info/data/deferred_future/main.dart b/pkg/compiler/test/dump_info/data/deferred_future/main.dart
new file mode 100644
index 0000000..10e2e59
--- /dev/null
+++ b/pkg/compiler/test/dump_info/data/deferred_future/main.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2019, 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: library=[{
+ "id": "library/memory:sdk/tests/web/native/main.dart::",
+ "kind": "library",
+ "name": "<unnamed>",
+ "size": 857,
+ "children": [
+ "function/memory:sdk/tests/web/native/main.dart::main"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/main.dart"
+}]*/
+
+// @dart = 2.7
+
+import 'dart:async';
+import 'lib1.dart' deferred as lib1;
+import 'lib2.dart' as lib2;
+
+/*member: main:
+ function=[{
+ "id": "function/memory:sdk/tests/web/native/main.dart::main",
+ "kind": "function",
+ "name": "main",
+ "size": 857,
+ "outputUnit": "outputUnit/main",
+ "parent": "library/memory:sdk/tests/web/native/main.dart::",
+ "children": [],
+ "modifiers": {
+ "static": false,
+ "const": false,
+ "factory": false,
+ "external": false
+ },
+ "returnType": "dynamic",
+ "inferredReturnType": "[exact=_Future]",
+ "parameters": [],
+ "sideEffects": "SideEffects(reads nothing; writes nothing)",
+ "inlinedCount": 0,
+ "code": "main() {\n var $async$goto = 0,\n $async$completer = A._makeAsyncAwaitCompleter(type$.dynamic);\n var $async$main = A._wrapJsFunctionForAsync(function($async$errorCode, $async$result) {\n if ($async$errorCode === 1)\n return A._asyncRethrow($async$result, $async$completer);\n while (true)\n switch ($async$goto) {\n case 0:\n // Function start\n $async$goto = 2;\n return A._asyncAwait(A.loadDeferredLibrary(\"lib1\"), $async$main);\n case 2:\n // returning from await.\n A.checkDeferredIsLoaded(\"lib1\");\n A.checkDeferredIsLoaded(\"lib1\");\n // implicit return\n return A._asyncReturn(null, $async$completer);\n }\n });\n return A._asyncStartSync($async$main, $async$completer);\n }",
+ "type": "dynamic Function()"
+}],
+ holding=[
+ {"id":"function/dart:_js_helper::checkDeferredIsLoaded","mask":null},
+ {"id":"function/dart:_js_helper::loadDeferredLibrary","mask":null},
+ {"id":"function/dart:_rti::findType","mask":null},
+ {"id":"function/dart:async::StreamIterator.StreamIterator","mask":null},
+ {"id":"function/dart:async::_asyncAwait","mask":null},
+ {"id":"function/dart:async::_asyncRethrow","mask":null},
+ {"id":"function/dart:async::_asyncReturn","mask":null},
+ {"id":"function/dart:async::_asyncStartSync","mask":null},
+ {"id":"function/dart:async::_makeAsyncAwaitCompleter","mask":null},
+ {"id":"function/dart:async::_wrapJsFunctionForAsync","mask":null},
+ {"id":"function/memory:sdk/tests/web/native/lib2.dart::A.method","mask":"inlined"},
+ {"id":"function/memory:sdk/tests/web/native/lib2.dart::A.method","mask":null}]
+*/
+main() async {
+ await lib1.loadLibrary();
+ lib1.field is FutureOr<lib2.A>;
+ lib1.field.method();
+}
diff --git a/pkg/compiler/test/dump_info/data/js_members.dart b/pkg/compiler/test/dump_info/data/js_members.dart
index 0d2e390..db9ca6b 100644
--- a/pkg/compiler/test/dump_info/data/js_members.dart
+++ b/pkg/compiler/test/dump_info/data/js_members.dart
@@ -1,3 +1,15 @@
+/*library: library=[{
+ "id": "library/memory:sdk/tests/web/native/main.dart::",
+ "kind": "library",
+ "name": "js_parameters_test",
+ "size": 1891,
+ "children": [
+ "class/memory:sdk/tests/web/native/main.dart::Bar",
+ "class/memory:sdk/tests/web/native/main.dart::Foo",
+ "function/memory:sdk/tests/web/native/main.dart::main"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/main.dart"
+}]*/
@JS()
library js_parameters_test;
diff --git a/pkg/compiler/test/dump_info/data/members.dart b/pkg/compiler/test/dump_info/data/members.dart
index 326e97c..8538881 100644
--- a/pkg/compiler/test/dump_info/data/members.dart
+++ b/pkg/compiler/test/dump_info/data/members.dart
@@ -1,3 +1,18 @@
+/*library: library=[{
+ "id": "library/memory:sdk/tests/web/native/main.dart::",
+ "kind": "library",
+ "name": "<unnamed>",
+ "size": 475,
+ "children": [
+ "class/memory:sdk/tests/web/native/main.dart::A",
+ "class/memory:sdk/tests/web/native/main.dart::C",
+ "classType/memory:sdk/tests/web/native/main.dart::A",
+ "field/memory:sdk/tests/web/native/main.dart::constList",
+ "function/memory:sdk/tests/web/native/main.dart::F",
+ "function/memory:sdk/tests/web/native/main.dart::main"
+ ],
+ "canonicalUri": "memory:sdk/tests/web/native/main.dart"
+}]*/
class C {
/*member: C.value:
function=[{
diff --git a/pkg/compiler/test/dump_info/dump_info_test.dart b/pkg/compiler/test/dump_info/dump_info_test.dart
index 9a36426..b27abdf 100644
--- a/pkg/compiler/test/dump_info/dump_info_test.dart
+++ b/pkg/compiler/test/dump_info/dump_info_test.dart
@@ -52,21 +52,41 @@
static const String wildcard = '%';
@override
- void computeMemberData(Compiler compiler, MemberEntity member,
+ void computeLibraryData(Compiler compiler, LibraryEntity library,
Map<Id, ActualData<Features>> actualMap,
- {bool verbose: false}) {
- var converter = info.AllInfoToJsonConverter(
+ {bool verbose}) {
+ final converter = info.AllInfoToJsonConverter(
isBackwardCompatible: true, filterTreeshaken: false);
DumpInfoStateData dumpInfoState = compiler.dumpInfoStateForTesting;
Features features = new Features();
- var functionInfo = dumpInfoState.entityToInfo[member];
+ final libraryInfo = dumpInfoState.entityToInfo[library];
+ if (libraryInfo == null) return;
+
+ features.addElement(
+ Tags.library, indentedEncoder.convert(libraryInfo.accept(converter)));
+
+ final id = LibraryId(library.canonicalUri);
+ actualMap[id] = new ActualData<Features>(
+ id, features, library.canonicalUri, -1, library);
+ }
+
+ @override
+ void computeMemberData(Compiler compiler, MemberEntity member,
+ Map<Id, ActualData<Features>> actualMap,
+ {bool verbose: false}) {
+ final converter = info.AllInfoToJsonConverter(
+ isBackwardCompatible: true, filterTreeshaken: false);
+ DumpInfoStateData dumpInfoState = compiler.dumpInfoStateForTesting;
+
+ Features features = new Features();
+ final functionInfo = dumpInfoState.entityToInfo[member];
if (functionInfo == null) return;
if (functionInfo is info.FunctionInfo) {
features.addElement(Tags.function,
indentedEncoder.convert(functionInfo.accept(converter)));
- for (var use in functionInfo.uses) {
+ for (final use in functionInfo.uses) {
features.addElement(
Tags.holding, encoder.convert(converter.visitDependencyInfo(use)));
}
@@ -75,7 +95,7 @@
if (functionInfo is info.FieldInfo) {
features.addElement(Tags.function,
indentedEncoder.convert(functionInfo.accept(converter)));
- for (var use in functionInfo.uses) {
+ for (final use in functionInfo.uses) {
features.addElement(
Tags.holding, encoder.convert(converter.visitDependencyInfo(use)));
}
@@ -138,7 +158,7 @@
expectedText.substring(0, expectedText.indexOf(wildcard));
List matches = [];
for (Object actualObject in actualList) {
- var formattedActualObject =
+ final formattedActualObject =
encoder.convert(jsonDecode(actualObject));
if (formattedActualObject.startsWith(prefix)) {
matches.add(actualObject);
@@ -150,7 +170,7 @@
}
} else {
for (Object actualObject in actualList) {
- var formattedActualObject =
+ final formattedActualObject =
encoder.convert(jsonDecode(actualObject));
if (expectedText == formattedActualObject) {
actualList.remove(actualObject);
diff --git a/tools/VERSION b/tools/VERSION
index 088c41a..54c3858 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 18
PATCH 0
-PRERELEASE 51
+PRERELEASE 52
PRERELEASE_PATCH 0
\ No newline at end of file