mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:30:32 +00:00
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 <lrn@google.com> Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
parent
9b128c5173
commit
f0ed48196e
|
@ -1243,15 +1243,15 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation> {
|
|||
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,
|
||||
|
|
|
@ -994,7 +994,7 @@ class ClassUse {
|
|||
/// For instance `A` in:
|
||||
///
|
||||
/// class A {}
|
||||
/// main() => <A>[] is List<String>;
|
||||
/// main() => new List<A>() is List<String>;
|
||||
///
|
||||
bool typeArgument = false;
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ class ClassUse {
|
|||
/// For instance `A` in:
|
||||
///
|
||||
/// class A {}
|
||||
/// main() => <String>[] is List<A>;
|
||||
/// main() => new List<String>() is List<A>;
|
||||
///
|
||||
bool checkedTypeArgument = false;
|
||||
|
||||
|
|
|
@ -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 `<T>[]` constructor.
|
||||
/// Handle the legacy `List<T>()` constructor.
|
||||
void _handleInvokeLegacyGrowableListFactoryConstructor(
|
||||
ir.StaticInvocation invocation,
|
||||
ConstructorEntity function,
|
||||
AbstractValue typeMask,
|
||||
List<HInstruction> arguments,
|
||||
SourceInformation sourceInformation) {
|
||||
// `<T>[]` is essentially the same as `<T>[]`.
|
||||
// `List<T>()` is essentially the same as `<T>[]`.
|
||||
push(_buildLiteralList(<HInstruction>[]));
|
||||
HInstruction allocation = pop();
|
||||
var inferredType = globalInferenceResults.typeOfNewList(invocation);
|
||||
|
@ -3956,7 +3956,7 @@ class KernelSsaGraphBuilder extends ir.Visitor {
|
|||
_setListRuntimeTypeInfoIfNeeded(allocation, type, sourceInformation));
|
||||
}
|
||||
|
||||
/// Handle the `JSArray<T>.list(length)` and legacy `List<T>.filled(length, null)`
|
||||
/// Handle the `JSArray<T>.list(length)` and legacy `List<T>(length)`
|
||||
/// constructors.
|
||||
void _handleInvokeLegacyFixedListFactoryConstructor(
|
||||
ir.StaticInvocation invocation,
|
||||
|
|
|
@ -139,7 +139,7 @@ original type is used at runtime, it may cause checked mode errors:
|
|||
|
||||
```dart
|
||||
List/*<T>*/ makeList/*<T extends num>*/() {
|
||||
return <num /*=T*/>[];
|
||||
return new List<num /*=T*/>();
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
@ -174,7 +174,7 @@ List<dynamic /*=S*/> foo/*<S>*/(/*=S*/ x) {
|
|||
var l0 = <dynamic /*=S*/>[x];
|
||||
|
||||
// as above, but with a regular constructor.
|
||||
var l1 = <dynamic /*=S*/>[];
|
||||
var l1 = new List<dynamic /*=S*/>();
|
||||
return l1;
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue