From f0ed48196e045f3acbc6e82247eae6b52db11993 Mon Sep 17 00:00:00 2001 From: Lasse Reichstein Holst Nielsen Date: Mon, 7 Dec 2020 22:10:18 +0000 Subject: [PATCH] Undo conversion from List() to [] and List(n) to List.filled(n, null) in comments. Change-Id: I80b5e335f63e14a80db697e2ac3cbcf4c8d51d6b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175253 Commit-Queue: Lasse R.H. Nielsen Reviewed-by: Stephen Adams --- pkg/compiler/lib/src/inferrer/builder_kernel.dart | 6 +++--- pkg/compiler/lib/src/js_backend/runtime_types.dart | 4 ++-- pkg/compiler/lib/src/ssa/builder_kernel.dart | 10 +++++----- pkg/dev_compiler/doc/GENERIC_METHOD_COMMENTS.md | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/compiler/lib/src/inferrer/builder_kernel.dart b/pkg/compiler/lib/src/inferrer/builder_kernel.dart index fdfd67ec534..55d7ab6d24b 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.filled(..., null)`. + // We have `new List(...)`. if (arguments.positional.isEmpty && arguments.named.isEmpty) { - // We have `[]`. + // We have `new List()`. return _inferrer.concreteTypes.putIfAbsent( node, () => _types.allocateList(_types.growableListType, node, _analyzedMember, _types.nonNullEmpty(), 0)); } else { - // We have `new List.filled(len, null)`. + // We have `new List(len)`. int length = _findLength(arguments); return _inferrer.concreteTypes.putIfAbsent( node, diff --git a/pkg/compiler/lib/src/js_backend/runtime_types.dart b/pkg/compiler/lib/src/js_backend/runtime_types.dart index 29980124e52..c8084d5bc62 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() => [] is List; + /// main() => new List() is List; /// bool typeArgument = false; @@ -1003,7 +1003,7 @@ class ClassUse { /// For instance `A` in: /// /// class A {} - /// main() => [] is List; + /// main() => new List() is List; /// bool checkedTypeArgument = false; diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart index e81ca798663..7c66c12b2e0 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 `[]` and `List.filled(n, null)`. + // Recognize `List()` and `List(n)`. if (_commonElements.isUnnamedListConstructor(function)) { if (invocation.arguments.named.isEmpty) { int argumentCount = invocation.arguments.positional.length; if (argumentCount == 0) { - // `[]` takes no arguments, `JSArray.list()` takes a sentinel. + // `List()` 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 `[]` constructor. + /// Handle the legacy `List()` constructor. void _handleInvokeLegacyGrowableListFactoryConstructor( ir.StaticInvocation invocation, ConstructorEntity function, AbstractValue typeMask, List arguments, SourceInformation sourceInformation) { - // `[]` is essentially the same as `[]`. + // `List()` 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.filled(length, null)` + /// Handle the `JSArray.list(length)` and legacy `List(length)` /// constructors. void _handleInvokeLegacyFixedListFactoryConstructor( ir.StaticInvocation invocation, diff --git a/pkg/dev_compiler/doc/GENERIC_METHOD_COMMENTS.md b/pkg/dev_compiler/doc/GENERIC_METHOD_COMMENTS.md index 8f236577d2e..9050eab7fe7 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 []; + return new List(); } void main() { @@ -174,7 +174,7 @@ List foo/**/(/*=S*/ x) { var l0 = [x]; // as above, but with a regular constructor. - var l1 = []; + var l1 = new List(); return l1; } ```