From 6e29700e166361b9aca2a376163b97ef3cf4960b Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Mon, 7 Dec 2020 16:20:28 +0000 Subject: [PATCH] Update List constructor documentation, deprecate constructor. Emphasize that the operation is going away, and mark constructor as deprecated. TEST= Refactoring+deprecation only, covered by existing tests. Change-Id: I82aa044cd2cf7bf347b624371399f44bda8f4a07 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173261 Commit-Queue: Lasse R.H. Nielsen Reviewed-by: Konstantin Shcheglov Reviewed-by: Nate Bosch --- .../lib/src/parser/quote.dart | 2 +- .../lib/src/parser/stack_listener.dart | 13 +++---- .../lib/src/parser/token_stream_rewriter.dart | 2 +- .../lib/src/scanner/keyword_state.dart | 5 +-- .../lib/src/scanner/string_canonicalizer.dart | 6 ++-- .../lib/src/util/link.dart | 8 ++--- .../lib/src/util/link_implementation.dart | 4 +-- .../tool/smoke_test_quick.dart | 2 +- .../correction/statement_analyzer.dart | 2 +- .../lib/src/services/correction/util.dart | 2 +- pkg/analysis_server/test/completion_test.dart | 4 +-- .../imported_reference_contributor_test.dart | 2 +- .../refactoring/extract_method_test.dart | 6 ++-- .../dependency/reference_collector.dart | 5 +-- pkg/analyzer/lib/src/dart/ast/ast.dart | 2 +- .../lib/src/dart/constant/evaluation.dart | 2 +- .../lib/src/dart/element/element.dart | 4 +-- .../src/dart/element/least_upper_bound.dart | 4 +-- pkg/analyzer/lib/src/dart/element/member.dart | 4 +-- .../lib/src/dart/element/top_merge.dart | 4 +-- pkg/analyzer/lib/src/dart/element/type.dart | 11 +++--- .../lib/src/dart/element/type_algebra.dart | 3 +- .../src/dart/resolver/type_name_resolver.dart | 2 +- .../dart/resolver/typed_literal_resolver.dart | 9 ++--- pkg/analyzer/lib/src/dart/sdk/sdk.dart | 2 +- pkg/analyzer/lib/src/fasta/ast_builder.dart | 10 +++--- .../lib/src/generated/error_verifier.dart | 2 +- pkg/analyzer/lib/src/generated/resolver.dart | 2 +- .../generated/testing/ast_test_factory.dart | 2 +- .../generated/testing/element_factory.dart | 8 +++-- .../lib/src/summary/flat_buffers.dart | 2 +- .../lib/src/summary2/apply_resolution.dart | 2 +- .../src/summary2/default_types_builder.dart | 8 ++--- .../lib/src/summary2/named_type_builder.dart | 4 +-- .../lib/src/test_utilities/mock_sdk.dart | 2 +- pkg/analyzer/test/dart/ast/ast_test.dart | 6 ++-- .../generated/non_error_resolver_test.dart | 2 +- .../test/generated/non_hint_code_test.dart | 2 +- .../test/generated/utilities_test.dart | 2 +- .../src/dart/analysis/byte_store_test.dart | 2 +- .../test/src/dart/analysis/cache_test.dart | 2 +- pkg/analyzer/tool/messages/generate.dart | 2 +- pkg/analyzer/tool/summary/mini_ast.dart | 2 +- pkg/compiler/lib/src/dart2js.dart | 2 +- pkg/compiler/lib/src/dump_info.dart | 6 ++-- pkg/compiler/lib/src/elements/types.dart | 7 ++-- .../lib/src/helpers/expensive_map.dart | 2 +- .../lib/src/helpers/expensive_set.dart | 2 +- .../lib/src/inferrer/builder_kernel.dart | 6 ++-- .../lib/src/inferrer/closure_tracer.dart | 2 +- .../lib/src/inferrer/type_graph_dump.dart | 2 +- .../lib/src/inferrer/type_graph_nodes.dart | 3 +- .../lib/src/io/source_map_builder.dart | 2 +- pkg/compiler/lib/src/ir/static_type.dart | 5 +-- pkg/compiler/lib/src/js/rewrite_async.dart | 2 +- .../src/js_backend/field_naming_mixin.dart | 2 +- .../lib/src/js_backend/frequency_namer.dart | 2 +- .../lib/src/js_backend/runtime_types.dart | 4 +-- .../js_emitter/parameter_stub_generator.dart | 10 +++--- .../program_builder/program_builder.dart | 6 ++-- pkg/compiler/lib/src/ordered_typeset.dart | 10 +++--- .../src/serialization/abstract_source.dart | 6 ++-- .../lib/src/serialization/mixins.dart | 25 ++++++------- pkg/compiler/lib/src/ssa/builder_kernel.dart | 17 ++++----- pkg/compiler/lib/src/ssa/codegen.dart | 2 +- pkg/compiler/lib/src/ssa/codegen_helpers.dart | 2 +- pkg/compiler/lib/src/ssa/nodes.dart | 4 +-- pkg/compiler/lib/src/ssa/optimize.dart | 8 ++--- .../lib/src/ssa/types_propagation.dart | 2 +- pkg/compiler/lib/src/ssa/value_set.dart | 4 +-- .../lib/src/ssa/variable_allocator.dart | 8 ++--- pkg/compiler/lib/src/util/maplet.dart | 2 +- pkg/compiler/lib/src/util/setlet.dart | 2 +- pkg/compiler/lib/src/util/util.dart | 2 +- pkg/dds/test/web/sse_smoke_driver.dart.js | 2 +- .../doc/GENERIC_METHOD_COMMENTS.md | 4 +-- .../lib/src/compiler/module_containers.dart | 2 +- pkg/dev_compiler/lib/src/js_ast/builder.dart | 4 +-- .../tool/dartdevc_nnbd_sdk_error_golden.txt | 4 +-- .../lib/src/api_unstable/bazel_worker.dart | 2 +- .../modular_incremental_compilation.dart | 2 +- .../lib/src/base/processed_options.dart | 3 +- .../fasta/builder/constructor_builder.dart | 2 +- .../src/fasta/builder/function_builder.dart | 2 +- .../fasta/builder/function_type_builder.dart | 6 ++-- .../src/fasta/builder/named_type_builder.dart | 2 +- .../src/fasta/builder/procedure_builder.dart | 6 ++-- .../src/fasta/dill/dill_class_builder.dart | 2 +- .../lib/src/fasta/incremental_compiler.dart | 18 +++++----- .../lib/src/fasta/incremental_serializer.dart | 8 ++--- .../lib/src/fasta/kernel/body_builder.dart | 10 +++--- .../fasta/kernel/class_hierarchy_builder.dart | 23 ++++++------ .../kernel/combined_member_signature.dart | 7 ++-- .../kernel/constant_collection_builders.dart | 2 +- .../src/fasta/kernel/constant_evaluator.dart | 6 ++-- .../fasta/kernel/expression_generator.dart | 2 +- .../src/fasta/kernel/inference_visitor.dart | 2 +- .../lib/src/fasta/kernel/kernel_target.dart | 4 +-- .../src/fasta/kernel/member_covariance.dart | 9 ++--- .../lib/src/fasta/kernel/type_algorithms.dart | 13 ++++--- .../fasta/kernel/type_builder_computer.dart | 7 ++-- .../lib/src/fasta/source/outline_builder.dart | 10 +++--- .../fasta/source/source_library_builder.dart | 3 +- .../lib/src/fasta/source/source_loader.dart | 2 +- .../source/source_type_alias_builder.dart | 2 +- .../lib/src/fasta/util/direct_parser_ast.dart | 2 +- .../lib/src/fasta/util/textual_outline.dart | 8 ++--- .../lib/src/kernel_generator_impl.dart | 2 +- .../test/ast_nodes_has_to_string_test.dart | 4 +-- pkg/front_end/test/binary_md_dill_reader.dart | 2 +- .../test/crashing_test_case_minimizer.dart | 4 +-- .../test/dijkstras_sssp_algorithm.dart | 2 +- .../test/fasta/incremental_source_files.dart | 2 +- pkg/front_end/test/fasta/messages_suite.dart | 10 +++--- pkg/front_end/test/fasta/testing/suite.dart | 2 +- .../test/flutter_gallery_leak_tester.dart | 2 +- .../test/incremental_compiler_leak_test.dart | 3 +- .../test/incremental_dart2js_tester.dart | 4 +-- .../test/incremental_flutter_tester.dart | 2 +- .../incremental_load_from_dill_suite.dart | 16 ++++----- pkg/front_end/test/lint_suite.dart | 4 +-- pkg/front_end/test/parser_suite.dart | 8 ++--- .../test/spell_checking_cleanup_lists.dart | 4 +-- pkg/front_end/test/spell_checking_utils.dart | 26 +++++++------- .../test/spell_checking_utils_test.dart | 2 +- pkg/front_end/test/spelling_test_base.dart | 2 +- pkg/front_end/test/split_dill_test.dart | 2 +- pkg/front_end/test/test_generator_test.dart | 4 +-- pkg/front_end/test/vm_service_coverage.dart | 2 +- ...m_service_coverage_constant_evaluator.dart | 2 +- .../test/vm_service_for_leak_detection.dart | 2 +- .../test/vm_service_heap_helper.dart | 12 +++---- .../testcases/general/expressions.dart | 2 +- .../general/expressions.dart.strong.expect | 2 +- .../downwards_inference_yield_yield_star.dart | 8 ++--- ...erence_yield_yield_star.dart.strong.expect | 28 +++++++-------- ..._yield_star.dart.strong.transformed.expect | 28 +++++++-------- pkg/front_end/testcases/nnbd/issue41102.dart | 2 +- .../nnbd/issue41102.dart.strong.expect | 14 ++++---- .../issue41102.dart.strong.transformed.expect | 35 ++++++++++--------- .../issue41102.dart.textual_outline.expect | 2 +- ...41102.dart.textual_outline_modelled.expect | 2 +- .../nnbd/issue41102.dart.weak.expect | 14 ++++---- .../issue41102.dart.weak.transformed.expect | 14 ++++---- .../testcases/rasta/issue_000070.dart | 2 +- .../rasta/issue_000070.dart.strong.expect | 2 +- ...ssue_000070.dart.strong.transformed.expect | 2 +- .../issue_000070.dart.textual_outline.expect | 2 +- ...00070.dart.textual_outline_modelled.expect | 2 +- pkg/front_end/tool/_fasta/entry_points.dart | 2 +- pkg/front_end/tool/smoke_test_quick.dart | 2 +- pkg/frontend_server/lib/frontend_server.dart | 6 ++-- .../test/frontend_server_flutter.dart | 4 +-- .../test/frontend_server_flutter_suite.dart | 2 +- pkg/js_ast/lib/src/builder.dart | 4 +-- pkg/kernel/lib/ast.dart | 2 +- pkg/kernel/lib/binary/ast_from_binary.dart | 27 +++++++------- pkg/kernel/lib/binary/ast_to_binary.dart | 16 ++++----- pkg/kernel/lib/class_hierarchy.dart | 15 ++++---- pkg/kernel/lib/import_table.dart | 2 +- pkg/kernel/lib/src/bounds_checks.dart | 15 ++++---- pkg/kernel/lib/src/merge_visitor.dart | 14 ++++---- pkg/kernel/lib/src/nnbd_top_merge.dart | 3 +- pkg/kernel/lib/src/replacement_visitor.dart | 2 +- pkg/kernel/lib/src/standard_bounds.dart | 10 +++--- .../lib/text/serializer_combinators.dart | 6 ++-- pkg/kernel/lib/text/text_serializer.dart | 7 ++-- .../lib/transformations/continuation.dart | 6 ++-- .../lib/vm/constants_native_effects.dart | 2 +- pkg/kernel/test/binary_bench.dart | 4 +-- pkg/kernel/test/class_hierarchy_bench.dart | 2 +- pkg/kernel/test/import_table_test.dart | 2 +- .../load_concat_dill_keeps_source_test.dart | 4 +-- pkg/kernel/tool/smoke_test_quick.dart | 2 +- .../lib/src/front_end/info_builder.dart | 3 +- .../lib/src/stepping_helper.dart | 2 +- pkg/status_file/lib/src/disjunctive.dart | 6 ++-- pkg/test_runner/lib/src/process_queue.dart | 2 +- pkg/testing/lib/src/test_dart/path.dart | 2 +- .../lib/src/test_dart/status_expression.dart | 2 +- .../lib/src/test_dart/status_file_parser.dart | 8 ++--- pkg/vm/bin/kernel_service.dart | 4 +-- pkg/vm/lib/kernel_front_end.dart | 7 ++-- .../late_var_init_transformer.dart | 2 +- .../transformations/type_flow/analysis.dart | 6 ++-- .../transformations/type_flow/summary.dart | 16 ++++----- .../type_flow/summary_collector.dart | 16 +++++---- .../type_flow/table_selector_assigner.dart | 2 +- .../lib/transformations/type_flow/types.dart | 2 +- pkg/vm/test/incremental_compiler_test.dart | 4 +-- .../transformer/dynamic_list_access.dart | 2 +- .../test/heap_snapshot_graph_test.dart | 4 +-- .../lib/program_info.dart | 2 +- pkg/vm_snapshot_analysis/lib/treemap.dart | 3 +- runtime/vm/compiler/recognized_methods_list.h | 2 +- sdk/lib/core/list.dart | 23 ++++++------ sdk/lib/internal/list.dart | 6 ++-- 197 files changed, 563 insertions(+), 522 deletions(-) diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/quote.dart b/pkg/_fe_analyzer_shared/lib/src/parser/quote.dart index d4928a53de4..a33410d5a99 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/quote.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/quote.dart @@ -184,7 +184,7 @@ String unescape(String string, Quote quote, Object location, String unescapeCodeUnits(List codeUnits, bool isRaw, Object location, UnescapeErrorListener listener) { // Can't use Uint8List or Uint16List here, the code units may be larger. - List result = new List(codeUnits.length); + List result = new List.filled(codeUnits.length, null); int resultOffset = 0; for (int i = 0; i < codeUnits.length; i++) { diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart b/pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart index e9d29da1877..6462add9348 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart @@ -518,7 +518,7 @@ abstract class Stack { } class StackImpl implements Stack { - List array = new List(/* length = */ 8); + List array = new List.filled(/* length = */ 8, null); int arrayLength = 0; bool get isNotEmpty => arrayLength > 0; @@ -581,14 +581,14 @@ class StackImpl implements Stack { List get values { final int length = arrayLength; - final List list = new List(length); + final List list = new List.filled(length, null); list.setRange(/* start = */ 0, length, array); return list; } void _grow() { final int length = array.length; - final List newArray = new List(length * 2); + final List newArray = new List.filled(length * 2, null); newArray.setRange(/* start = */ 0, length, array, /* skipCount = */ 0); array = newArray; } @@ -597,7 +597,7 @@ class StackImpl implements Stack { class DebugStack implements Stack { Stack realStack = new StackImpl(); Stack stackTraceStack = new StackImpl(); - List latestStacktraces = new List(); + List latestStacktraces = []; @override Object operator [](int index) { @@ -654,13 +654,14 @@ class FixedNullableList { List pop(Stack stack, int count, [NullValue nullValue]) { if (count == 0) return null; - return stack.popList(count, new List(count), nullValue); + return stack.popList(count, new List.filled(count, null), nullValue); } List popPadded(Stack stack, int count, int padding, [NullValue nullValue]) { if (count + padding == 0) return null; - return stack.popList(count, new List(count + padding), nullValue); + return stack.popList( + count, new List.filled(count + padding, null), nullValue); } } diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/token_stream_rewriter.dart b/pkg/_fe_analyzer_shared/lib/src/parser/token_stream_rewriter.dart index df1e467d6e0..7868ae5c845 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/token_stream_rewriter.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/token_stream_rewriter.dart @@ -331,7 +331,7 @@ class PreviousTokenStreamChange implements TokenStreamChange { /// implementation does this by rewriting the previous token to point to the /// inserted token. It also allows to undo these changes. class UndoableTokenStreamRewriter extends TokenStreamRewriter { - List _changes = new List(); + List _changes = []; void undo() { for (int i = _changes.length - 1; i >= 0; i--) { diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/keyword_state.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/keyword_state.dart index b4620e32b02..05f07e073d8 100644 --- a/pkg/_fe_analyzer_shared/lib/src/scanner/keyword_state.dart +++ b/pkg/_fe_analyzer_shared/lib/src/scanner/keyword_state.dart @@ -20,7 +20,8 @@ abstract class KeywordState { static KeywordState _KEYWORD_STATE; static KeywordState get KEYWORD_STATE { if (_KEYWORD_STATE == null) { - List strings = new List(analyzer.Keyword.values.length); + List strings = + new List.filled(analyzer.Keyword.values.length, null); for (int i = 0; i < analyzer.Keyword.values.length; i++) { strings[i] = analyzer.Keyword.values[i].lexeme; } @@ -38,7 +39,7 @@ abstract class KeywordState { int start, List strings, int offset, int length) { bool isLowercase = true; - List table = new List($z - $A + 1); + List table = new List.filled($z - $A + 1, null); assert(length != 0); int chunk = 0; int chunkStart = -1; diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/string_canonicalizer.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/string_canonicalizer.dart index 2b127b7f5bf..7370bdf886d 100644 --- a/pkg/_fe_analyzer_shared/lib/src/scanner/string_canonicalizer.dart +++ b/pkg/_fe_analyzer_shared/lib/src/scanner/string_canonicalizer.dart @@ -34,7 +34,7 @@ class StringCanonicalizer { int _count = 0; /// The table itself. - List _nodes = new List(INITIAL_SIZE); + List _nodes = new List.filled(INITIAL_SIZE, null); static String decode(List data, int start, int end, bool asciiOnly) { String s; @@ -64,7 +64,7 @@ class StringCanonicalizer { rehash() { int newSize = _size * 2; - List newNodes = new List(newSize); + List newNodes = new List.filled(newSize, null); for (int i = 0; i < _size; i++) { Node t = _nodes[i]; while (t != null) { @@ -117,7 +117,7 @@ class StringCanonicalizer { clear() { _size = INITIAL_SIZE; - _nodes = new List(_size); + _nodes = new List.filled(_size, null); _count = 0; } } diff --git a/pkg/_fe_analyzer_shared/lib/src/util/link.dart b/pkg/_fe_analyzer_shared/lib/src/util/link.dart index 8cb8dd001db..2474f06a976 100644 --- a/pkg/_fe_analyzer_shared/lib/src/util/link.dart +++ b/pkg/_fe_analyzer_shared/lib/src/util/link.dart @@ -24,9 +24,9 @@ class Link implements Iterable { List toList({bool growable: true}) { List result; if (!growable) { - result = new List(slowLength()); + result = new List.filled(slowLength(), null); } else { - result = new List(); + result = []; result.length = slowLength(); } int i = 0; @@ -46,9 +46,9 @@ class Link implements Iterable { List mapToList(E fn(T item), {bool growable: true}) { List result; if (!growable) { - result = new List(slowLength()); + result = new List.filled(slowLength(), null); } else { - result = new List(); + result = []; result.length = slowLength(); } int i = 0; diff --git a/pkg/_fe_analyzer_shared/lib/src/util/link_implementation.dart b/pkg/_fe_analyzer_shared/lib/src/util/link_implementation.dart index e9d97ecfa30..7fced1ad58d 100644 --- a/pkg/_fe_analyzer_shared/lib/src/util/link_implementation.dart +++ b/pkg/_fe_analyzer_shared/lib/src/util/link_implementation.dart @@ -168,8 +168,8 @@ class LinkBuilderImplementation implements LinkBuilder { } List toList() { - if (length == 0) return new List(0); - List list = new List(length); + if (length == 0) return new List.filled(0, null); + List list = new List.filled(length, null); int index = 0; Link link = head; while (link.isNotEmpty) { diff --git a/pkg/_fe_analyzer_shared/tool/smoke_test_quick.dart b/pkg/_fe_analyzer_shared/tool/smoke_test_quick.dart index e5c6d2bad5b..2c7025cc0e7 100644 --- a/pkg/_fe_analyzer_shared/tool/smoke_test_quick.dart +++ b/pkg/_fe_analyzer_shared/tool/smoke_test_quick.dart @@ -10,7 +10,7 @@ String get dartVm => Platform.executable; main(List args) async { Stopwatch stopwatch = new Stopwatch()..start(); - List futures = new List(); + List futures = []; futures.add(run("pkg/front_end/test/spelling_test_src_suite.dart", ["--", "spelling_test_src/_fe_analyzer_shared/..."])); futures.add(run( diff --git a/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart b/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart index c21363ff738..96e8e891b2e 100644 --- a/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart +++ b/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart @@ -32,7 +32,7 @@ List _getTokens(String text, FeatureSet featureSet) { } return tokens; } catch (e) { - return List(0); + return List.filled(0, null); } } diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart index 59dca744ac8..46b3f036e2f 100644 --- a/pkg/analysis_server/lib/src/services/correction/util.dart +++ b/pkg/analysis_server/lib/src/services/correction/util.dart @@ -422,7 +422,7 @@ List getParents(AstNode node) { } } // fill array of parents - var parents = List(numParents); + var parents = List.filled(numParents, null); var current = node.parent; var index = numParents; while (current != null) { diff --git a/pkg/analysis_server/test/completion_test.dart b/pkg/analysis_server/test/completion_test.dart index 3067b772884..bb5fa964fba 100644 --- a/pkg/analysis_server/test/completion_test.dart +++ b/pkg/analysis_server/test/completion_test.dart @@ -181,7 +181,7 @@ class List{add(){}length(){}}t1() {var x;if (x is List) {x.!1add(3);}}''', // Type propagation buildTests('testCommentSnippets035', ''' -class List{clear(){}length(){}}t3() {var x=new List(), y=x.!1length();x.!2clear();}''', +class List{clear(){}length(){}}t3() {var x=[], y=x.!1length();x.!2clear();}''', ['1+length', '2+clear']); buildTests('testCommentSnippets036', ''' @@ -1829,7 +1829,7 @@ void b() { var x = [Q.!2] } void c() { - var x = new List([Q.!3]) + var x = new List.filled([Q.!3], null) } void d() { new Q.!4 diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart index 1e7de2b31c7..ff603a410bf 100644 --- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart +++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart @@ -3421,7 +3421,7 @@ class B { assertNotSuggested('_g'); assertSuggestClass('bool'); if (suggestConstructorsWithoutNew) { - assertSuggestConstructor('List'); + assertSuggestConstructor('List.filled'); } } diff --git a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart index 9db193109fa..ff277f5f905 100644 --- a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart +++ b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart @@ -1575,17 +1575,17 @@ Completer res() => newCompleter(); Future test_singleExpression_returnTypeGeneric() async { await indexTestUnit(''' main() { - var v = new List(); + var v = []; } '''); - _createRefactoringForString('new List()'); + _createRefactoringForString('[]'); // apply refactoring return _assertSuccessfulRefactoring(''' main() { var v = res(); } -List res() => new List(); +List res() => []; '''); } diff --git a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart index 74a6b9380c5..1314ccf10ef 100644 --- a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart +++ b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart @@ -121,8 +121,9 @@ class ReferenceCollector { } } - var importPrefixes = List(importPrefixCount); - var importPrefixedReferencedNames = List>(importPrefixCount); + var importPrefixes = List.filled(importPrefixCount, null); + var importPrefixedReferencedNames = + List>.filled(importPrefixCount, null); var importIndex = 0; for (var i = 0; i < _importPrefixedReferences.length; i++) { var import = _importPrefixedReferences[i]; diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart index a948a396d90..59fd5c6c123 100644 --- a/pkg/analyzer/lib/src/dart/ast/ast.dart +++ b/pkg/analyzer/lib/src/dart/ast/ast.dart @@ -4475,7 +4475,7 @@ class FormalParameterListImpl extends AstNodeImpl @override List get parameterElements { int count = _parameters.length; - List types = List(count); + List types = List.filled(count, null); for (int i = 0; i < count; i++) { types[i] = _parameters[i].declaredElement; } diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart index 33034f075aa..6c1f831cdd7 100644 --- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart +++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart @@ -406,7 +406,7 @@ class ConstantEvaluationEngine { } int argumentCount = arguments.length; - var argumentValues = List(argumentCount); + var argumentValues = List.filled(argumentCount, null); Map namedNodes; Map namedValues; for (int i = 0; i < argumentCount; i++) { diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart index a41ae6bafd6..faf322ee6f1 100644 --- a/pkg/analyzer/lib/src/dart/element/element.dart +++ b/pkg/analyzer/lib/src/dart/element/element.dart @@ -1019,7 +1019,7 @@ class ClassElementImpl extends AbstractClassElementImpl int count = superParameters.length; if (count > 0) { List implicitParameters = - List(count); + List.filled(count, null); for (int i = 0; i < count; i++) { ParameterElement superParameter = superParameters[i]; ParameterElementImpl implicitParameter; @@ -3167,7 +3167,7 @@ abstract class ElementImpl implements Element { return const []; } - var annotations = List(length); + var annotations = List.filled(length, null); for (int i = 0; i < length; i++) { var ast = nodeList[i]; annotations[i] = ElementAnnotationImpl(unit) diff --git a/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart b/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart index 941812adf66..d355eab1868 100644 --- a/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart +++ b/pkg/analyzer/lib/src/dart/element/least_upper_bound.dart @@ -135,7 +135,7 @@ class InstantiatedClass { List _toInstantiatedClasses( List interfaces, ) { - var result = List(interfaces.length); + var result = List.filled(interfaces.length, null); for (var i = 0; i < interfaces.length; i++) { var interface = interfaces[i]; var substituted = _substitution.substituteType(interface); @@ -196,7 +196,7 @@ class InterfaceLeastUpperBoundHelper { assert(args1.length == args2.length); assert(args1.length == params.length); - var args = List(args1.length); + var args = List.filled(args1.length, null); for (int i = 0; i < args1.length; i++) { // TODO (kallentu) : Clean up TypeParameterElementImpl casting once // variance is added to the interface. diff --git a/pkg/analyzer/lib/src/dart/element/member.dart b/pkg/analyzer/lib/src/dart/element/member.dart index 9816e569fea..f343aa1554d 100644 --- a/pkg/analyzer/lib/src/dart/element/member.dart +++ b/pkg/analyzer/lib/src/dart/element/member.dart @@ -1069,8 +1069,8 @@ class _SubstitutedTypeParameters { // Create type formals with specialized bounds. // For example `` where T comes from an outer scope. - var newElements = List(elements.length); - var newTypes = List(elements.length); + var newElements = List.filled(elements.length, null); + var newTypes = List.filled(elements.length, null); for (int i = 0; i < newElements.length; i++) { var element = elements[i]; var newElement = TypeParameterElementImpl.synthetic(element.name); diff --git a/pkg/analyzer/lib/src/dart/element/top_merge.dart b/pkg/analyzer/lib/src/dart/element/top_merge.dart index 78714eaf95a..8fb1327913e 100644 --- a/pkg/analyzer/lib/src/dart/element/top_merge.dart +++ b/pkg/analyzer/lib/src/dart/element/top_merge.dart @@ -212,7 +212,7 @@ class TopMergeHelper { throw _TopMergeStateError(T, S, 'Different number of formal parameters'); } - var R_parameters = List(T_parameters.length); + var R_parameters = List.filled(T_parameters.length, null); for (var i = 0; i < T_parameters.length; i++) { var T_parameter = T_parameters[i]; var S_parameter = S_parameters[i]; @@ -278,7 +278,7 @@ class TopMergeHelper { if (T_arguments.isEmpty) { return T; } else { - var arguments = List(T_arguments.length); + var arguments = List.filled(T_arguments.length, null); for (var i = 0; i < T_arguments.length; i++) { arguments[i] = topMerge(T_arguments[i], S_arguments[i]); } diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart index 20211b68240..50953f87f68 100644 --- a/pkg/analyzer/lib/src/dart/element/type.dart +++ b/pkg/analyzer/lib/src/dart/element/type.dart @@ -644,7 +644,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { if (_accessors == null) { List accessors = element.accessors; List members = - List(accessors.length); + List.filled(accessors.length, null); for (int i = 0; i < accessors.length; i++) { members[i] = PropertyAccessorMember.from(accessors[i], this); } @@ -666,7 +666,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { if (_constructors == null) { List constructors = element.constructors; List members = - List(constructors.length); + List.filled(constructors.length, null); for (int i = 0; i < constructors.length; i++) { members[i] = ConstructorMember.from(constructors[i], this); } @@ -767,7 +767,8 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { List get methods { if (_methods == null) { List methods = element.methods; - List members = List(methods.length); + List members = + List.filled(methods.length, null); for (int i = 0; i < methods.length; i++) { members[i] = MethodMember.from(methods[i], this); } @@ -1322,7 +1323,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { if (typeParameters.isEmpty) return defined; var substitution = Substitution.fromInterfaceType(this); - var result = List(defined.length); + var result = List.filled(defined.length, null); for (int i = 0; i < defined.length; i++) { result[i] = substitution.substituteType(defined[i]); } @@ -1425,7 +1426,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { if (argumentCount == 0) { return firstType; } - List lubArguments = List(argumentCount); + List lubArguments = List.filled(argumentCount, null); for (int i = 0; i < argumentCount; i++) { // // Ideally we would take the least upper bound of the two argument types, diff --git a/pkg/analyzer/lib/src/dart/element/type_algebra.dart b/pkg/analyzer/lib/src/dart/element/type_algebra.dart index 2854f7e8496..a6ca14b404e 100644 --- a/pkg/analyzer/lib/src/dart/element/type_algebra.dart +++ b/pkg/analyzer/lib/src/dart/element/type_algebra.dart @@ -239,7 +239,8 @@ class _FreshTypeParametersSubstitutor extends _TypeSubstitutor { return const []; } - var freshElements = List(elements.length); + var freshElements = + List.filled(elements.length, null); for (var i = 0; i < elements.length; i++) { // TODO (kallentu) : Clean up TypeParameterElementImpl casting once // variance is added to the interface. diff --git a/pkg/analyzer/lib/src/dart/resolver/type_name_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/type_name_resolver.dart index 55967cb9985..c077118ad66 100644 --- a/pkg/analyzer/lib/src/dart/resolver/type_name_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/type_name_resolver.dart @@ -133,7 +133,7 @@ class TypeNameResolver { return const []; } - var typeArguments = List(parameterCount); + var typeArguments = List.filled(parameterCount, null); for (var i = 0; i < parameterCount; i++) { typeArguments[i] = arguments[i].type; } diff --git a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart index b36521c6982..e7012449117 100644 --- a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart @@ -768,8 +768,9 @@ class TypedLiteralResolver { nullabilitySuffix: _noneOrStarSuffix, ); - var parameters = List(2 * inferredTypes.length); - var argumentTypes = List(2 * inferredTypes.length); + var parameters = + List.filled(2 * inferredTypes.length, null); + var argumentTypes = List.filled(2 * inferredTypes.length, null); for (var i = 0; i < inferredTypes.length; i++) { parameters[2 * i + 0] = ParameterElementImpl.synthetic( 'key', genericKeyType, ParameterKind.POSITIONAL); @@ -802,8 +803,8 @@ class TypedLiteralResolver { nullabilitySuffix: _noneOrStarSuffix, ); - var parameters = List(inferredTypes.length); - var argumentTypes = List(inferredTypes.length); + var parameters = List.filled(inferredTypes.length, null); + var argumentTypes = List.filled(inferredTypes.length, null); for (var i = 0; i < inferredTypes.length; i++) { parameters[i] = ParameterElementImpl.synthetic( 'element', genericElementType, ParameterKind.POSITIONAL); diff --git a/pkg/analyzer/lib/src/dart/sdk/sdk.dart b/pkg/analyzer/lib/src/dart/sdk/sdk.dart index 5c3e5c9ee88..0a0d0fa1793 100644 --- a/pkg/analyzer/lib/src/dart/sdk/sdk.dart +++ b/pkg/analyzer/lib/src/dart/sdk/sdk.dart @@ -142,7 +142,7 @@ abstract class AbstractDartSdk implements DartSdk { String _getPath(File file) { List libraries = libraryMap.sdkLibraries; int length = libraries.length; - List paths = List(length); + List paths = List.filled(length, null); String filePath = getRelativePathFromFile(file); if (filePath == null) { return null; diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart index 58ec08b550e..16eb67ee21e 100644 --- a/pkg/analyzer/lib/src/fasta/ast_builder.dart +++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart @@ -2087,10 +2087,10 @@ class AstBuilder extends StackListener { member.labels.insert(0, pop()); --labelCount; } - members = List(expressionCount + 1); + members = List.filled(expressionCount + 1, null); members[expressionCount] = member; } else { - members = List(expressionCount); + members = List.filled(expressionCount, null); } for (int index = expressionCount - 1; index >= 0; --index) { SwitchMember member = pop(); @@ -3476,7 +3476,7 @@ class AstBuilder extends StackListener { void handleTypeVariablesDefined(Token token, int count) { debugEvent("handleTypeVariablesDefined"); assert(count > 0); - push(popTypedList(count, List(count))); + push(popTypedList(count, List.filled(count, null))); } @override @@ -3563,7 +3563,7 @@ class AstBuilder extends StackListener { List parseCommentReferences(Token dartdoc) { // Parse dartdoc into potential comment reference source/offset pairs int count = parser.parseCommentReferences(dartdoc); - List sourcesAndOffsets = List(count * 2); + List sourcesAndOffsets = List.filled(count * 2, null); popList(count * 2, sourcesAndOffsets); // Parse each of the source/offset pairs into actual comment references @@ -3581,7 +3581,7 @@ class AstBuilder extends StackListener { } } - final references = List(count); + final references = List.filled(count, null); popTypedList(count, references); return references; } diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart index fa0e7d50043..e54f009dfcf 100644 --- a/pkg/analyzer/lib/src/generated/error_verifier.dart +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart @@ -1529,7 +1529,7 @@ class ErrorVerifier extends RecursiveAstVisitor { String name = element.displayName; List conflictingMembers = element.conflictingElements; int count = conflictingMembers.length; - List libraryNames = List(count); + List libraryNames = List.filled(count, null); for (int i = 0; i < count; i++) { libraryNames[i] = _getLibraryName(conflictingMembers[i]); } diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart index 21b7d76467c..d44e6a073d4 100644 --- a/pkg/analyzer/lib/src/generated/resolver.dart +++ b/pkg/analyzer/lib/src/generated/resolver.dart @@ -2208,7 +2208,7 @@ class ResolverVisitor extends ScopedVisitor { NodeList arguments = argumentList.arguments; int argumentCount = arguments.length; List resolvedParameters = - List(argumentCount); + List.filled(argumentCount, null); int positionalArgumentCount = 0; HashSet usedNames; bool noBlankArguments = true; diff --git a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart index 81d60f6b084..a76d6258947 100644 --- a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart +++ b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart @@ -451,7 +451,7 @@ class AstTestFactory { String name, List constantNames) { int count = constantNames.length; List constants = - List(count); + List.filled(count, null); for (int i = 0; i < count; i++) { constants[i] = astFactory.enumConstantDeclaration( null, null, identifier3(constantNames[i])); diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart index afd513a20e3..88250f8952f 100644 --- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart +++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart @@ -126,7 +126,8 @@ class ElementFactory { constructor.isConst = isConst; if (argumentTypes != null) { int count = argumentTypes.length; - List parameters = List(count); + List parameters = + List.filled(count, null); for (int i = 0; i < count; i++) { ParameterElementImpl parameter = ParameterElementImpl("a$i", i); parameter.type = argumentTypes[i]; @@ -320,7 +321,8 @@ class ElementFactory { method.parameters = const []; } else { int count = argumentTypes.length; - List parameters = List(count); + List parameters = + List.filled(count, null); for (int i = 0; i < count; i++) { ParameterElementImpl parameter = ParameterElementImpl("a$i", i); parameter.type = argumentTypes[i]; @@ -487,7 +489,7 @@ class ElementFactory { return const []; } List typeParameters = - List(count); + List.filled(count, null); for (int i = 0; i < count; i++) { typeParameters[i] = typeParameterWithType(names[i]); } diff --git a/pkg/analyzer/lib/src/summary/flat_buffers.dart b/pkg/analyzer/lib/src/summary/flat_buffers.dart index b939bb9e7f7..764ea954cd2 100644 --- a/pkg/analyzer/lib/src/summary/flat_buffers.dart +++ b/pkg/analyzer/lib/src/summary/flat_buffers.dart @@ -737,7 +737,7 @@ class _FbGenericList extends _FbList { @override E operator [](int i) { - _items ??= List(length); + _items ??= List.filled(length, null); E item = _items[i]; if (item == null) { item = elementReader.read(bc, offset + 4 + elementReader.size * i); diff --git a/pkg/analyzer/lib/src/summary2/apply_resolution.dart b/pkg/analyzer/lib/src/summary2/apply_resolution.dart index 62ecae08853..1c0785be630 100644 --- a/pkg/analyzer/lib/src/summary2/apply_resolution.dart +++ b/pkg/analyzer/lib/src/summary2/apply_resolution.dart @@ -901,7 +901,7 @@ class ApplyResolutionVisitor extends ThrowingAstVisitor { return const []; } - var annotations = List(length); + var annotations = List.filled(length, null); for (int i = 0; i < length; i++) { var ast = nodeList[i]; annotations[i] = ElementAnnotationImpl(unit) diff --git a/pkg/analyzer/lib/src/summary2/default_types_builder.dart b/pkg/analyzer/lib/src/summary2/default_types_builder.dart index ad8c510d766..68cc05376a7 100644 --- a/pkg/analyzer/lib/src/summary2/default_types_builder.dart +++ b/pkg/analyzer/lib/src/summary2/default_types_builder.dart @@ -161,8 +161,8 @@ class DefaultTypesBuilder { var nodes = parameterList.typeParameters; var length = nodes.length; - var elements = List(length); - var bounds = List(length); + var elements = List.filled(length, null); + var bounds = List.filled(length, null); for (int i = 0; i < length; i++) { var node = nodes[i]; elements[i] = node.declaredElement; @@ -324,8 +324,8 @@ class _TypeParametersGraph implements Graph { ) { assert(parameters.length == bounds.length); - vertices = List(parameters.length); - _edges = List>(parameters.length); + vertices = List.filled(parameters.length, null); + _edges = List>.filled(parameters.length, null); for (int i = 0; i < vertices.length; i++) { vertices[i] = i; _edges[i] = []; diff --git a/pkg/analyzer/lib/src/summary2/named_type_builder.dart b/pkg/analyzer/lib/src/summary2/named_type_builder.dart index a00dfb847dc..d67f186fb3c 100644 --- a/pkg/analyzer/lib/src/summary2/named_type_builder.dart +++ b/pkg/analyzer/lib/src/summary2/named_type_builder.dart @@ -182,7 +182,7 @@ class NamedTypeBuilder extends TypeBuilder { return const []; } else if (arguments.isNotEmpty) { if (arguments.length == parameters.length) { - var result = List(parameters.length); + var result = List.filled(parameters.length, null); for (int i = 0; i < result.length; ++i) { var type = arguments[i]; result[i] = _buildType(type); @@ -192,7 +192,7 @@ class NamedTypeBuilder extends TypeBuilder { return _listOfDynamic(parameters.length); } } else { - var result = List(parameters.length); + var result = List.filled(parameters.length, null); for (int i = 0; i < result.length; ++i) { TypeParameterElementImpl parameter = parameters[i]; var defaultType = parameter.defaultType; diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart index cd292024c34..5007cdea3c8 100644 --- a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart +++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart @@ -253,7 +253,7 @@ void print(Object? object) {} class ArgumentError extends Error { ArgumentError([message]); - + static T checkNotNull(T argument, [String, name]) => argument; } diff --git a/pkg/analyzer/test/dart/ast/ast_test.dart b/pkg/analyzer/test/dart/ast/ast_test.dart index 635d7ff0055..ba3b7ed5d27 100644 --- a/pkg/analyzer/test/dart/ast/ast_test.dart +++ b/pkg/analyzer/test/dart/ast/ast_test.dart @@ -1693,7 +1693,8 @@ class VariableDeclarationTest extends ParserTestCase { VariableDeclaration varDecl = AstTestFactory.variableDeclaration("a"); TopLevelVariableDeclaration decl = AstTestFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]); - Comment comment = astFactory.documentationComment(List(0)); + Comment comment = + astFactory.documentationComment(List.filled(0, null)); expect(varDecl.documentationComment, isNull); decl.documentationComment = comment; expect(varDecl.documentationComment, isNotNull); @@ -1702,7 +1703,8 @@ class VariableDeclarationTest extends ParserTestCase { void test_getDocumentationComment_onNode() { VariableDeclaration decl = AstTestFactory.variableDeclaration("a"); - Comment comment = astFactory.documentationComment(List(0)); + Comment comment = + astFactory.documentationComment(List.filled(0, null)); decl.documentationComment = comment; expect(decl.documentationComment, isNotNull); } diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart index 95d7b3e190c..8bfa6724c69 100644 --- a/pkg/analyzer/test/generated/non_error_resolver_test.dart +++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart @@ -2045,7 +2045,7 @@ abstract class A { List m(); } class B extends A { - List m() { return new List(); } + List m() { return []; } } '''); } diff --git a/pkg/analyzer/test/generated/non_hint_code_test.dart b/pkg/analyzer/test/generated/non_hint_code_test.dart index bd321295a94..e283dd58309 100644 --- a/pkg/analyzer/test/generated/non_hint_code_test.dart +++ b/pkg/analyzer/test/generated/non_hint_code_test.dart @@ -67,7 +67,7 @@ f(var message) { await assertNoErrorsInCode(r''' class A { } class X { - final x = new List(); + final x = []; } class Z { final X y = new X(); diff --git a/pkg/analyzer/test/generated/utilities_test.dart b/pkg/analyzer/test/generated/utilities_test.dart index 1bb1df606b2..9bf5576b226 100644 --- a/pkg/analyzer/test/generated/utilities_test.dart +++ b/pkg/analyzer/test/generated/utilities_test.dart @@ -3808,7 +3808,7 @@ class StringUtilitiesTest { void test_printListOfQuotedNames_empty() { expect(() { - StringUtilities.printListOfQuotedNames(List(0)); + StringUtilities.printListOfQuotedNames(List.filled(0, null)); }, throwsArgumentError); } diff --git a/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart b/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart index 38435ac1e7e..42bc17b572e 100644 --- a/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart +++ b/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart @@ -14,7 +14,7 @@ main() { } List _b(int length) { - return List(length); + return List.filled(length, null); } @reflectiveTest diff --git a/pkg/analyzer/test/src/dart/analysis/cache_test.dart b/pkg/analyzer/test/src/dart/analysis/cache_test.dart index 67ec3410c13..b966f6387e8 100644 --- a/pkg/analyzer/test/src/dart/analysis/cache_test.dart +++ b/pkg/analyzer/test/src/dart/analysis/cache_test.dart @@ -13,7 +13,7 @@ main() { } List _b(int length) { - return List(length); + return List.filled(length, null); } @reflectiveTest diff --git a/pkg/analyzer/tool/messages/generate.dart b/pkg/analyzer/tool/messages/generate.dart index e8451776802..fb3bfe78be6 100644 --- a/pkg/analyzer/tool/messages/generate.dart +++ b/pkg/analyzer/tool/messages/generate.dart @@ -187,7 +187,7 @@ part of 'syntactic_errors.dart'; } void generateFastaAnalyzerErrorCodeList() { - final sorted = List(translatedEntries.length); + final sorted = List.filled(translatedEntries.length, null); for (var entry in translatedEntries) { var index = entry['index']; if (index is int && index >= 1 && index <= sorted.length) { diff --git a/pkg/analyzer/tool/summary/mini_ast.dart b/pkg/analyzer/tool/summary/mini_ast.dart index c8d5635222f..1993ae8c4b2 100644 --- a/pkg/analyzer/tool/summary/mini_ast.dart +++ b/pkg/analyzer/tool/summary/mini_ast.dart @@ -478,7 +478,7 @@ class MiniAstBuilder extends StackListener { int count, Token leftBracket, Token constKeyword, Token rightBracket) { debugEvent("LiteralList"); - var elements = List(count); + var elements = List.filled(count, null); popList(count, elements); pop(); // type arguments diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart index 60c4e1cb62c..76191aa8527 100644 --- a/pkg/compiler/lib/src/dart2js.dart +++ b/pkg/compiler/lib/src/dart2js.dart @@ -117,7 +117,7 @@ Future compile(List argv, List multiRoots; String multiRootScheme = 'org-dartlang-app'; Uri packageConfig = null; - List options = new List(); + List options = []; bool wantHelp = false; bool wantVersion = false; bool trustTypeAnnotations = false; diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart index bc001f7576b..3e82de2990b 100644 --- a/pkg/compiler/lib/src/dump_info.dart +++ b/pkg/compiler/lib/src/dump_info.dart @@ -442,7 +442,7 @@ class DumpInfoTask extends CompilerTask implements InfoReporter { void reportInlined(FunctionEntity element, MemberEntity inlinedFrom) { inlineCount.putIfAbsent(element, () => 0); inlineCount[element] += 1; - inlineMap.putIfAbsent(inlinedFrom, () => new List()); + inlineMap.putIfAbsent(inlinedFrom, () => []); inlineMap[inlinedFrom].add(element); } @@ -486,9 +486,7 @@ class DumpInfoTask extends CompilerTask implements InfoReporter { void registerEntityAst(Entity entity, jsAst.Node code, {LibraryEntity library}) { if (compiler.options.dumpInfo) { - _entityToNodes - .putIfAbsent(entity, () => new List()) - .add(code); + _entityToNodes.putIfAbsent(entity, () => []).add(code); _nodeData[code] ??= useBinaryFormat ? new CodeSpan() : new _CodeData(); } } diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart index 7cb8bc23ecc..8a660e2eaaa 100644 --- a/pkg/compiler/lib/src/elements/types.dart +++ b/pkg/compiler/lib/src/elements/types.dart @@ -28,7 +28,7 @@ extension on DataSource { List _readDartTypes( List functionTypeVariables) { int count = readInt(); - List types = List(count); + List types = List.filled(count, null); for (int index = 0; index < count; index++) { types[index] = DartType.readFromDataSource(this, functionTypeVariables); } @@ -717,7 +717,8 @@ class FunctionType extends DartType { source._readDartTypes(functionTypeVariables); List namedParameterTypes = source._readDartTypes(functionTypeVariables); - List namedParameters = List(namedParameterTypes.length); + List namedParameters = + List.filled(namedParameterTypes.length, null); var requiredNamedParameters = {}; for (int i = 0; i < namedParameters.length; i++) { namedParameters[i] = source.readString(); @@ -1036,7 +1037,7 @@ class _LegacyErasureVisitor extends DartTypeVisitor { var length = oldTypeVariables.length; List typeVariables = - List(length); + List.filled(length, null); List erasableTypeVariables = []; List erasedTypeVariables = []; for (int i = 0; i < length; i++) { diff --git a/pkg/compiler/lib/src/helpers/expensive_map.dart b/pkg/compiler/lib/src/helpers/expensive_map.dart index 149e811539d..91098f5fe3e 100644 --- a/pkg/compiler/lib/src/helpers/expensive_map.dart +++ b/pkg/compiler/lib/src/helpers/expensive_map.dart @@ -10,7 +10,7 @@ import "dart:collection"; class ExpensiveMap extends MapBase { final List _maps; - ExpensiveMap([int copies = 10]) : _maps = new List(copies) { + ExpensiveMap([int copies = 10]) : _maps = new List.filled(copies, null) { assert(copies > 0); for (int i = 0; i < _maps.length; i++) { _maps[i] = new Map(); diff --git a/pkg/compiler/lib/src/helpers/expensive_set.dart b/pkg/compiler/lib/src/helpers/expensive_set.dart index 4c5101eee6b..cc41f8b03b0 100644 --- a/pkg/compiler/lib/src/helpers/expensive_set.dart +++ b/pkg/compiler/lib/src/helpers/expensive_set.dart @@ -10,7 +10,7 @@ import 'dart:collection'; class ExpensiveSet extends SetBase { final List _sets; - ExpensiveSet([int copies = 10]) : _sets = new List(copies) { + ExpensiveSet([int copies = 10]) : _sets = new List.filled(copies, null) { assert(copies > 0); for (int i = 0; i < _sets.length; i++) { _sets[i] = new Set(); diff --git a/pkg/compiler/lib/src/inferrer/builder_kernel.dart b/pkg/compiler/lib/src/inferrer/builder_kernel.dart index 55d7ab6d24b..fdfd67ec534 100644 --- a/pkg/compiler/lib/src/inferrer/builder_kernel.dart +++ b/pkg/compiler/lib/src/inferrer/builder_kernel.dart @@ -1243,15 +1243,15 @@ class KernelTypeGraphBuilder extends ir.Visitor { var commonElements = _elementMap.commonElements; if (commonElements.isUnnamedListConstructor(constructor)) { - // We have `new List(...)`. + // We have `new List.filled(..., null)`. if (arguments.positional.isEmpty && arguments.named.isEmpty) { - // We have `new List()`. + // We have `[]`. return _inferrer.concreteTypes.putIfAbsent( node, () => _types.allocateList(_types.growableListType, node, _analyzedMember, _types.nonNullEmpty(), 0)); } else { - // We have `new List(len)`. + // We have `new List.filled(len, null)`. int length = _findLength(arguments); return _inferrer.concreteTypes.putIfAbsent( node, diff --git a/pkg/compiler/lib/src/inferrer/closure_tracer.dart b/pkg/compiler/lib/src/inferrer/closure_tracer.dart index 809b850c2bf..18eb0ca8f50 100644 --- a/pkg/compiler/lib/src/inferrer/closure_tracer.dart +++ b/pkg/compiler/lib/src/inferrer/closure_tracer.dart @@ -15,7 +15,7 @@ import 'type_graph_nodes.dart'; class ClosureTracerVisitor extends TracerVisitor { final Iterable tracedElements; final List _callsToAnalyze = - new List(); + []; ClosureTracerVisitor(this.tracedElements, ApplyableTypeInformation tracedType, InferrerEngine inferrer) diff --git a/pkg/compiler/lib/src/inferrer/type_graph_dump.dart b/pkg/compiler/lib/src/inferrer/type_graph_dump.dart index c215ca1b240..ac9c9018da1 100644 --- a/pkg/compiler/lib/src/inferrer/type_graph_dump.dart +++ b/pkg/compiler/lib/src/inferrer/type_graph_dump.dart @@ -136,7 +136,7 @@ class TypeGraphDump { class _GraphGenerator extends TypeInformationVisitor { final TypeGraphDump global; final Set seen = new Set(); - final List worklist = new List(); + final List worklist = []; final Map nodeId = {}; final String Function(AbstractValue) formatType; int usedIds = 0; diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart index 78664ebac93..f791743c5a1 100644 --- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart +++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart @@ -115,7 +115,8 @@ abstract class TypeInformation { // The below is not a compile time constant to make it differentiable // from other empty lists of [TypeInformation]. - static final STOP_TRACKING_INPUTS_MARKER = new List(0); + static final STOP_TRACKING_INPUTS_MARKER = + new List.filled(0, null); bool areInputsTracked() { return inputs != STOP_TRACKING_INPUTS_MARKER; diff --git a/pkg/compiler/lib/src/io/source_map_builder.dart b/pkg/compiler/lib/src/io/source_map_builder.dart index 654c87bd34f..a630dd513d3 100644 --- a/pkg/compiler/lib/src/io/source_map_builder.dart +++ b/pkg/compiler/lib/src/io/source_map_builder.dart @@ -22,7 +22,7 @@ class SourceMapBuilder { final Uri targetFileUri; final LocationProvider locationProvider; - final List entries = new List(); + final List entries = []; /// Extension used to deobfuscate minified names in error messages. final Map minifiedGlobalNames; diff --git a/pkg/compiler/lib/src/ir/static_type.dart b/pkg/compiler/lib/src/ir/static_type.dart index 49f5eb282d2..9527cd2934f 100644 --- a/pkg/compiler/lib/src/ir/static_type.dart +++ b/pkg/compiler/lib/src/ir/static_type.dart @@ -644,7 +644,8 @@ abstract class StaticTypeVisitor extends StaticTypeBase { if (arguments.positional.isEmpty) { positional = const []; } else { - positional = new List(arguments.positional.length); + positional = + new List.filled(arguments.positional.length, null); int index = 0; for (ir.Expression argument in arguments.positional) { positional[index++] = visitNode(argument); @@ -653,7 +654,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase { if (arguments.named.isEmpty) { named = const []; } else { - named = new List(arguments.named.length); + named = new List.filled(arguments.named.length, null); int index = 0; for (ir.NamedExpression argument in arguments.named) { named[index++] = visitNode(argument); diff --git a/pkg/compiler/lib/src/js/rewrite_async.dart b/pkg/compiler/lib/src/js/rewrite_async.dart index 60e8c84ee91..53e156afa76 100644 --- a/pkg/compiler/lib/src/js/rewrite_async.dart +++ b/pkg/compiler/lib/src/js/rewrite_async.dart @@ -1400,7 +1400,7 @@ abstract class AsyncRewriterBase extends js.NodeVisitor { breakLabels[node] = after; beginLabel(before); - List labels = new List(node.cases.length); + List labels = new List.filled(node.cases.length, null); bool anyCaseExpressionTransformed = node.cases.any( (js.SwitchClause x) => x is js.Case && shouldTransform(x.expression)); diff --git a/pkg/compiler/lib/src/js_backend/field_naming_mixin.dart b/pkg/compiler/lib/src/js_backend/field_naming_mixin.dart index a0fb0b3ad16..3954c4c8922 100644 --- a/pkg/compiler/lib/src/js_backend/field_naming_mixin.dart +++ b/pkg/compiler/lib/src/js_backend/field_naming_mixin.dart @@ -48,7 +48,7 @@ class _FieldNamingRegistry { int globalCount = 0; - final List nameStore = new List(); + final List nameStore = []; _FieldNamingRegistry(this.namer); diff --git a/pkg/compiler/lib/src/js_backend/frequency_namer.dart b/pkg/compiler/lib/src/js_backend/frequency_namer.dart index f929e7a40f8..9d0eb7127c8 100644 --- a/pkg/compiler/lib/src/js_backend/frequency_namer.dart +++ b/pkg/compiler/lib/src/js_backend/frequency_namer.dart @@ -9,7 +9,7 @@ class FrequencyBasedNamer extends Namer implements jsAst.TokenFinalizer { @override _FieldNamingRegistry fieldRegistry; - List tokens = new List(); + List tokens = []; Map _tokenScopes = new Maplet(); diff --git a/pkg/compiler/lib/src/js_backend/runtime_types.dart b/pkg/compiler/lib/src/js_backend/runtime_types.dart index c8084d5bc62..29980124e52 100644 --- a/pkg/compiler/lib/src/js_backend/runtime_types.dart +++ b/pkg/compiler/lib/src/js_backend/runtime_types.dart @@ -994,7 +994,7 @@ class ClassUse { /// For instance `A` in: /// /// class A {} - /// main() => new List() is List; + /// main() => [] is List; /// bool typeArgument = false; @@ -1003,7 +1003,7 @@ class ClassUse { /// For instance `A` in: /// /// class A {} - /// main() => new List() is List; + /// main() => [] is List; /// bool checkedTypeArgument = false; diff --git a/pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart index 1016f9ab0f0..cef6e379c98 100644 --- a/pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart +++ b/pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart @@ -112,15 +112,17 @@ class ParameterStubGenerator { String receiverArgumentName = r'$receiver'; // The parameters that this stub takes. - List stubParameters = new List( + List stubParameters = new List.filled( extraArgumentCount + selector.argumentCount + - selector.typeArgumentCount); + selector.typeArgumentCount, + null); // The arguments that will be passed to the real method. - List targetArguments = new List( + List targetArguments = new List.filled( extraArgumentCount + parameterStructure.totalParameters + - parameterStructure.typeParameters); + parameterStructure.typeParameters, + null); int count = 0; if (isInterceptedMethod) { diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart index 0d0b4382f00..351d6bc22cd 100644 --- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart +++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart @@ -250,7 +250,8 @@ class ProgramBuilder { Iterable deferredFragments = _registry.deferredLibrariesMap.map(_buildDeferredFragment); - List fragments = new List(_registry.librariesMapCount); + List fragments = + new List.filled(_registry.librariesMapCount, null); fragments[0] = mainFragment; fragments.setAll(1, deferredFragments); @@ -480,7 +481,8 @@ class ProgramBuilder { } List _buildLibraries(LibrariesMap librariesMap) { - List libraries = new List(librariesMap.length); + List libraries = + new List.filled(librariesMap.length, null); int count = 0; librariesMap.forEach((LibraryEntity library, List classes, List members, List classTypeElements) { diff --git a/pkg/compiler/lib/src/ordered_typeset.dart b/pkg/compiler/lib/src/ordered_typeset.dart index dcbcf37d819..8be49709567 100644 --- a/pkg/compiler/lib/src/ordered_typeset.dart +++ b/pkg/compiler/lib/src/ordered_typeset.dart @@ -55,7 +55,7 @@ class OrderedTypeSet { int levelCount = source.readInt(); List> levels = - new List>(levelCount); + new List>.filled(levelCount, null); for (int i = 0; i < levelCount; i++) { levels[i] = links[source.readInt()]; } @@ -90,7 +90,8 @@ class OrderedTypeSet { factory OrderedTypeSet.singleton(InterfaceType type) { Link types = new LinkEntry(type, const Link()); - List> list = new List>(1); + List> list = + new List>.filled(1, null); list[0] = types; return new OrderedTypeSet.internal(list, types); } @@ -107,7 +108,8 @@ class OrderedTypeSet { 'OrderedTypeSet.extendClass')); Link extendedTypes = new LinkEntry(type, types); - List> list = new List>(levels + 1); + List> list = + new List>.filled(levels + 1, null); for (int i = 0; i < levels; i++) { list[i] = _levels[i]; } @@ -257,7 +259,7 @@ abstract class OrderedTypeSetBuilderBase implements OrderedTypeSetBuilder { OrderedTypeSet toTypeSet() { List> levels = - new List>(maxDepth + 1); + new List>.filled(maxDepth + 1, null); if (maxDepth < 0) { return new OrderedTypeSet.internal(levels, const Link()); } diff --git a/pkg/compiler/lib/src/serialization/abstract_source.dart b/pkg/compiler/lib/src/serialization/abstract_source.dart index b3ad306ffbf..c1e8ea1ee86 100644 --- a/pkg/compiler/lib/src/serialization/abstract_source.dart +++ b/pkg/compiler/lib/src/serialization/abstract_source.dart @@ -143,7 +143,7 @@ abstract class AbstractDataSource extends DataSourceMixin List _readDartTypeNodes( List functionTypeVariables) { int count = readInt(); - List types = new List(count); + List types = new List.filled(count, null); for (int index = 0; index < count; index++) { types[index] = _readDartTypeNode(functionTypeVariables); } @@ -229,7 +229,7 @@ abstract class AbstractDataSource extends DataSourceMixin _readDartTypeNodes(functionTypeVariables); int namedParameterCount = readInt(); List namedParameters = - new List(namedParameterCount); + new List.filled(namedParameterCount, null); for (int index = 0; index < namedParameterCount; index++) { String name = readString(); bool isRequired = readBool(); @@ -427,7 +427,7 @@ abstract class AbstractDataSource extends DataSourceMixin {bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { ir.TreeNode node = readTreeNodeInContextInternal(currentMemberData); list[i] = node; diff --git a/pkg/compiler/lib/src/serialization/mixins.dart b/pkg/compiler/lib/src/serialization/mixins.dart index 3718e257af6..d7d5d87fa4b 100644 --- a/pkg/compiler/lib/src/serialization/mixins.dart +++ b/pkg/compiler/lib/src/serialization/mixins.dart @@ -19,7 +19,7 @@ abstract class DataSourceMixin implements DataSource { List readList(E f(), {bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { list[i] = f(); } @@ -48,7 +48,7 @@ abstract class DataSourceMixin implements DataSource { List readStrings({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { list[i] = readString(); } @@ -59,7 +59,7 @@ abstract class DataSourceMixin implements DataSource { List readDartTypes({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { list[i] = readDartType(); } @@ -70,7 +70,8 @@ abstract class DataSourceMixin implements DataSource { List readTypeParameterNodes({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = + new List.filled(count, null); for (int i = 0; i < count; i++) { list[i] = readTypeParameterNode(); } @@ -81,7 +82,7 @@ abstract class DataSourceMixin implements DataSource { List readMembers({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { MemberEntity member = readMember(); list[i] = member; @@ -93,7 +94,7 @@ abstract class DataSourceMixin implements DataSource { List readMemberNodes({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { ir.Member value = readMemberNode(); list[i] = value; @@ -105,7 +106,7 @@ abstract class DataSourceMixin implements DataSource { List readClasses({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { ClassEntity cls = readClass(); list[i] = cls; @@ -187,7 +188,7 @@ abstract class DataSourceMixin implements DataSource { List readLocals({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { Local local = readLocal(); list[i] = local; @@ -212,7 +213,7 @@ abstract class DataSourceMixin implements DataSource { List readTreeNodes({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { ir.TreeNode node = readTreeNode(); list[i] = node; @@ -282,7 +283,7 @@ abstract class DataSourceMixin implements DataSource { List readConstants({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { ConstantValue value = readConstant(); list[i] = value; @@ -326,7 +327,7 @@ abstract class DataSourceMixin implements DataSource { List readImports({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { list[i] = readImport(); } @@ -350,7 +351,7 @@ abstract class DataSourceMixin implements DataSource { List readDartTypeNodes({bool emptyAsNull: false}) { int count = readInt(); if (count == 0 && emptyAsNull) return null; - List list = new List(count); + List list = new List.filled(count, null); for (int i = 0; i < count; i++) { list[i] = readDartTypeNode(); } diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart index e1c0789030f..e81ca798663 100644 --- a/pkg/compiler/lib/src/ssa/builder_kernel.dart +++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart @@ -3816,12 +3816,12 @@ class KernelSsaGraphBuilder extends ir.Visitor { return; } - // Recognize `List()` and `List(n)`. + // Recognize `[]` and `List.filled(n, null)`. if (_commonElements.isUnnamedListConstructor(function)) { if (invocation.arguments.named.isEmpty) { int argumentCount = invocation.arguments.positional.length; if (argumentCount == 0) { - // `List()` takes no arguments, `JSArray.list()` takes a sentinel. + // `[]` takes no arguments, `JSArray.list()` takes a sentinel. assert(arguments.length == 0 || arguments.length == 1, '\narguments: $arguments\n'); _handleInvokeLegacyGrowableListFactoryConstructor( @@ -3936,14 +3936,14 @@ class KernelSsaGraphBuilder extends ir.Visitor { stack.add(_setListRuntimeTypeInfoIfNeeded(pop(), type, sourceInformation)); } - /// Handle the legacy `List()` constructor. + /// Handle the legacy `[]` constructor. void _handleInvokeLegacyGrowableListFactoryConstructor( ir.StaticInvocation invocation, ConstructorEntity function, AbstractValue typeMask, List arguments, SourceInformation sourceInformation) { - // `List()` is essentially the same as `[]`. + // `[]` is essentially the same as `[]`. push(_buildLiteralList([])); HInstruction allocation = pop(); var inferredType = globalInferenceResults.typeOfNewList(invocation); @@ -3956,7 +3956,7 @@ class KernelSsaGraphBuilder extends ir.Visitor { _setListRuntimeTypeInfoIfNeeded(allocation, type, sourceInformation)); } - /// Handle the `JSArray.list(length)` and legacy `List(length)` + /// Handle the `JSArray.list(length)` and legacy `List.filled(length, null)` /// constructors. void _handleInvokeLegacyFixedListFactoryConstructor( ir.StaticInvocation invocation, @@ -5215,7 +5215,7 @@ class KernelSsaGraphBuilder extends ir.Visitor { var argumentsInstruction = _buildLiteralList(arguments); add(argumentsInstruction); - var argumentNames = new List(); + var argumentNames = []; for (String argumentName in selector.namedArguments) { ConstantValue argumentNameConstant = constant_system.createString(argumentName); @@ -5865,10 +5865,11 @@ class KernelSsaGraphBuilder extends ir.Visitor { ParameterStructure parameterStructure = function.parameterStructure; List selectorArgumentNames = selector.callStructure.getOrderedNamedArguments(); - List compiledArguments = new List( + List compiledArguments = new List.filled( parameterStructure.totalParameters + parameterStructure.typeParameters + - 1); // Plus one for receiver. + 1, + null); // Plus one for receiver. int compiledArgumentIndex = 0; diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart index 7c501162f64..098531fdd5d 100644 --- a/pkg/compiler/lib/src/ssa/codegen.dart +++ b/pkg/compiler/lib/src/ssa/codegen.dart @@ -642,7 +642,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { List visitArguments(List inputs, {int start: HInvoke.ARGUMENTS_OFFSET}) { assert(inputs.length >= start); - List result = new List(inputs.length - start); + List result = new List.filled(inputs.length - start, null); for (int i = start; i < inputs.length; i++) { use(inputs[i]); result[i - start] = pop(); diff --git a/pkg/compiler/lib/src/ssa/codegen_helpers.dart b/pkg/compiler/lib/src/ssa/codegen_helpers.dart index 6aa5a3cf98c..cb8a95e272e 100644 --- a/pkg/compiler/lib/src/ssa/codegen_helpers.dart +++ b/pkg/compiler/lib/src/ssa/codegen_helpers.dart @@ -886,7 +886,7 @@ class SsaInstructionMerger extends HBaseVisitor with CodegenPhase { // The expectedInputs list holds non-trivial instructions that may // be generated at their use site, if they occur in the correct order. - if (expectedInputs == null) expectedInputs = new List(); + if (expectedInputs == null) expectedInputs = []; if (pureInputs == null) pureInputs = new Set(); // Pop instructions from expectedInputs until instruction is found. diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart index 115e891fa5a..25b48a8ae04 100644 --- a/pkg/compiler/lib/src/ssa/nodes.dart +++ b/pkg/compiler/lib/src/ssa/nodes.dart @@ -3789,8 +3789,8 @@ class HLoopInformation { HLoopBlockInformation loopBlockInformation; HLoopInformation(this.header, this.target, this.labels) - : blocks = new List(), - backEdges = new List(); + : blocks = [], + backEdges = []; void addBackEdge(HBasicBlock predecessor) { backEdges.add(predecessor); diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart index 5ea6c697f01..b855b900748 100644 --- a/pkg/compiler/lib/src/ssa/optimize.dart +++ b/pkg/compiler/lib/src/ssa/optimize.dart @@ -2964,8 +2964,8 @@ class SsaGlobalValueNumberer implements OptimizationPhase { // loop changes flags list to zero so we can use bitwise or when // propagating loop changes upwards. final int length = graph.blocks.length; - blockChangesFlags = new List(length); - loopChangesFlags = new List(length); + blockChangesFlags = new List.filled(length, null); + loopChangesFlags = new List.filled(length, null); for (int i = 0; i < length; i++) loopChangesFlags[i] = 0; // Run through all the basic blocks in the graph and fill in the @@ -3046,7 +3046,7 @@ class SsaCodeMotion extends HBaseVisitor implements OptimizationPhase { @override void visitGraph(HGraph graph) { - values = new List(graph.blocks.length); + values = new List.filled(graph.blocks.length, null); for (int i = 0; i < graph.blocks.length; i++) { values[graph.blocks[i].id] = new ValueSet(); } @@ -3315,7 +3315,7 @@ class SsaLoadElimination extends HBaseVisitor implements OptimizationPhase { @override void visitGraph(HGraph graph) { _graph = graph; - memories = new List(graph.blocks.length); + memories = new List.filled(graph.blocks.length, null); List blocks = graph.blocks; for (int i = 0; i < blocks.length; i++) { HBasicBlock block = blocks[i]; diff --git a/pkg/compiler/lib/src/ssa/types_propagation.dart b/pkg/compiler/lib/src/ssa/types_propagation.dart index 12fabcf9181..a5a1581b805 100644 --- a/pkg/compiler/lib/src/ssa/types_propagation.dart +++ b/pkg/compiler/lib/src/ssa/types_propagation.dart @@ -31,7 +31,7 @@ import 'optimize.dart'; // targeted conditioning checks. class SsaTypePropagator extends HBaseVisitor implements OptimizationPhase { final Map workmap = new Map(); - final List worklist = new List(); + final List worklist = []; final Map pendingOptimizations = new Map(); diff --git a/pkg/compiler/lib/src/ssa/value_set.dart b/pkg/compiler/lib/src/ssa/value_set.dart index b24a5600570..f2a6148b81d 100644 --- a/pkg/compiler/lib/src/ssa/value_set.dart +++ b/pkg/compiler/lib/src/ssa/value_set.dart @@ -9,7 +9,7 @@ class ValueSet { int size = 0; List table; ValueSetNode collisions; - ValueSet() : table = new List(8); + ValueSet() : table = new List.filled(8, null); bool get isEmpty => size == 0; int get length => size; @@ -138,7 +138,7 @@ class ValueSet { // Reset the table with a bigger capacity. assert(capacity > table.length); size = 0; - table = new List(capacity); + table = new List.filled(capacity, null); collisions = null; // Add the old instructions to the new table. copyTo(this, oldTable, oldCollisions); diff --git a/pkg/compiler/lib/src/ssa/variable_allocator.dart b/pkg/compiler/lib/src/ssa/variable_allocator.dart index 338204e631a..c279758e69e 100644 --- a/pkg/compiler/lib/src/ssa/variable_allocator.dart +++ b/pkg/compiler/lib/src/ssa/variable_allocator.dart @@ -59,7 +59,7 @@ class LiveInterval { @override String toString() { - List res = new List(); + List res = []; for (final interval in ranges) res.add(interval.toString()); return '(${res.join(", ")})'; } @@ -376,8 +376,8 @@ class CopyHandler { final List> assignments; CopyHandler() - : copies = new List>(), - assignments = new List>(); + : copies = >[], + assignments = >[]; void addCopy(HInstruction source, HInstruction destination) { copies.add(new Copy(source, destination)); @@ -458,7 +458,7 @@ class VariableNamer { VariableNamer(LiveEnvironment environment, this.names, this._namer) : usedNames = new Set(), - freeTemporaryNames = new List() { + freeTemporaryNames = [] { // [VariableNames.swapTemp] is used when there is a cycle in a copy handler. // Therefore we make sure no one uses it. usedNames.add(names.swapTemp); diff --git a/pkg/compiler/lib/src/util/maplet.dart b/pkg/compiler/lib/src/util/maplet.dart index 329853c3b7c..6c46fed2966 100644 --- a/pkg/compiler/lib/src/util/maplet.dart +++ b/pkg/compiler/lib/src/util/maplet.dart @@ -99,7 +99,7 @@ class Maplet extends MapBase { } else if (_key == key) { _value = value; } else { - List list = new List(CAPACITY * 2); + List list = new List.filled(CAPACITY * 2, null); list[0] = _key; list[1] = key; list[CAPACITY] = _value; diff --git a/pkg/compiler/lib/src/util/setlet.dart b/pkg/compiler/lib/src/util/setlet.dart index e35c12b5a5d..a2870a40d42 100644 --- a/pkg/compiler/lib/src/util/setlet.dart +++ b/pkg/compiler/lib/src/util/setlet.dart @@ -91,7 +91,7 @@ class Setlet extends SetBase { // Do nothing. return false; } else { - List list = new List(CAPACITY); + List list = new List.filled(CAPACITY, null); list[0] = _contents; list[1] = element; _contents = list; diff --git a/pkg/compiler/lib/src/util/util.dart b/pkg/compiler/lib/src/util/util.dart index 423c0b2d783..7b5e9fd9845 100644 --- a/pkg/compiler/lib/src/util/util.dart +++ b/pkg/compiler/lib/src/util/util.dart @@ -88,7 +88,7 @@ class Hashing { /// [existing]. static int unorderedMapHash(Map map, [int existing = 0]) { if (map.length == 0) return existing; - List hashCodes = List(map.length); + List hashCodes = List.filled(map.length, null); int i = 0; for (var entry in map.entries) { hashCodes[i++] = objectHash(entry.key, objectHash(entry.value)); diff --git a/pkg/dds/test/web/sse_smoke_driver.dart.js b/pkg/dds/test/web/sse_smoke_driver.dart.js index 1fc97584079..bab69937ff3 100644 --- a/pkg/dds/test/web/sse_smoke_driver.dart.js +++ b/pkg/dds/test/web/sse_smoke_driver.dart.js @@ -4479,7 +4479,7 @@ }, Iterator: function Iterator() { }, - List: function List() { + List: function [] { }, Map: function Map() { }, diff --git a/pkg/dev_compiler/doc/GENERIC_METHOD_COMMENTS.md b/pkg/dev_compiler/doc/GENERIC_METHOD_COMMENTS.md index 9050eab7fe7..8f236577d2e 100644 --- a/pkg/dev_compiler/doc/GENERIC_METHOD_COMMENTS.md +++ b/pkg/dev_compiler/doc/GENERIC_METHOD_COMMENTS.md @@ -139,7 +139,7 @@ original type is used at runtime, it may cause checked mode errors: ```dart List/**/ makeList/**/() { - return new List(); + return []; } void main() { @@ -174,7 +174,7 @@ List foo/**/(/*=S*/ x) { var l0 = [x]; // as above, but with a regular constructor. - var l1 = new List(); + var l1 = []; return l1; } ``` diff --git a/pkg/dev_compiler/lib/src/compiler/module_containers.dart b/pkg/dev_compiler/lib/src/compiler/module_containers.dart index 82f06b4fd09..6c766886f8d 100644 --- a/pkg/dev_compiler/lib/src/compiler/module_containers.dart +++ b/pkg/dev_compiler/lib/src/compiler/module_containers.dart @@ -227,7 +227,7 @@ class ModuleItemArrayContainer extends ModuleItemContainer { @override List emit() { if (moduleItems.isEmpty) return []; - var properties = List(length); + var properties = List.filled(length, null); // If the entire array holds just one value, generate a short initializer. var valueSet = {}; diff --git a/pkg/dev_compiler/lib/src/js_ast/builder.dart b/pkg/dev_compiler/lib/src/js_ast/builder.dart index ed3c8e396a2..42a451127d8 100644 --- a/pkg/dev_compiler/lib/src/js_ast/builder.dart +++ b/pkg/dev_compiler/lib/src/js_ast/builder.dart @@ -1676,7 +1676,7 @@ class MiniJsParser { Expression key = parseExpression(); expectCategory(RPAREN); expectCategory(LBRACE); - var clauses = List(); + var clauses = []; while (lastCategory != RBRACE) { clauses.add(parseSwitchClause()); } @@ -1701,7 +1701,7 @@ class MiniJsParser { heritage = parseConditional(); } expectCategory(LBRACE); - var methods = List(); + var methods = []; while (lastCategory != RBRACE) { methods.add(parseMethodOrProperty(onlyMethods: true) as Method); } diff --git a/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt b/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt index 7803de7b76c..033628245cd 100644 --- a/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt +++ b/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt @@ -1,11 +1,11 @@ ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|3679|5|94|Const constructors can't throw exceptions. -ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|7881|5|97|Const constructors can't throw exceptions. +ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|7878|5|97|Const constructors can't throw exceptions. ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|893|5|95|Const constructors can't throw exceptions. ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|926|5|94|Const constructors can't throw exceptions. ERROR|COMPILE_TIME_ERROR|INVALID_ASSIGNMENT|lib/_internal/js_dev_runtime/private/interceptors.dart|1358|18|27|A value of type 'double' can't be assigned to a variable of type 'int'. ERROR|COMPILE_TIME_ERROR|RETURN_OF_INVALID_TYPE|lib/_internal/js_dev_runtime/private/interceptors.dart|1225|14|38|A value of type 'double' can't be returned from method '%' because it has a return type of 'JSNumber'. ERROR|COMPILE_TIME_ERROR|RETURN_OF_INVALID_TYPE|lib/_internal/js_dev_runtime/private/interceptors.dart|1227|14|38|A value of type 'double' can't be returned from method '%' because it has a return type of 'JSNumber'. ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|3677|3|5|Only redirecting factory constructors can be declared to be 'const'. -ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|7879|3|5|Only redirecting factory constructors can be declared to be 'const'. +ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|7876|3|5|Only redirecting factory constructors can be declared to be 'const'. ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|891|3|5|Only redirecting factory constructors can be declared to be 'const'. ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|924|3|5|Only redirecting factory constructors can be declared to be 'const'. diff --git a/pkg/front_end/lib/src/api_unstable/bazel_worker.dart b/pkg/front_end/lib/src/api_unstable/bazel_worker.dart index d4445e440d5..48df5c91a2d 100644 --- a/pkg/front_end/lib/src/api_unstable/bazel_worker.dart +++ b/pkg/front_end/lib/src/api_unstable/bazel_worker.dart @@ -77,7 +77,7 @@ Future initializeIncrementalCompiler( bool verbose: false, NnbdMode nnbdMode: NnbdMode.Weak}) async { List outputLoadedAdditionalDills = - new List(additionalDills.length); + new List.filled(additionalDills.length, null); Map experimentalFlags = parseExperimentalFlags( parseExperimentalArguments(experiments), onError: (e) => throw e); diff --git a/pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.dart b/pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.dart index 691483d0eb7..eb80f977b15 100644 --- a/pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.dart +++ b/pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.dart @@ -156,7 +156,7 @@ Future initializeIncrementalCompiler( if (trackNeededDillLibraries) { libraryToInputDill = new Map(); } - List loadFromDillIndexes = new List(); + List loadFromDillIndexes = []; // Notice that the ordering of the input summaries matter, so we need to // keep them in order. diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart index 9ab9035ef72..7414b1c9e13 100644 --- a/pkg/front_end/lib/src/base/processed_options.dart +++ b/pkg/front_end/lib/src/base/processed_options.dart @@ -216,7 +216,8 @@ class ProcessedOptions { command_line_reporting.format(message, severity, location: location); List formattedContext; if (context != null && context.isNotEmpty) { - formattedContext = new List(context.length); + formattedContext = + new List.filled(context.length, null); for (int i = 0; i < context.length; i++) { formattedContext[i] = format(context[i], Severity.context, null); } diff --git a/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart b/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart index 2c0f03192c6..03f46c73312 100644 --- a/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart @@ -263,7 +263,7 @@ class ConstructorBuilderImpl extends FunctionBuilderImpl FunctionNode functionNode = super.buildFunction(library); ClassBuilder enclosingClassBuilder = parent; Class enclosingClass = enclosingClassBuilder.cls; - List typeParameterTypes = new List(); + List typeParameterTypes = []; for (int i = 0; i < enclosingClass.typeParameters.length; i++) { TypeParameter typeParameter = enclosingClass.typeParameters[i]; typeParameterTypes.add( diff --git a/pkg/front_end/lib/src/fasta/builder/function_builder.dart b/pkg/front_end/lib/src/fasta/builder/function_builder.dart index 2fea24a79ac..129c01a61e9 100644 --- a/pkg/front_end/lib/src/fasta/builder/function_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/function_builder.dart @@ -461,7 +461,7 @@ abstract class FunctionBuilderImpl extends MemberBuilderImpl _extensionThis = result.positionalParameters.first; if (extensionBuilder.typeParameters != null) { int count = extensionBuilder.typeParameters.length; - _extensionTypeParameters = new List(count); + _extensionTypeParameters = new List.filled(count, null); for (int index = 0; index < count; index++) { _extensionTypeParameters[index] = result.typeParameters[index]; } diff --git a/pkg/front_end/lib/src/fasta/builder/function_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/function_type_builder.dart index b360b523a6b..3143c2d8643 100644 --- a/pkg/front_end/lib/src/fasta/builder/function_type_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/function_type_builder.dart @@ -130,14 +130,16 @@ class FunctionTypeBuilder extends TypeBuilder { FunctionTypeBuilder clone(List newTypes) { List clonedTypeVariables; if (typeVariables != null) { - clonedTypeVariables = new List(typeVariables.length); + clonedTypeVariables = + new List.filled(typeVariables.length, null); for (int i = 0; i < clonedTypeVariables.length; i++) { clonedTypeVariables[i] = typeVariables[i].clone(newTypes); } } List clonedFormals; if (formals != null) { - clonedFormals = new List(formals.length); + clonedFormals = + new List.filled(formals.length, null); for (int i = 0; i < clonedFormals.length; i++) { FormalParameterBuilder formal = formals[i]; clonedFormals[i] = formal.clone(newTypes); diff --git a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart index e09e091f256..54cd164b132 100644 --- a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart @@ -399,7 +399,7 @@ class NamedTypeBuilder extends TypeBuilder { NamedTypeBuilder clone(List newTypes) { List clonedArguments; if (arguments != null) { - clonedArguments = new List(arguments.length); + clonedArguments = new List.filled(arguments.length, null); for (int i = 0; i < clonedArguments.length; i++) { clonedArguments[i] = arguments[i].clone(newTypes); } diff --git a/pkg/front_end/lib/src/fasta/builder/procedure_builder.dart b/pkg/front_end/lib/src/fasta/builder/procedure_builder.dart index 18d69f70106..f4962fba0bd 100644 --- a/pkg/front_end/lib/src/fasta/builder/procedure_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/procedure_builder.dart @@ -722,7 +722,7 @@ class RedirectingFactoryBuilder extends ProcedureBuilderImpl { actualOrigin.function.typeParameters[i], library.library); } List newTypeArguments = - new List(typeArguments.length); + new List.filled(typeArguments.length, null); for (int i = 0; i < newTypeArguments.length; i++) { newTypeArguments[i] = substitute(typeArguments[i], substitution); } @@ -755,8 +755,8 @@ class RedirectingFactoryBuilder extends ProcedureBuilderImpl { } _procedure.isRedirectingFactoryConstructor = true; if (redirectionTarget.typeArguments != null) { - typeArguments = - new List(redirectionTarget.typeArguments.length); + typeArguments = new List.filled( + redirectionTarget.typeArguments.length, null); for (int i = 0; i < typeArguments.length; i++) { typeArguments[i] = redirectionTarget.typeArguments[i].build(library); } diff --git a/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart index 73c8433a582..a548f80c5f2 100644 --- a/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart +++ b/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart @@ -149,7 +149,7 @@ class DillClassBuilder extends ClassBuilderImpl { if (cls.implementedTypes.isEmpty) return null; if (super.interfaceBuilders == null) { List result = - new List(cls.implementedTypes.length); + new List.filled(cls.implementedTypes.length, null); for (int i = 0; i < result.length; i++) { result[i] = computeTypeBuilder(library, cls.implementedTypes[i]); } diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart index a354e884ff5..35c074ec253 100644 --- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart +++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart @@ -537,7 +537,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { } } } else { - outputLibraries = new List(); + outputLibraries = []; allLibraries = computeTransitiveClosure( compiledLibraries, entryPoints, @@ -895,7 +895,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { ExperimentalInvalidation experimentalInvalidation, ReusageResult reusedResult) { if (hierarchy != null) { - List removedLibraries = new List(); + List removedLibraries = []; // TODO(jensj): For now remove all the original from the class hierarchy // to avoid the class hierarchy getting confused. if (experimentalInvalidation != null) { @@ -1232,7 +1232,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { if (hierarchy is ClosedWorldClassHierarchy && !hierarchy.allBetsOff) { neededDillLibraries ??= new Set(); Set classes = new Set(); - List worklist = new List(); + List worklist = []; // Get all classes touched by kernel class hierarchy. List usedClasses = hierarchy.getUsedClasses(); worklist.addAll(usedClasses); @@ -1447,7 +1447,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { UriTranslator uriTranslator, Map uriToSource, [List inputLibrariesFiltered]) { - List result = new List(); + List result = []; Map libraryMap = {}; Map potentiallyReferencedLibraries = {}; Map potentiallyReferencedInputLibraries = {}; @@ -1462,7 +1462,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { } } - List worklist = new List(); + List worklist = []; worklist.addAll(entries); for (LibraryBuilder libraryBuilder in reusedLibraries) { if (libraryBuilder.importUri.scheme == "dart" && @@ -1499,7 +1499,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { } } - List removedLibraries = new List(); + List removedLibraries = []; bool removedDillBuilders = false; for (Uri uri in potentiallyReferencedLibraries.keys) { if (uri.scheme == "package") continue; @@ -1690,7 +1690,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { if (message.uri != null) { List messages = remainingComponentProblems[message.uri] ??= - new List(); + []; messages.add(message); } if (message.involvedFiles != null) { @@ -1701,7 +1701,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { for (Uri uri in message.involvedFiles) { List messages = remainingComponentProblems[uri] ??= - new List(); + []; messages.add(message); } } @@ -1915,7 +1915,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { return new ReusageResult({}, [], false, reusedLibraries); } bool invalidatedBecauseOfPackageUpdate = false; - List directlyInvalidated = new List(); + List directlyInvalidated = []; Set notReusedLibraries = new Set(); // Maps all non-platform LibraryBuilders from their import URI. diff --git a/pkg/front_end/lib/src/fasta/incremental_serializer.dart b/pkg/front_end/lib/src/fasta/incremental_serializer.dart index e22b91204e1..4581f1645bf 100644 --- a/pkg/front_end/lib/src/fasta/incremental_serializer.dart +++ b/pkg/front_end/lib/src/fasta/incremental_serializer.dart @@ -62,7 +62,7 @@ class IncrementalSerializer { // Add groups. Wrap in try because an exception will be thrown if a group // has a dependency that isn't being met. try { - List newGroups = new List(); + List newGroups = []; for (int i = 0; i < goodViews.length; i++) { SubComponentView view = goodViews[i]; List data = new Uint8List(view.componentFileSize); @@ -113,8 +113,8 @@ class IncrementalSerializer { component.computeCanonicalNames(); // Split into package and non-package libraries. - List packageLibraries = new List(); - List nonPackageLibraries = new List(); + List packageLibraries = []; + List nonPackageLibraries = []; for (Library lib in component.libraries) { Uri uri = lib.importUri; if (uri.scheme == "package") { @@ -196,7 +196,7 @@ class IncrementalSerializer { void removeInvalidated() { // Remove all directly invalidated entries. Set removed = new Set(); - List workList = new List(); + List workList = []; for (Uri uri in invalidatedUris) { removeUriFromMap(uri, removed, workList); } diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart index 2efd369fe05..8971d25918f 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -1389,8 +1389,8 @@ class BodyBuilder extends ScopeListener List formals = parameters.positionalParameters.length == 0 ? null - : new List( - parameters.positionalParameters.length); + : new List.filled( + parameters.positionalParameters.length, null); for (int i = 0; i < parameters.positionalParameters.length; i++) { VariableDeclaration formal = parameters.positionalParameters[i]; formals[i] = new FormalParameterBuilder( @@ -3133,7 +3133,8 @@ class BodyBuilder extends ScopeListener if (isSet) { buildLiteralSet(typeArguments, constKeyword, leftBrace, setOrMapEntries); } else { - List mapEntries = new List(setOrMapEntries.length); + List mapEntries = + new List.filled(setOrMapEntries.length, null); for (int i = 0; i < setOrMapEntries.length; ++i) { if (setOrMapEntries[i] is MapEntry) { mapEntries[i] = setOrMapEntries[i]; @@ -5456,7 +5457,8 @@ class BodyBuilder extends ScopeListener int count = labelCount + expressionCount; List labelsAndExpressions = const FixedNullableList().pop(stack, count); - List