Version 2.18.0-205.0.dev
Merge commit 'cb5c93d2da3cf385ee35d7dca33199f9d5e96ddf' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
index daa8e97..ade3b53 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
@@ -15,6 +15,7 @@
import 'package:analyzer/src/task/options.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer/src/util/yaml.dart';
+import 'package:analyzer/src/utilities/extensions/file_system.dart';
import 'package:analyzer/src/workspace/basic.dart';
import 'package:analyzer/src/workspace/bazel.dart';
import 'package:analyzer/src/workspace/gn.dart';
@@ -185,7 +186,7 @@
if (defaultOptionsFile != null) {
optionsFile = defaultOptionsFile;
} else {
- optionsFile = _findOptionsFile(parent);
+ optionsFile = parent.findAnalysisOptionsYamlFile();
optionsFolderToChooseRoot = optionsFile?.parent;
}
@@ -271,7 +272,7 @@
//
File? localOptionsFile;
if (optionsFile == null) {
- localOptionsFile = _getOptionsFile(folder);
+ localOptionsFile = folder.existingAnalysisOptionsYamlFile;
}
File? localPackagesFile;
if (packagesFile == null) {
@@ -406,19 +407,6 @@
return null;
}
- /// Return the analysis options file to be used to analyze files in the given
- /// [folder], or `null` if there is no analysis options file in the given
- /// folder or any parent folder.
- File? _findOptionsFile(Folder folder) {
- for (var current in folder.withAncestors) {
- var file = _getOptionsFile(current);
- if (file != null) {
- return file;
- }
- }
- return null;
- }
-
/// Return the packages file to be used to analyze files in the given
/// [folder], or `null` if there is no packages file in the given folder or
/// any parent folder.
@@ -480,18 +468,6 @@
return patterns;
}
- /// If the given [directory] contains a file with the given [name], then
- /// return the file. Otherwise, return `null`.
- File? _getFile(Folder directory, String name) {
- var file = directory.getChildAssumingFile(name);
- return file.exists ? file : null;
- }
-
- /// Return the analysis options file in the given [folder], or `null` if the
- /// folder does not contain an analysis options file.
- File? _getOptionsFile(Folder folder) =>
- _getFile(folder, file_paths.analysisOptionsYaml);
-
/// Return the packages file in the given [folder], or `null` if the folder
/// does not contain a packages file.
File? _getPackagesFile(Folder folder) {
diff --git a/pkg/analyzer/lib/src/dart/micro/cider_byte_store.dart b/pkg/analyzer/lib/src/dart/micro/cider_byte_store.dart
deleted file mode 100644
index 91e96e3..0000000
--- a/pkg/analyzer/lib/src/dart/micro/cider_byte_store.dart
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (c) 2020, 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.
-
-@Deprecated('Use ByteStore directly instead')
-library cider_byte_store;
-
-import 'package:analyzer/src/dart/analysis/byte_store.dart';
-
-@Deprecated('Use ByteStore directly instead')
-typedef CiderByteStore = ByteStore;
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index cb43de1..cea7103 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -37,8 +37,8 @@
import 'package:analyzer/src/summary2/link.dart';
import 'package:analyzer/src/summary2/linked_element_factory.dart';
import 'package:analyzer/src/task/options.dart';
-import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer/src/util/performance/operation_performance.dart';
+import 'package:analyzer/src/utilities/extensions/file_system.dart';
import 'package:analyzer/src/workspace/workspace.dart';
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
@@ -735,16 +735,6 @@
}
}
- File? _findOptionsFile(Folder folder) {
- for (var current in folder.withAncestors) {
- var file = _getFile(current, file_paths.analysisOptionsYaml);
- if (file != null) {
- return file;
- }
- }
- return null;
- }
-
/// Return the analysis options.
///
/// If the [path] is not `null`, read it.
@@ -766,9 +756,9 @@
File? optionsFile;
if (!isThirdParty) {
- optionsFile = performance.run('findOptionsFile', (_) {
+ optionsFile = performance.run('findAnalysisOptionsYamlFile', (_) {
var folder = resourceProvider.getFile(path).parent;
- return _findOptionsFile(folder);
+ return folder.findAnalysisOptionsYamlFile();
});
}
@@ -777,9 +767,7 @@
try {
var optionsProvider = AnalysisOptionsProvider(sourceFactory);
optionMap = optionsProvider.getOptionsFromFile(optionsFile!);
- } catch (e) {
- // ignored
- }
+ } catch (_) {}
});
} else {
var source = performance.run('defaultOptions', (_) {
@@ -802,9 +790,7 @@
try {
var optionsProvider = AnalysisOptionsProvider(sourceFactory);
optionMap = optionsProvider.getOptionsFromSource(source);
- } catch (e) {
- // ignored
- }
+ } catch (_) {}
});
}
}
@@ -853,11 +839,6 @@
);
}
}
-
- static File? _getFile(Folder directory, String name) {
- var file = directory.getChildAssumingFile(name);
- return file.exists ? file : null;
- }
}
class FileResolverTestView {
diff --git a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
index 497160f..27c1357 100644
--- a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
@@ -101,10 +101,12 @@
var reader = _libraryReaders[uri];
if (reader == null) {
- var libraryUriList = rootReference.children.map((e) => e.name).toList();
+ final rootChildren = rootReference.children.map((e) => e.name).toList();
throw ArgumentError(
'Missing library: $uri\n'
- 'Available libraries: $libraryUriList',
+ 'Libraries: $uriListWithLibraryElements'
+ 'Root children: $rootChildren'
+ 'Readers: ${_libraryReaders.keys.toList()}',
);
}
diff --git a/pkg/analyzer/lib/src/utilities/extensions/file_system.dart b/pkg/analyzer/lib/src/utilities/extensions/file_system.dart
new file mode 100644
index 0000000..6a629b5
--- /dev/null
+++ b/pkg/analyzer/lib/src/utilities/extensions/file_system.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2022, 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:analyzer/file_system/file_system.dart';
+import 'package:analyzer/src/util/file_paths.dart' as file_paths;
+
+extension FolderExtension on Folder {
+ /// Returns the existing analysis options file in the target, or `null`.
+ File? get existingAnalysisOptionsYamlFile {
+ return getExistingFile(file_paths.analysisOptionsYaml);
+ }
+
+ /// Return the analysis options file to be used for files in the target.
+ File? findAnalysisOptionsYamlFile() {
+ for (final current in withAncestors) {
+ final file = current.existingAnalysisOptionsYamlFile;
+ if (file != null) {
+ return file;
+ }
+ }
+ return null;
+ }
+
+ /// If the target contains an existing file with the given [name], then
+ /// returns it. Otherwise, return `null`.
+ File? getExistingFile(String name) {
+ final file = getChildAssumingFile(name);
+ return file.exists ? file : null;
+ }
+}
diff --git a/pkg/compiler/lib/src/js_backend/field_analysis.dart b/pkg/compiler/lib/src/js_backend/field_analysis.dart
index b22fb53..f2ba357 100644
--- a/pkg/compiler/lib/src/js_backend/field_analysis.dart
+++ b/pkg/compiler/lib/src/js_backend/field_analysis.dart
@@ -14,7 +14,7 @@
import '../elements/types.dart';
import '../ir/scope_visitor.dart';
import '../js_model/elements.dart' show JField;
-import '../js_model/js_world_builder.dart' show JsToFrontendMap;
+import '../js_model/js_to_frontend_map.dart' show JsToFrontendMap;
import '../kernel/element_map.dart';
import '../kernel/kernel_strategy.dart';
import '../kernel/kelements.dart' show KClass, KField, KConstructor;
diff --git a/pkg/compiler/lib/src/js_backend/native_data.dart b/pkg/compiler/lib/src/js_backend/native_data.dart
index 4226f5a..348af11 100644
--- a/pkg/compiler/lib/src/js_backend/native_data.dart
+++ b/pkg/compiler/lib/src/js_backend/native_data.dart
@@ -12,7 +12,7 @@
import '../common/elements.dart' show ElementEnvironment;
import '../elements/entities.dart';
import '../ir/annotations.dart';
-import '../js_model/js_world_builder.dart' show identity, JsToFrontendMap;
+import '../js_model/js_to_frontend_map.dart' show identity, JsToFrontendMap;
import '../kernel/element_map.dart';
import '../native/behavior.dart' show NativeBehavior;
import '../serialization/serialization_interfaces.dart';
diff --git a/pkg/compiler/lib/src/js_model/js_strategy.dart b/pkg/compiler/lib/src/js_model/js_strategy.dart
index 9b2fcd42..54a43e6 100644
--- a/pkg/compiler/lib/src/js_model/js_strategy.dart
+++ b/pkg/compiler/lib/src/js_model/js_strategy.dart
@@ -61,7 +61,7 @@
import 'element_map.dart';
import 'element_map_impl.dart';
import 'js_world.dart';
-import 'js_world_builder.dart';
+import 'js_world_builder.dart' show JsClosedWorldBuilder;
import 'locals.dart';
/// JS Strategy pattern that defines the element model used in type inference
diff --git a/pkg/compiler/lib/src/js_model/js_to_frontend_map.dart b/pkg/compiler/lib/src/js_model/js_to_frontend_map.dart
new file mode 100644
index 0000000..aa5cdac
--- /dev/null
+++ b/pkg/compiler/lib/src/js_model/js_to_frontend_map.dart
@@ -0,0 +1,95 @@
+// Copyright (c) 2018, 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 '../constants/values.dart';
+import '../elements/entities.dart';
+import '../elements/types.dart';
+
+/// Map from 'frontend' to 'backend' elements.
+///
+/// Frontend elements are what we read in, these typically represents concepts
+/// in Dart. Backend elements are what we generate, these may include elements
+/// that do not correspond to a Dart concept, such as closure classes.
+///
+/// Querying for the frontend element for a backend-only element throws an
+/// exception.
+abstract class JsToFrontendMap {
+ LibraryEntity toBackendLibrary(LibraryEntity library);
+
+ ClassEntity toBackendClass(ClassEntity cls);
+
+ /// Returns the backend member corresponding to [member]. If a member isn't
+ /// live, it doesn't have a corresponding backend member and `null` is
+ /// returned instead.
+ MemberEntity? toBackendMember(MemberEntity member);
+
+ DartType toBackendType(DartType type, {bool allowFreeVariables = false});
+
+ ConstantValue toBackendConstant(ConstantValue value,
+ {bool allowNull = false});
+
+ Set<LibraryEntity> toBackendLibrarySet(Iterable<LibraryEntity> set) {
+ return set.map(toBackendLibrary).toSet();
+ }
+
+ Set<ClassEntity> toBackendClassSet(Iterable<ClassEntity> set) {
+ // TODO(johnniwinther): Filter unused classes.
+ return set.map(toBackendClass).toSet();
+ }
+
+ Set<MemberEntity> toBackendMemberSet(Iterable<MemberEntity> set) {
+ return {
+ for (final member in set.map(toBackendMember))
+ // Members that are not live don't have a corresponding backend member.
+ if (member != null) member
+ };
+ }
+
+ Set<FieldEntity> toBackendFieldSet(Iterable<FieldEntity> set) {
+ return {
+ for (final member in set.map(toBackendMember))
+ // Members that are not live don't have a corresponding backend member.
+ if (member != null) member as FieldEntity
+ };
+ }
+
+ Set<FunctionEntity> toBackendFunctionSet(Iterable<FunctionEntity> set) {
+ return {
+ for (final member in set.map(toBackendMember))
+ // Members that are not live don't have a corresponding backend member.
+ if (member != null) member as FunctionEntity
+ };
+ }
+
+ Map<LibraryEntity, V> toBackendLibraryMap<V>(
+ Map<LibraryEntity, V> map, V convert(V value)) {
+ return convertMap(map, toBackendLibrary, convert);
+ }
+
+ Map<ClassEntity, V> toBackendClassMap<V>(
+ Map<ClassEntity, V> map, V convert(V value)) {
+ return convertMap(map, toBackendClass, convert);
+ }
+
+ Map<MemberEntity, V2> toBackendMemberMap<V1, V2>(
+ Map<MemberEntity, V1> map, V2 convert(V1 value)) {
+ return convertMap(map, toBackendMember, convert);
+ }
+}
+
+E identity<E>(E element) => element;
+
+Map<K, V2> convertMap<K, V1, V2>(
+ Map<K, V1> map, K? convertKey(K key), V2 convertValue(V1 value)) {
+ Map<K, V2> newMap = {};
+ map.forEach((K key, V1 value) {
+ K? newKey = convertKey(key);
+ V2 newValue = convertValue(value);
+ if (newKey != null && newValue != null) {
+ // Entities that are not used don't have a corresponding backend entity.
+ newMap[newKey] = newValue;
+ }
+ });
+ return newMap;
+}
diff --git a/pkg/compiler/lib/src/js_model/js_world_builder.dart b/pkg/compiler/lib/src/js_model/js_world_builder.dart
index e9b5662..7957441 100644
--- a/pkg/compiler/lib/src/js_model/js_world_builder.dart
+++ b/pkg/compiler/lib/src/js_model/js_world_builder.dart
@@ -36,6 +36,7 @@
import 'closure.dart';
import 'elements.dart';
import 'element_map_impl.dart';
+import 'js_to_frontend_map.dart';
import 'js_world.dart';
class JsClosedWorldBuilder {
@@ -184,7 +185,7 @@
rtiNeed = jRtiNeed;
}
- map.registerClosureData(closureData);
+ (map as JsToFrontendMapImpl)._registerClosureData(closureData);
BackendUsage backendUsage =
_convertBackendUsage(map, closedWorld.backendUsage);
@@ -502,107 +503,7 @@
rtiNeed.instantiationNeedsTypeArguments(functionType, typeArgumentCount);
}
-/// Map from 'frontend' to 'backend' elements.
-///
-/// Frontend elements are what we read in, these typically represents concepts
-/// in Dart. Backend elements are what we generate, these may include elements
-/// that do not correspond to a Dart concept, such as closure classes.
-///
-/// Querying for the frontend element for a backend-only element throws an
-/// exception.
-abstract class JsToFrontendMap {
- LibraryEntity toBackendLibrary(LibraryEntity library);
-
- ClassEntity toBackendClass(ClassEntity cls);
-
- /// Returns the backend member corresponding to [member]. If a member isn't
- /// live, it doesn't have a corresponding backend member and `null` is
- /// returned instead.
- MemberEntity toBackendMember(MemberEntity member);
-
- DartType toBackendType(DartType type, {bool allowFreeVariables = false});
-
- ConstantValue toBackendConstant(ConstantValue value,
- {bool allowNull = false});
-
- /// Register [closureData] with this map.
- ///
- /// [ClosureData] holds the relation between local function and the backend
- /// entities. Before this has been registered, type variables of local
- /// functions cannot be converted into backend equivalents.
- void registerClosureData(ClosureData closureData);
-
- Set<LibraryEntity> toBackendLibrarySet(Iterable<LibraryEntity> set) {
- return set.map(toBackendLibrary).toSet();
- }
-
- Set<ClassEntity> toBackendClassSet(Iterable<ClassEntity> set) {
- // TODO(johnniwinther): Filter unused classes.
- return set.map(toBackendClass).toSet();
- }
-
- Set<MemberEntity> toBackendMemberSet(Iterable<MemberEntity> set) {
- return set.map(toBackendMember).where((MemberEntity member) {
- // Members that are not live don't have a corresponding backend member.
- return member != null;
- }).toSet();
- }
-
- Set<FieldEntity> toBackendFieldSet(Iterable<FieldEntity> set) {
- Set<FieldEntity> newSet = Set<FieldEntity>();
- for (FieldEntity element in set) {
- FieldEntity backendField = toBackendMember(element);
- if (backendField != null) {
- // Members that are not live don't have a corresponding backend member.
- newSet.add(backendField);
- }
- }
- return newSet;
- }
-
- Set<FunctionEntity> toBackendFunctionSet(Iterable<FunctionEntity> set) {
- Set<FunctionEntity> newSet = Set<FunctionEntity>();
- for (FunctionEntity element in set) {
- FunctionEntity backendFunction = toBackendMember(element);
- if (backendFunction != null) {
- // Members that are not live don't have a corresponding backend member.
- newSet.add(backendFunction);
- }
- }
- return newSet;
- }
-
- Map<LibraryEntity, V> toBackendLibraryMap<V>(
- Map<LibraryEntity, V> map, V convert(V value)) {
- return convertMap(map, toBackendLibrary, convert);
- }
-
- Map<ClassEntity, V> toBackendClassMap<V>(
- Map<ClassEntity, V> map, V convert(V value)) {
- return convertMap(map, toBackendClass, convert);
- }
-
- Map<MemberEntity, V2> toBackendMemberMap<V1, V2>(
- Map<MemberEntity, V1> map, V2 convert(V1 value)) {
- return convertMap(map, toBackendMember, convert);
- }
-}
-
-E identity<E>(E element) => element;
-
-Map<K, V2> convertMap<K, V1, V2>(
- Map<K, V1> map, K convertKey(K key), V2 convertValue(V1 value)) {
- Map<K, V2> newMap = {};
- map.forEach((K key, V1 value) {
- K newKey = convertKey(key);
- V2 newValue = convertValue(value);
- if (newKey != null && newValue != null) {
- // Entities that are not used don't have a corresponding backend entity.
- newMap[newKey] = newValue;
- }
- });
- return newMap;
-}
+// TODO(48820): Possibly move contents of js_to_frontend_map.dart back here.
class JsToFrontendMapImpl extends JsToFrontendMap {
final JsKernelToElementMap _backend;
@@ -643,8 +544,7 @@
return _backend.members.getEntity(member.memberIndex);
}
- @override
- void registerClosureData(ClosureData closureData) {
+ void _registerClosureData(ClosureData closureData) {
assert(_closureData == null, "Closure data has already been registered.");
_closureData = closureData;
}
diff --git a/pkg/compiler/lib/src/native/behavior.dart b/pkg/compiler/lib/src/native/behavior.dart
index 545440e..3c1e721 100644
--- a/pkg/compiler/lib/src/native/behavior.dart
+++ b/pkg/compiler/lib/src/native/behavior.dart
@@ -10,8 +10,8 @@
import '../elements/entities.dart';
import '../elements/types.dart';
import '../js/js.dart' as js;
-import '../js_backend/native_data.dart' show NativeBasicData;
-import '../js_model/js_world_builder.dart' show JsToFrontendMap;
+import '../js_backend/native_data_interfaces.dart' show NativeBasicData;
+import '../js_model/js_to_frontend_map.dart' show JsToFrontendMap;
import '../options.dart';
import '../serialization/serialization_interfaces.dart';
import '../universe/side_effects.dart' show SideEffects;
diff --git a/pkg/dart2js_info/bin/src/convert.dart b/pkg/dart2js_info/bin/src/convert.dart
index e698029..7439957 100644
--- a/pkg/dart2js_info/bin/src/convert.dart
+++ b/pkg/dart2js_info/bin/src/convert.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.11
-
import 'package:args/command_runner.dart';
import 'to_json.dart' show ToJsonCommand;
diff --git a/pkg/dart2js_info/bin/src/debug_info.dart b/pkg/dart2js_info/bin/src/debug_info.dart
index 24b2298..5a237e4 100644
--- a/pkg/dart2js_info/bin/src/debug_info.dart
+++ b/pkg/dart2js_info/bin/src/debug_info.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.11
-
/// Tool used mainly by dart2js developers to debug the generated info and check
/// that it is consistent and that it covers all the data we expect it to cover.
library dart2js_info.bin.debug_info;
@@ -29,13 +27,14 @@
@override
void run() async {
- var args = argResults.rest;
+ final argRes = argResults!;
+ final args = argRes.rest;
if (args.isEmpty) {
usageException('Missing argument: info.data');
}
- var info = await infoFromFile(args.first);
- var debugLibName = argResults['show-library'];
+ final info = await infoFromFile(args.first);
+ final debugLibName = argRes['show-library'];
validateSize(info, debugLibName);
validateParents(info);
@@ -47,14 +46,14 @@
/// Validates that codesize of elements adds up to total codesize.
validateSize(AllInfo info, String debugLibName) {
// Gather data from visiting all info elements.
- var tracker = _SizeTracker(debugLibName);
+ final tracker = _SizeTracker(debugLibName);
info.accept(tracker);
// Validate that listed elements include elements of each library.
final listed = {...info.functions, ...info.fields};
// For our sanity we do some validation of dump-info invariants
- var diff1 = listed.difference(tracker.discovered);
- var diff2 = tracker.discovered.difference(listed);
+ final diff1 = listed.difference(tracker.discovered);
+ final diff2 = tracker.discovered.difference(listed);
if (diff1.isEmpty || diff2.isEmpty) {
_pass('all fields and functions are covered');
} else {
@@ -69,7 +68,7 @@
}
// Validate that code-size adds up.
- int realTotal = info.program.size;
+ final realTotal = info.program!.size;
int totalLib = info.libraries.fold(0, (n, lib) => n + lib.size);
int constantsSize = info.constants.fold(0, (n, c) => n + c.size);
int accounted = totalLib + constantsSize;
@@ -114,7 +113,7 @@
class _SizeTracker extends RecursiveInfoVisitor {
/// A library name for which to print debugging information (if not null).
- final String _debugLibName;
+ final String? _debugLibName;
_SizeTracker(this._debugLibName);
@@ -141,7 +140,7 @@
void _push() => stack.add(_State());
- void _pop(info) {
+ void _pop(Info info) {
var last = stack.removeLast();
var size = last._totalSize;
if (size > info.size) {
@@ -162,7 +161,7 @@
bool _debug = false;
@override
visitLibrary(LibraryInfo info) {
- if (_debugLibName != null) _debug = info.name.contains(_debugLibName);
+ if (_debugLibName != null) _debug = info.name.contains(_debugLibName!);
_push();
if (_debug) {
_debugCode.write('{\n');
@@ -204,8 +203,8 @@
_debugCode.write('},\n');
}
}
- stack.last._totalSize += info.size;
- stack.last._bodySize += info.size;
+ stack.last._totalSize += (info.size as int);
+ stack.last._bodySize += (info.size as int);
stack.last._count++;
}
@@ -282,7 +281,7 @@
}
g2.addNode(f);
if (info.dependencies[f] != null) {
- for (var g in info.dependencies[f]) {
+ for (var g in info.dependencies[f]!) {
g2.addEdge(f, g);
}
}
@@ -295,7 +294,7 @@
}
g2.addNode(f);
if (info.dependencies[f] != null) {
- for (var g in info.dependencies[f]) {
+ for (var g in info.dependencies[f]!) {
g2.addEdge(f, g);
}
}
@@ -327,7 +326,7 @@
// graph.
verifyDeps(AllInfo info) {
var graph = graphFromInfo(info);
- var entrypoint = info.program.entrypoint;
+ var entrypoint = info.program!.entrypoint;
var reachables = Set.from(graph.preOrder(entrypoint));
var functionsAndFields = <BasicInfo>[...info.functions, ...info.fields];
diff --git a/pkg/dart2js_info/bin/src/deferred_library_layout.dart b/pkg/dart2js_info/bin/src/deferred_library_layout.dart
index 7dc279a..0e3416b 100644
--- a/pkg/dart2js_info/bin/src/deferred_library_layout.dart
+++ b/pkg/dart2js_info/bin/src/deferred_library_layout.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.11
-
/// This tool reports how code is divided among deferred chunks.
library dart2js_info.bin.deferred_library_layout;
@@ -24,7 +22,7 @@
@override
void run() async {
- var args = argResults.rest;
+ final args = argResults!.rest;
if (args.isEmpty) {
usageException('Missing argument: info.data');
}
@@ -38,8 +36,8 @@
Map<OutputUnitInfo, Map<LibraryInfo, List<BasicInfo>>> hunkMembers = {};
Map<LibraryInfo, Set<OutputUnitInfo>> libToHunks = {};
void register(BasicInfo info) {
- var unit = info.outputUnit;
- var lib = _libOf(info);
+ final unit = info.outputUnit!;
+ final lib = _libOf(info);
if (lib == null) return;
libToHunks.putIfAbsent(lib, () => <OutputUnitInfo>{}).add(unit);
hunkMembers
@@ -54,10 +52,10 @@
info.fields.forEach(register);
info.closures.forEach(register);
- var dir = Directory.current.path;
+ final dir = Directory.current.path;
hunkMembers.forEach((unit, map) {
- print('Output unit ${unit.name ?? "main"}:');
- if (unit.name == null || unit.name == 'main') {
+ print('Output unit ${unit.name}:');
+ if (unit.name == 'main') {
print(' loaded by default');
} else {
print(' loaded by importing: ${unit.imports}');
@@ -65,18 +63,18 @@
print(' contains:');
map.forEach((lib, elements) {
- var uri = lib.uri;
- var shortUri = (uri.isScheme('file') && uri.path.startsWith(dir))
+ final uri = lib.uri;
+ final shortUri = (uri.isScheme('file') && uri.path.startsWith(dir))
? uri.path.substring(dir.length + 1)
: '$uri';
// If the entire library is in one chunk, just report the library name
// otherwise report which functions are on this chunk.
- if (libToHunks[lib].length == 1) {
+ if (libToHunks[lib]!.length == 1) {
print(' - $shortUri');
} else {
print(' - $shortUri:');
- for (var e in elements) {
+ for (final e in elements) {
print(' - ${kindToString(e.kind)} ${e.name}');
}
}
diff --git a/pkg/dart2js_info/bin/src/deferred_library_size.dart b/pkg/dart2js_info/bin/src/deferred_library_size.dart
index 78f94c9..6cf0ceb 100644
--- a/pkg/dart2js_info/bin/src/deferred_library_size.dart
+++ b/pkg/dart2js_info/bin/src/deferred_library_size.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.11
-
/// This tool gives a breakdown of code size by deferred part in the program.
library dart2js_info.bin.deferred_library_size;
@@ -25,14 +23,14 @@
@override
void run() async {
- var args = argResults.rest;
+ final args = argResults!.rest;
if (args.isEmpty) {
usageException('Missing argument: info.data');
}
// TODO(het): Would be faster to only parse the 'outputUnits' part
- var info = await infoFromFile(args.first);
- var sizeByImport = getSizeByImport(info);
- printSizes(sizeByImport, info.program.size);
+ final info = await infoFromFile(args.first);
+ final sizeByImport = getSizeByImport(info);
+ printSizes(sizeByImport, info.program!.size);
}
}
@@ -49,7 +47,7 @@
}
void printSizes(Map<String, int> sizeByImport, int programSize) {
- var importSizes = <ImportSize>[];
+ final importSizes = <ImportSize>[];
sizeByImport.forEach((import, size) {
importSizes.add(ImportSize(import, size));
});
@@ -72,9 +70,9 @@
}
print('-' * (longest + 16));
- var mainChunkSize = sizeByImport['main'];
- var deferredSize = programSize - mainChunkSize;
- var percentDeferred = (deferredSize * 100 / programSize).toStringAsFixed(2);
+ final mainChunkSize = sizeByImport['main']!;
+ final deferredSize = programSize - mainChunkSize;
+ final percentDeferred = (deferredSize * 100 / programSize).toStringAsFixed(2);
printRow('Main chunk size', mainChunkSize);
printRow('Deferred code size', deferredSize);
printRow('Percent of code deferred', '$percentDeferred%');
@@ -82,13 +80,13 @@
Map<String, int> getSizeByImport(AllInfo info) {
var sizeByImport = <String, int>{};
- for (var outputUnit in info.outputUnits) {
- if (outputUnit.name == 'main' || outputUnit.name == null) {
+ for (final outputUnit in info.outputUnits) {
+ if (outputUnit.name == 'main') {
sizeByImport['main'] = outputUnit.size;
} else {
- for (var import in outputUnit.imports) {
- sizeByImport.putIfAbsent(import, () => 0);
- sizeByImport[import] += outputUnit.size;
+ for (final import in outputUnit.imports) {
+ sizeByImport.update(import, (value) => value + outputUnit.size,
+ ifAbsent: () => outputUnit.size);
}
}
}
diff --git a/pkg/dart2js_info/bin/src/diff.dart b/pkg/dart2js_info/bin/src/diff.dart
index dfa4b34..405009f 100644
--- a/pkg/dart2js_info/bin/src/diff.dart
+++ b/pkg/dart2js_info/bin/src/diff.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.11
-
import 'package:args/command_runner.dart';
import 'package:dart2js_info/info.dart';
@@ -29,24 +27,25 @@
@override
void run() async {
- var args = argResults.rest;
+ final argRes = argResults!;
+ var args = argRes.rest;
if (args.length < 2) {
usageException(
'Missing arguments, expected two dump-info files to compare');
}
- var oldInfo = await infoFromFile(args[0]);
- var newInfo = await infoFromFile(args[1]);
- var summaryOnly = argResults['summary-only'];
+ final oldInfo = await infoFromFile(args[0]);
+ final newInfo = await infoFromFile(args[1]);
+ final summaryOnly = argRes['summary-only'];
- var diffs = diff(oldInfo, newInfo);
+ final diffs = diff(oldInfo, newInfo);
// Categorize the diffs
- var adds = <AddDiff>[];
- var removals = <RemoveDiff>[];
- var sizeChanges = <SizeDiff>[];
- var becameDeferred = <DeferredStatusDiff>[];
- var becameUndeferred = <DeferredStatusDiff>[];
+ final adds = <AddDiff>[];
+ final removals = <RemoveDiff>[];
+ final sizeChanges = <SizeDiff>[];
+ final becameDeferred = <DeferredStatusDiff>[];
+ final becameUndeferred = <DeferredStatusDiff>[];
for (var diff in diffs) {
switch (diff.kind) {
@@ -125,7 +124,7 @@
List<DeferredStatusDiff> becameDeferred,
List<DeferredStatusDiff> becameUndeferred,
Map<List<Diff>, int> totalSizes) {
- var overallSizeDiff = newInfo.program.size - oldInfo.program.size;
+ var overallSizeDiff = newInfo.program!.size - oldInfo.program!.size;
print('total_size_difference $overallSizeDiff');
print('total_added ${totalSizes[adds]}');
@@ -181,7 +180,7 @@
}
}
-void _section(String title, {int size}) {
+void _section(String title, {int? size}) {
print('$title ($size bytes)');
print('=' * 72);
}
diff --git a/pkg/dart2js_info/bin/src/function_size_analysis.dart b/pkg/dart2js_info/bin/src/function_size_analysis.dart
index a856f2e..04aa819 100644
--- a/pkg/dart2js_info/bin/src/function_size_analysis.dart
+++ b/pkg/dart2js_info/bin/src/function_size_analysis.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.11
-
/// Tool presenting how much each function contributes to the total code.
library compiler.tool.function_size_analysis;
@@ -26,18 +24,18 @@
@override
void run() async {
- var args = argResults.rest;
+ final args = argResults!.rest;
if (args.isEmpty) {
usageException('Missing argument: info.data');
}
- var info = await infoFromFile(args.first);
+ final info = await infoFromFile(args.first);
showCodeDistribution(info);
}
}
showCodeDistribution(AllInfo info,
- {bool Function(Info info) filter, bool showLibrarySizes = false}) {
- var realTotal = info.program.size;
+ {bool Function(Info info)? filter, bool showLibrarySizes = false}) {
+ var realTotal = info.program!.size;
filter ??= (i) => true;
var reported = <BasicInfo>[
...info.functions.where(filter),
@@ -78,7 +76,7 @@
var mainMethod = info.functions.firstWhere((f) => f.name == 'main');
var dominatorTree = graph.dominatorTree(mainMethod);
var dominatedSize = {};
- helper(n) {
+ int helper(n) {
int size = n.size;
assert(!dominatedSize.containsKey(n));
dominatedSize[n] = 0;
@@ -103,21 +101,21 @@
var longest = 0;
for (var info in reported) {
var size = info.size;
- while (info != null && info is! LibraryInfo) {
- info = info.parent;
+ Info? lib = info;
+ while (lib != null && lib is! LibraryInfo) {
+ lib = lib.parent;
}
- if (info == null) return;
- LibraryInfo lib = info;
- totals.putIfAbsent(lib, () => 0);
- totals[lib] += size;
+ if (lib == null) return;
+ totals.update(lib as LibraryInfo, (value) => value + size,
+ ifAbsent: () => size);
longest = math.max(longest, '${lib.uri}'.length);
}
_showLibHeader(longest + 1);
var reportedByLibrary = totals.keys.toList();
- reportedByLibrary.sort((a, b) => totals[b] - totals[a]);
- for (var info in reportedByLibrary) {
- _showLib('${info.uri}', totals[info], realTotal, longest + 1);
+ reportedByLibrary.sort((a, b) => totals[b]! - totals[a]!);
+ for (final info in reportedByLibrary) {
+ _showLib('${info.uri}', totals[info]!, realTotal, longest + 1);
}
}
@@ -135,27 +133,22 @@
/// Data associated with an SCC. Used to compute the reachable code size.
class _SccData {
int size = 0;
- Set deps = {};
+ Set<_SccData> deps = {};
_SccData();
- int _maxSize;
- int get maxSize {
- compute();
- return _maxSize;
- }
+ late final int maxSize = computeMaxSize();
- void compute() {
- if (_maxSize != null) return;
+ int computeMaxSize() {
var max = 0;
- var seen = <dynamic>{};
- helper(n) {
+ var seen = <_SccData>{};
+ void helper(_SccData n) {
if (!seen.add(n)) return;
max += n.size;
n.deps.forEach(helper);
}
helper(this);
- _maxSize = max;
+ return max;
}
}
diff --git a/pkg/dart2js_info/bin/src/inject_text.dart b/pkg/dart2js_info/bin/src/inject_text.dart
index ea245ad..045f7b3 100644
--- a/pkg/dart2js_info/bin/src/inject_text.dart
+++ b/pkg/dart2js_info/bin/src/inject_text.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.11
-
import 'dart:io';
import 'package:dart2js_info/info.dart';
@@ -18,17 +16,17 @@
// produces code spans, but excludes the orignal text
for (var f in info.functions) {
for (var span in f.code) {
- _fillSpan(span, f.outputUnit);
+ _fillSpan(span, f.outputUnit!);
}
}
for (var f in info.fields) {
for (var span in f.code) {
- _fillSpan(span, f.outputUnit);
+ _fillSpan(span, f.outputUnit!);
}
}
for (var c in info.constants) {
for (var span in c.code) {
- _fillSpan(span, c.outputUnit);
+ _fillSpan(span, c.outputUnit!);
}
}
}
diff --git a/pkg/dart2js_info/bin/src/library_size_split.dart b/pkg/dart2js_info/bin/src/library_size_split.dart
index a4e2483..8a1e77a 100644
--- a/pkg/dart2js_info/bin/src/library_size_split.dart
+++ b/pkg/dart2js_info/bin/src/library_size_split.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.11
-
/// Command-line tool to show the size distribution of generated code among
/// libraries. Libraries can be grouped using regular expressions. You can
/// specify what regular expressions to use by providing a `grouping.yaml` file.
@@ -86,30 +84,31 @@
@override
void run() async {
- var args = argResults.rest;
+ final argRes = argResults!;
+ final args = argRes.rest;
if (args.isEmpty) {
usageException('Missing argument: info.data');
}
- var info = await infoFromFile(args.first);
+ final info = await infoFromFile(args.first);
- var groupingFile = argResults['grouping'];
- var groupingText = groupingFile != null
+ final groupingFile = argRes['grouping'];
+ final groupingText = groupingFile != null
? File(groupingFile).readAsStringSync()
: defaultGrouping;
- var groupingYaml = loadYaml(groupingText);
- var groups = [];
+ final groupingYaml = loadYaml(groupingText);
+ final groups = [];
for (var group in groupingYaml['groups']) {
groups.add(_Group(
group['name'], RegExp(group['regexp']), group['cluster'] ?? 0));
}
- var sizes = {};
+ final sizes = {};
var allLibs = 0;
for (LibraryInfo lib in info.libraries) {
allLibs += lib.size;
for (var group in groups) {
- var match = group.matcher.firstMatch('${lib.uri}');
+ final match = group.matcher.firstMatch('${lib.uri}');
if (match != null) {
var name = group.name;
if (name == null && match.groupCount > 0) name = match.group(1);
@@ -125,11 +124,11 @@
allConstants += constant.size;
}
- var all = sizes.keys.toList();
+ final all = sizes.keys.toList();
all.sort((a, b) => sizes[a].compareTo(sizes[b]));
- var realTotal = info.program.size;
+ final realTotal = info.program!.size;
var longest = 0;
- var rows = <_Row>[];
+ final rows = <_Row>[];
addRow(String label, int value) {
rows.add(_Row(label, value));
longest = max(longest, label.length);
@@ -150,12 +149,12 @@
var lastCluster = 0;
for (var name in all) {
- var entry = sizes[name];
+ final entry = sizes[name];
if (lastCluster < entry.cluster) {
rows.add(const _Divider());
lastCluster = entry.cluster;
}
- var size = entry.size;
+ final size = entry.size;
addRow(name, size);
}
rows.add(const _Divider());
@@ -207,7 +206,7 @@
}
_pad(value, n, {bool right = false}) {
- var s = '$value';
+ final s = '$value';
if (s.length >= n) return s;
var pad = ' ' * (n - s.length);
return right ? '$s$pad' : '$pad$s';
diff --git a/pkg/dart2js_info/bin/src/live_code_size_analysis.dart b/pkg/dart2js_info/bin/src/live_code_size_analysis.dart
index 3e02b7a..2a4d135 100644
--- a/pkg/dart2js_info/bin/src/live_code_size_analysis.dart
+++ b/pkg/dart2js_info/bin/src/live_code_size_analysis.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.11
-
/// Command-line tool presenting combined information from dump-info and
/// coverage data.
///
@@ -62,11 +60,12 @@
@override
void run() async {
- var args = argResults.rest;
+ final argRes = argResults!;
+ var args = argRes.rest;
if (args.length < 2) {
usageException('Missing arguments, expected: info.data coverage.json');
}
- await _liveCodeAnalysis(args[0], args[1], argResults['verbose']);
+ await _liveCodeAnalysis(args[0], args[1], argRes['verbose']);
}
}
@@ -74,7 +73,7 @@
var info = await infoFromFile(infoFile);
var coverage = jsonDecode(File(coverageFile).readAsStringSync());
- int realTotal = info.program.size;
+ int realTotal = info.program!.size;
int totalLib = info.libraries.fold(0, (n, lib) => n + lib.size);
int totalCode = 0;
diff --git a/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart b/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart
index 6f8183f..bef9247 100644
--- a/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart
+++ b/pkg/dart2js_info/bin/src/runtime_coverage_analysis.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.11
-
/// Command-line tool presenting combined information from dump-info and
/// runtime coverage data.
///
@@ -55,11 +53,12 @@
@override
void run() async {
- var args = argResults.rest;
+ final argRes = argResults!;
+ final args = argRes.rest;
if (args.length < 2) {
usageException('Missing arguments, expected: info.data coverage.json');
}
- var showPackages = argResults['show-packages'];
+ final showPackages = argRes['show-packages'];
if (showPackages) {
await _reportWithPackages(args[0], args[1]);
} else {
@@ -77,7 +76,7 @@
// The value associated with each coverage item isn't used for now.
var coverage = coverageRaw.keys.toSet();
- int totalProgramSize = info.program.size;
+ int totalProgramSize = info.program!.size;
int totalLibSize = info.libraries.fold(0, (n, lib) => n + lib.size);
int totalCode = 0;
@@ -130,13 +129,13 @@
// The value associated with each coverage item isn't used for now.
var coverage = coverageRaw.keys.toSet();
- int totalProgramSize = info.program.size;
+ int totalProgramSize = info.program!.size;
int totalLibSize = info.libraries.fold(0, (n, lib) => n + lib.size);
int totalCode = 0;
int usedCode = 0;
- var packageData = <String, PackageInfo>{};
- var unused = PriorityQueue<Info>((a, b) => b.size.compareTo(a.size));
+ final packageData = <String?, PackageInfo>{};
+ final unused = PriorityQueue<Info>((a, b) => b.size.compareTo(a.size));
void tallyCode(BasicInfo i) {
totalCode += i.size;
@@ -144,8 +143,7 @@
var used = coverage.contains(name);
var groupName = libraryGroupName(i);
- packageData.putIfAbsent(groupName, () => PackageInfo());
- packageData[groupName].add(i, used: used);
+ (packageData[groupName] ??= PackageInfo()).add(i, used: used);
if (used) {
usedCode += i.size;
@@ -218,7 +216,7 @@
var name = qualifiedName(item);
var used = coverage.contains(name);
var usedTick = used ? '+' : '-';
- var mainUnitTick = item.outputUnit.name == 'main' ? 'M' : 'D';
+ var mainUnitTick = item.outputUnit!.name == 'main' ? 'M' : 'D';
_leftPadded(' [$usedTick$mainUnitTick] ${qualifiedName(item)}:',
'${item.size} bytes ($percent% of package)');
}
@@ -227,7 +225,7 @@
}
}
-void _section(String title, {int size}) {
+void _section(String title, {int? size}) {
if (size == null) {
print(title);
} else {
@@ -268,7 +266,7 @@
} else {
unusedSize += i.size;
}
- if (i.outputUnit.name == 'main') {
+ if (i.outputUnit!.name == 'main') {
mainUnitSize += i.size;
if (!used) {
unusedMainUnitSize += i.size;
diff --git a/pkg/dart2js_info/bin/src/text_print.dart b/pkg/dart2js_info/bin/src/text_print.dart
index 95ad015..ad6158b 100644
--- a/pkg/dart2js_info/bin/src/text_print.dart
+++ b/pkg/dart2js_info/bin/src/text_print.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.11
-
import 'dart:io';
import 'package:args/command_runner.dart';
@@ -34,17 +32,18 @@
@override
void run() async {
- if (argResults.rest.isEmpty) {
+ final argRes = argResults!;
+ if (argRes.rest.isEmpty) {
usageException('Missing argument: <input-info>');
}
- String filename = argResults.rest[0];
+ String filename = argRes.rest[0];
AllInfo info = await infoFromFile(filename);
- if (argResults['inject-text']) injectText(info);
+ if (argRes['inject-text']) injectText(info);
- var buffer = StringBuffer();
- info.accept(TextPrinter(buffer, argResults['inject-text']));
- var outputPath = argResults['out'];
+ final buffer = StringBuffer();
+ info.accept(TextPrinter(buffer, argRes['inject-text']));
+ final outputPath = argRes['out'];
if (outputPath == null) {
print(buffer);
} else {
@@ -79,7 +78,7 @@
@override
void visitAll(AllInfo info) {
- _writeBlock("Summary data", () => visitProgram(info.program));
+ _writeBlock("Summary data", () => visitProgram(info.program!));
buffer.writeln();
_writeBlock("Libraries", () => info.libraries.forEach(visitLibrary));
// Note: classes, functions, typedefs, and fields are group;ed by library.
@@ -146,7 +145,7 @@
@override
void visitClass(ClassInfo info) {
_writeBlock(
- '${info.name}: ${_size(info.size)} [${info.outputUnit.filename}]', () {
+ '${info.name}: ${_size(info.size)} [${info.outputUnit?.filename}]', () {
if (info.functions.isNotEmpty) {
_writeBlock('Methods:', () => info.functions.forEach(visitFunction));
}
@@ -160,7 +159,7 @@
@override
void visitClassType(ClassTypeInfo info) {
_writeBlock(
- '${info.name}: ${_size(info.size)} [${info.outputUnit.filename}]',
+ '${info.name}: ${_size(info.size)} [${info.outputUnit?.filename}]',
() {});
}
@@ -182,7 +181,7 @@
void visitFunction(FunctionInfo info) {
var outputUnitFile = '';
if (info.functionKind == FunctionInfo.TOP_LEVEL_FUNCTION_KIND) {
- outputUnitFile = ' [${info.outputUnit.filename}]';
+ outputUnitFile = ' [${info.outputUnit?.filename}]';
}
String params =
info.parameters.map((p) => "${p.declaredType} ${p.name}").join(', ');
diff --git a/pkg/dart2js_info/bin/src/to_binary.dart b/pkg/dart2js_info/bin/src/to_binary.dart
index 3061c3e..2f97835 100644
--- a/pkg/dart2js_info/bin/src/to_binary.dart
+++ b/pkg/dart2js_info/bin/src/to_binary.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.11
-
import 'dart:io';
import 'package:args/command_runner.dart';
@@ -24,14 +22,15 @@
@override
void run() async {
- if (argResults.rest.isEmpty) {
+ final args = argResults!;
+ if (args.rest.isEmpty) {
usageException('Missing argument: <input-info>');
}
- String filename = argResults.rest[0];
+ String filename = args.rest[0];
AllInfo info = await infoFromFile(filename);
- if (argResults['inject-text']) injectText(info);
- String outputFilename = argResults['out'] ?? '$filename.data';
+ if (args['inject-text']) injectText(info);
+ String outputFilename = args['out'] ?? '$filename.data';
var outstream = File(outputFilename).openWrite();
binary.encode(info, outstream);
await outstream.done;
diff --git a/pkg/dart2js_info/bin/src/to_json.dart b/pkg/dart2js_info/bin/src/to_json.dart
index 38a909c..2e6b117 100644
--- a/pkg/dart2js_info/bin/src/to_json.dart
+++ b/pkg/dart2js_info/bin/src/to_json.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.11
-
import 'dart:io';
import 'dart:convert';
@@ -38,21 +36,22 @@
@override
void run() async {
- if (argResults.rest.isEmpty) {
+ final args = argResults!;
+ if (args.rest.isEmpty) {
usageException('Missing argument: <input-info>');
}
- String filename = argResults.rest[0];
- bool isBackwardCompatible = argResults['compat-mode'];
+ String filename = args.rest[0];
+ bool isBackwardCompatible = args['compat-mode'];
AllInfo info = await infoFromFile(filename);
- if (isBackwardCompatible || argResults['inject-text']) {
+ if (isBackwardCompatible || args['inject-text']) {
injectText(info);
}
var json = AllInfoJsonCodec(isBackwardCompatible: isBackwardCompatible)
.encode(info);
- String outputFilename = argResults['out'] ?? '$filename.json';
+ String outputFilename = args['out'] ?? '$filename.json';
File(outputFilename)
.writeAsStringSync(const JsonEncoder.withIndent(" ").convert(json));
}
diff --git a/pkg/dart2js_info/bin/src/to_proto.dart b/pkg/dart2js_info/bin/src/to_proto.dart
index 89ed41d..86112ef 100644
--- a/pkg/dart2js_info/bin/src/to_proto.dart
+++ b/pkg/dart2js_info/bin/src/to_proto.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.11
-
/// Command-line tool to convert an info.json file ouputted by dart2js to the
/// alternative protobuf format.
@@ -26,15 +24,16 @@
@override
void run() async {
- if (argResults.rest.isEmpty) {
+ final args = argResults!;
+ if (args.rest.isEmpty) {
usageException('Missing argument: <input-info>');
}
- String filename = argResults.rest[0];
+ String filename = args.rest[0];
final info = await infoFromFile(filename);
- if (argResults['inject-text']) injectText(info);
+ if (args['inject-text']) injectText(info);
final proto = AllInfoProtoCodec().encode(info);
- String outputFilename = argResults['out'] ?? '$filename.pb';
+ String outputFilename = args['out'] ?? '$filename.pb';
final outputFile = File(outputFilename);
await outputFile.writeAsBytes(proto.writeToBuffer(), mode: FileMode.write);
}
diff --git a/pkg/dart2js_info/bin/tools.dart b/pkg/dart2js_info/bin/tools.dart
index 785e00c..7dc64bd 100644
--- a/pkg/dart2js_info/bin/tools.dart
+++ b/pkg/dart2js_info/bin/tools.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.11
-
import 'package:args/command_runner.dart';
import 'src/code_deps.dart';
diff --git a/pkg/dart2js_info/test/binary_serialization_test.dart b/pkg/dart2js_info/test/binary_serialization_test.dart
index 27ac31a..842b212 100644
--- a/pkg/dart2js_info/test/binary_serialization_test.dart
+++ b/pkg/dart2js_info/test/binary_serialization_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.11
-
import 'dart:convert';
import 'dart:io' show File, Platform;
import 'dart:typed_data' show BytesBuilder;
diff --git a/pkg/dart2js_info/test/graph_test.dart b/pkg/dart2js_info/test/graph_test.dart
index 017a90e..71afc23 100644
--- a/pkg/dart2js_info/test/graph_test.dart
+++ b/pkg/dart2js_info/test/graph_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.11
-
import 'package:dart2js_info/src/graph.dart';
import 'package:test/test.dart';
diff --git a/pkg/dart2js_info/test/json_to_proto_deferred_test.dart b/pkg/dart2js_info/test/json_to_proto_deferred_test.dart
index 190b005..d88c036 100644
--- a/pkg/dart2js_info/test/json_to_proto_deferred_test.dart
+++ b/pkg/dart2js_info/test/json_to_proto_deferred_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.11
-
import 'dart:convert';
import 'dart:io';
@@ -35,14 +33,14 @@
final entrypoint = infoMap[proto.program.entrypointId];
expect(entrypoint, isNotNull);
- expect(entrypoint.hasFunctionInfo(), isTrue);
+ expect(entrypoint!.hasFunctionInfo(), isTrue);
expect(entrypoint.outputUnitId, isNotNull);
// The output unit of the entrypoint function should be the default
// entrypoint, which should have no imports.
final defaultOutputUnit = infoMap[entrypoint.outputUnitId];
expect(defaultOutputUnit, isNotNull);
- expect(defaultOutputUnit.hasOutputUnitInfo(), isTrue);
+ expect(defaultOutputUnit!.hasOutputUnitInfo(), isTrue);
expect(defaultOutputUnit.outputUnitInfo.imports, isEmpty);
});
});
diff --git a/pkg/dart2js_info/test/json_to_proto_test.dart b/pkg/dart2js_info/test/json_to_proto_test.dart
index 6579ea9..240f3c2 100644
--- a/pkg/dart2js_info/test/json_to_proto_test.dart
+++ b/pkg/dart2js_info/test/json_to_proto_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.11
-
import 'dart:convert';
import 'dart:io';
@@ -49,31 +47,31 @@
final value = info.value;
if (value.hasLibraryInfo()) {
expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.library]));
+ startsWith(expectedPrefixes[InfoKind.library]!));
} else if (value.hasClassInfo()) {
- expect(
- value.serializedId, startsWith(expectedPrefixes[InfoKind.clazz]));
+ expect(value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.clazz]!));
} else if (value.hasClassTypeInfo()) {
expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.classType]));
+ startsWith(expectedPrefixes[InfoKind.classType]!));
} else if (value.hasFunctionInfo()) {
expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.function]));
+ startsWith(expectedPrefixes[InfoKind.function]!));
} else if (value.hasFieldInfo()) {
- expect(
- value.serializedId, startsWith(expectedPrefixes[InfoKind.field]));
+ expect(value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.field]!));
} else if (value.hasConstantInfo()) {
expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.constant]));
+ startsWith(expectedPrefixes[InfoKind.constant]!));
} else if (value.hasOutputUnitInfo()) {
expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.outputUnit]));
+ startsWith(expectedPrefixes[InfoKind.outputUnit]!));
} else if (value.hasTypedefInfo()) {
expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.typedef]));
+ startsWith(expectedPrefixes[InfoKind.typedef]!));
} else if (value.hasClosureInfo()) {
expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.closure]));
+ startsWith(expectedPrefixes[InfoKind.closure]!));
}
}
});
diff --git a/pkg/dart2js_info/test/parse_test.dart b/pkg/dart2js_info/test/parse_test.dart
index bb80faf..92c34d0 100644
--- a/pkg/dart2js_info/test/parse_test.dart
+++ b/pkg/dart2js_info/test/parse_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.11
-
import 'dart:convert';
import 'dart:io';
@@ -18,10 +16,10 @@
var json = jsonDecode(helloWorld.readAsStringSync());
var decoded = AllInfoJsonCodec().decode(json);
- var program = decoded.program;
+ final program = decoded.program;
expect(program, isNotNull);
- expect(program.entrypoint, isNotNull);
+ expect(program!.entrypoint, isNotNull);
expect(program.size, 90362);
expect(program.compilationMoment,
DateTime.parse("2022-05-26 21:08:43.608041"));
diff --git a/pkg/vm/lib/target/flutter.dart b/pkg/vm/lib/target/flutter.dart
index 1eadf20..8bdde3d 100644
--- a/pkg/vm/lib/target/flutter.dart
+++ b/pkg/vm/lib/target/flutter.dart
@@ -50,6 +50,10 @@
List<String> get extraRequiredLibrariesPlatform => const <String>[];
@override
+ DartLibrarySupport get dartLibrarySupport =>
+ const CustomizedDartLibrarySupport(unsupported: {'mirrors'});
+
+ @override
void performPreConstantEvaluationTransformations(
Component component,
CoreTypes coreTypes,
diff --git a/tools/VERSION b/tools/VERSION
index 6f615bc..a78b64c 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 18
PATCH 0
-PRERELEASE 204
+PRERELEASE 205
PRERELEASE_PATCH 0
\ No newline at end of file