Remove left-over patch declarations for List constructor.
This CL replaces https://dart-review.googlesource.com/c/sdk/+/296900 The `List` constructor is removed in Dart 3.0. Some of the `@patch` implementations were not removed. This is *high priority*. It seems the left-over `@patch factory List` constructor did not cause any errors, instead it *added* a constructor to `List` that can be used in web compiled code. Even if `List` doesn't have such a constructor in the SDK code proper. The VM and analyzer will say the invocation is an error, but dart2js happily compiles it and runs. (It used to be that patches couldn't add public members, that security seems to have been removed.) Also removes code which tries to detect "the unnamed List constructor", which is no longer a thing, and a number of invocations of the constructor, where it's not clear that the test is aware that the constructor no longer exists, and is not marked as `@dart=2.x` with x < 12. TEST=ci Change-Id: I4ffaf3ae2c4e75ca06e7ba0bf19187b6376f3888 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297100 Reviewed-by: Brian Quinlan <bquinlan@google.com> Reviewed-by: Nate Bosch <nbosch@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
committed by
Commit Queue
parent
69f71e90ea
commit
45efccb5e0
@@ -1107,14 +1107,6 @@ class KCommonElements extends CommonElements {
|
||||
class JCommonElements extends CommonElements {
|
||||
JCommonElements(super.dartTypes, super.env);
|
||||
|
||||
/// Returns `true` if [element] is the unnamed constructor of `List`.
|
||||
///
|
||||
/// This will not resolve the constructor if it hasn't been seen yet during
|
||||
/// compilation.
|
||||
bool isUnnamedListConstructor(ConstructorEntity element) =>
|
||||
(element.name == '' && element.enclosingClass == listClass) ||
|
||||
(element.name == 'list' && element.enclosingClass == jsArrayClass);
|
||||
|
||||
/// Returns `true` if [element] is the named constructor of `List`,
|
||||
/// e.g. `List.of`.
|
||||
///
|
||||
|
||||
@@ -1385,24 +1385,6 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation?>
|
||||
|
||||
var commonElements = _elementMap.commonElements;
|
||||
|
||||
if (commonElements.isUnnamedListConstructor(constructor)) {
|
||||
// We have `new List(...)`.
|
||||
if (arguments.positional.isEmpty && arguments.named.isEmpty) {
|
||||
// We have `new List()`.
|
||||
return _inferrer.concreteTypes.putIfAbsent(
|
||||
node,
|
||||
() => _types.allocateList(_types.growableListType, node,
|
||||
_analyzedMember, _types.nonNullEmpty(), 0));
|
||||
} else {
|
||||
// We have `new List(len)`.
|
||||
final length = _findLength(arguments);
|
||||
return _inferrer.concreteTypes.putIfAbsent(
|
||||
node,
|
||||
() => _types.allocateList(_types.fixedListType, node,
|
||||
_analyzedMember, _types.nullType, length));
|
||||
}
|
||||
}
|
||||
|
||||
if (commonElements.isNamedListConstructor('filled', constructor)) {
|
||||
// We have something like `List.filled(len, fill)`.
|
||||
final length = _findLength(arguments);
|
||||
|
||||
@@ -1385,24 +1385,6 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation?>
|
||||
|
||||
var commonElements = _elementMap.commonElements;
|
||||
|
||||
if (commonElements.isUnnamedListConstructor(constructor)) {
|
||||
// We have `new List(...)`.
|
||||
if (arguments.positional.isEmpty && arguments.named.isEmpty) {
|
||||
// We have `new List()`.
|
||||
return _inferrer.concreteTypes.putIfAbsent(
|
||||
node,
|
||||
() => _types.allocateList(_types.growableListType, node,
|
||||
_analyzedMember, _types.nonNullEmpty(), 0));
|
||||
} else {
|
||||
// We have `new List(len)`.
|
||||
final length = _findLength(arguments);
|
||||
return _inferrer.concreteTypes.putIfAbsent(
|
||||
node,
|
||||
() => _types.allocateList(_types.fixedListType, node,
|
||||
_analyzedMember, _types.nullType, length));
|
||||
}
|
||||
}
|
||||
|
||||
if (commonElements.isNamedListConstructor('filled', constructor)) {
|
||||
// We have something like `List.filled(len, fill)`.
|
||||
final length = _findLength(arguments);
|
||||
|
||||
@@ -4256,27 +4256,6 @@ class KernelSsaGraphBuilder extends ir.Visitor<void> with ir.VisitorVoidMixin {
|
||||
AbstractValue typeMask,
|
||||
List<HInstruction> arguments,
|
||||
SourceInformation? sourceInformation) {
|
||||
// Recognize `List()` and `List(n)`.
|
||||
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.
|
||||
assert(arguments.length == 0 || arguments.length == 1,
|
||||
'\narguments: $arguments\n');
|
||||
_handleInvokeLegacyGrowableListFactoryConstructor(
|
||||
invocation, function, typeMask, arguments, sourceInformation);
|
||||
return;
|
||||
}
|
||||
if (argumentCount == 1) {
|
||||
assert(arguments.length == 1);
|
||||
_handleInvokeLegacyFixedListFactoryConstructor(
|
||||
invocation, function, typeMask, arguments, sourceInformation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recognize `JSArray<E>.typed(allocation)`.
|
||||
if (function == _commonElements.jsArrayTypedConstructor) {
|
||||
if (invocation.arguments.named.isEmpty) {
|
||||
@@ -4400,98 +4379,6 @@ class KernelSsaGraphBuilder extends ir.Visitor<void> with ir.VisitorVoidMixin {
|
||||
stack.add(_setListRuntimeTypeInfoIfNeeded(pop(), type, sourceInformation));
|
||||
}
|
||||
|
||||
/// Handle the legacy `List<T>()` constructor.
|
||||
void _handleInvokeLegacyGrowableListFactoryConstructor(
|
||||
ir.StaticInvocation invocation,
|
||||
ConstructorEntity function,
|
||||
AbstractValue typeMask,
|
||||
List<HInstruction> arguments,
|
||||
SourceInformation? sourceInformation) {
|
||||
// `List<T>()` is essentially the same as `<T>[]`.
|
||||
push(_buildLiteralList([]));
|
||||
HInstruction allocation = pop();
|
||||
var inferredType = globalInferenceResults.typeOfNewList(invocation);
|
||||
if (inferredType != null) {
|
||||
allocation.instructionType = inferredType;
|
||||
}
|
||||
InterfaceType type = _elementMap.createInterfaceType(
|
||||
invocation.target.enclosingClass!, invocation.arguments.types);
|
||||
stack.add(
|
||||
_setListRuntimeTypeInfoIfNeeded(allocation, type, sourceInformation));
|
||||
}
|
||||
|
||||
/// Handle the `JSArray<T>.list(length)` and legacy `List<T>(length)`
|
||||
/// constructors.
|
||||
void _handleInvokeLegacyFixedListFactoryConstructor(
|
||||
ir.StaticInvocation invocation,
|
||||
ConstructorEntity function,
|
||||
AbstractValue typeMask,
|
||||
List<HInstruction> arguments,
|
||||
SourceInformation? sourceInformation) {
|
||||
assert(
|
||||
// Arguments may include the type.
|
||||
arguments.length == 1 || arguments.length == 2,
|
||||
failedAt(
|
||||
function,
|
||||
"Unexpected arguments. "
|
||||
"Expected 1-2 argument, actual: $arguments."));
|
||||
HInstruction lengthInput = arguments.first;
|
||||
if (lengthInput.isNumber(_abstractValueDomain).isPotentiallyFalse) {
|
||||
HPrimitiveCheck conversion = HPrimitiveCheck(
|
||||
_commonElements.numType,
|
||||
HPrimitiveCheck.ARGUMENT_TYPE_CHECK,
|
||||
_abstractValueDomain.numType,
|
||||
lengthInput,
|
||||
sourceInformation);
|
||||
add(conversion);
|
||||
lengthInput = conversion;
|
||||
}
|
||||
js.Template code = js.js.parseForeignJS('new Array(#)');
|
||||
var behavior = NativeBehavior();
|
||||
|
||||
DartType expectedType = _getStaticType(invocation).type;
|
||||
behavior.typesInstantiated.add(expectedType);
|
||||
behavior.typesReturned.add(expectedType);
|
||||
|
||||
// The allocation can throw only if the given length is a double or
|
||||
// outside the unsigned 32 bit range.
|
||||
// TODO(sra): Array allocation should be an instruction so that canThrow
|
||||
// can depend on a length type discovered in optimization.
|
||||
bool canThrow = true;
|
||||
if (lengthInput.isUInt32(_abstractValueDomain).isDefinitelyTrue) {
|
||||
canThrow = false;
|
||||
}
|
||||
|
||||
var resultType = globalInferenceResults.typeOfNewList(invocation) ??
|
||||
_abstractValueDomain.fixedListType;
|
||||
|
||||
HForeignCode foreign = HForeignCode(code, resultType, [lengthInput],
|
||||
nativeBehavior: behavior,
|
||||
throwBehavior:
|
||||
canThrow ? NativeThrowBehavior.MAY : NativeThrowBehavior.NEVER)
|
||||
..sourceInformation = sourceInformation;
|
||||
push(foreign);
|
||||
js.Template fixedLengthMarker =
|
||||
js.js.parseForeignJS(r'#.fixed$length = Array');
|
||||
// We set the instruction as [canThrow] to avoid it being dead code.
|
||||
// We need a finer grained side effect.
|
||||
add(HForeignCode(
|
||||
fixedLengthMarker, _abstractValueDomain.nullType, [stack.last],
|
||||
throwBehavior: NativeThrowBehavior.MAY));
|
||||
|
||||
HInstruction newInstance = stack.last;
|
||||
|
||||
// If we inlined a constructor the call-site-specific type from type
|
||||
// inference (e.g. a container type) will not be on the node. Store the
|
||||
// more specialized type on the allocation.
|
||||
newInstance.instructionType = resultType;
|
||||
graph.allocatedFixedLists.add(newInstance);
|
||||
|
||||
InterfaceType type = _elementMap.createInterfaceType(
|
||||
invocation.target.enclosingClass!, invocation.arguments.types);
|
||||
stack.add(_setListRuntimeTypeInfoIfNeeded(pop(), type, sourceInformation));
|
||||
}
|
||||
|
||||
/// Replace calls to `extractTypeArguments` with equivalent code. Returns
|
||||
/// `true` if `extractTypeArguments` is handled.
|
||||
bool _handleExtractTypeArguments(
|
||||
|
||||
@@ -20,7 +20,7 @@ foo() {
|
||||
|
||||
const String TEST_THREE = r"""
|
||||
foo() {
|
||||
return List().add(2);
|
||||
return [].add(2);
|
||||
}
|
||||
""";
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ void foo(bar) {
|
||||
// GVN'ing the length of [:list:].
|
||||
const String TEST_TWO = r"""
|
||||
void foo(a) {
|
||||
var list = List<int>();
|
||||
var list = <int>[];
|
||||
list[0] = list[0 % a];
|
||||
list[1] = list[1 % a];
|
||||
}
|
||||
|
||||
@@ -26,14 +26,14 @@ main() {
|
||||
}
|
||||
|
||||
const String TEST3 = r"""
|
||||
var a = List(42);
|
||||
var a = List.filled(42, null);
|
||||
main() {
|
||||
return a[0];
|
||||
}
|
||||
""";
|
||||
|
||||
const String TEST4 = r"""
|
||||
var a = List(0);
|
||||
var a = List.filled(0, null);
|
||||
main() {
|
||||
return a[0];
|
||||
}
|
||||
@@ -75,7 +75,7 @@ main() {
|
||||
|
||||
const String TEST8 = r"""
|
||||
var b = int.parse('42');
|
||||
var a = List(b);
|
||||
var a = List.filled(b, null);
|
||||
main() {
|
||||
return a[1];
|
||||
}
|
||||
@@ -83,7 +83,7 @@ main() {
|
||||
|
||||
const String TEST9 = r"""
|
||||
const b = 42;
|
||||
var a = List(b);
|
||||
var a = List.filled(b, null);
|
||||
main() {
|
||||
return a[1];
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ main() {
|
||||
|
||||
const String TEST2 = r"""
|
||||
main() {
|
||||
var a = List();
|
||||
var a = [];
|
||||
a.add(42);
|
||||
a.add(null);
|
||||
return a[0] + 42;
|
||||
@@ -24,7 +24,7 @@ main() {
|
||||
|
||||
const String TEST3 = r"""
|
||||
main() {
|
||||
var a = List(42);
|
||||
var a = List<dynamic>.filled(42, null);
|
||||
a[a.length - 1] = 42;
|
||||
return a[0] + 42;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ var a = [42];
|
||||
main() {
|
||||
var value = a[0];
|
||||
if (value < 42) {
|
||||
return List(42)[value];
|
||||
return List.filled(42, null)[value];
|
||||
}
|
||||
}
|
||||
''',
|
||||
|
||||
@@ -18,7 +18,7 @@ const int BELOW_ZERO_CHECK = 6;
|
||||
final List TESTS = [
|
||||
"""
|
||||
main() {
|
||||
var a = List();
|
||||
var a = [];
|
||||
var sum = 0;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
sum += a[i];
|
||||
@@ -29,7 +29,7 @@ main() {
|
||||
REMOVED,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List();
|
||||
var a = [];
|
||||
var sum = 0;
|
||||
for (int i = 0; i < value; i++) {
|
||||
sum += a[i];
|
||||
@@ -42,7 +42,7 @@ main(value) {
|
||||
main(check) {
|
||||
// Make sure value is an int.
|
||||
var value = check ? 42 : 54;
|
||||
var a = List(value);
|
||||
var a = List.filled(value, null);
|
||||
var sum = 0;
|
||||
for (int i = 0; i < value; i++) {
|
||||
sum += a[i];
|
||||
@@ -53,77 +53,77 @@ main(check) {
|
||||
REMOVED,
|
||||
"""
|
||||
main() {
|
||||
var a = List();
|
||||
var a = [];
|
||||
return a[0];
|
||||
}
|
||||
""",
|
||||
KEPT,
|
||||
"""
|
||||
main() {
|
||||
var a = List();
|
||||
var a = [];
|
||||
return a.removeLast();
|
||||
}
|
||||
""",
|
||||
KEPT,
|
||||
"""
|
||||
main() {
|
||||
var a = List(4);
|
||||
var a = List.filled(4, null);
|
||||
return a[0];
|
||||
}
|
||||
""",
|
||||
REMOVED,
|
||||
"""
|
||||
main() {
|
||||
var a = List(4);
|
||||
var a = List.filled(4, null);
|
||||
return a.removeLast();
|
||||
}
|
||||
""",
|
||||
REMOVED,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List(value);
|
||||
var a = List.filled(value, null);
|
||||
return a[value];
|
||||
}
|
||||
""",
|
||||
KEPT,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List(1024);
|
||||
var a = List.filled(1024, null);
|
||||
return a[1023 & value];
|
||||
}
|
||||
""",
|
||||
REMOVED,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List(1024);
|
||||
var a = List.filled(1024, null);
|
||||
return a[1024 & value];
|
||||
}
|
||||
""",
|
||||
ABOVE_ZERO,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List();
|
||||
var a = [];
|
||||
return a[1];
|
||||
}
|
||||
""",
|
||||
ABOVE_ZERO,
|
||||
"""
|
||||
main(value, call) {
|
||||
var a = List();
|
||||
var a = [];
|
||||
return a[value] + call() + a[value];
|
||||
}
|
||||
""",
|
||||
ONE_ZERO_CHECK,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List();
|
||||
var a = [];
|
||||
return a[1] + a[0];
|
||||
}
|
||||
""",
|
||||
ONE_CHECK,
|
||||
"""
|
||||
main() {
|
||||
var a = List();
|
||||
var a = [];
|
||||
var sum = 0;
|
||||
for (int i = 0; i <= a.length - 1; i++) {
|
||||
sum += a[i];
|
||||
@@ -134,7 +134,7 @@ main() {
|
||||
REMOVED,
|
||||
"""
|
||||
main() {
|
||||
var a = List();
|
||||
var a = [];
|
||||
var sum = 0;
|
||||
for (int i = a.length - 1; i >=0; i--) {
|
||||
sum += a[i];
|
||||
@@ -148,7 +148,7 @@ main(value) {
|
||||
value = value is int ? value as int : 42;
|
||||
int sum = ~value;
|
||||
for (int i = 0; i < 42; i++) sum += (value & 4);
|
||||
var a = List();
|
||||
var a = [];
|
||||
if (value > a.length - 1) return;
|
||||
if (value < 0) return;
|
||||
return a[value];
|
||||
@@ -160,7 +160,7 @@ main(value) {
|
||||
value = value is int ? value as int : 42;
|
||||
int sum = ~value;
|
||||
for (int i = 0; i < 42; i++) sum += (value & 4);
|
||||
var a = List();
|
||||
var a = [];
|
||||
if (value <= a.length - 1) {
|
||||
if (value >= 0) {
|
||||
return a[value];
|
||||
@@ -174,7 +174,7 @@ main(value) {
|
||||
value = value is int ? value as int : 42;
|
||||
int sum = ~value;
|
||||
for (int i = 0; i < 42; i++) sum += (value & 4);
|
||||
var a = List();
|
||||
var a = [];
|
||||
if (value >= a.length) return;
|
||||
if (value <= -1) return;
|
||||
return a[value];
|
||||
@@ -183,7 +183,7 @@ main(value) {
|
||||
REMOVED,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List(4);
|
||||
var a = List.filled(4, null);
|
||||
var sum = 0;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
sum += a[i];
|
||||
@@ -195,7 +195,7 @@ main(value) {
|
||||
REMOVED,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List(5);
|
||||
var a = List.filled(5, null);
|
||||
var sum = 0;
|
||||
for (int i = a.length - 1; i >= 0; i--) {
|
||||
sum += a[i];
|
||||
@@ -207,7 +207,7 @@ main(value) {
|
||||
REMOVED,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List(6);
|
||||
var a = List.filled(6, null);
|
||||
var sum = 0;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
sum += a[i];
|
||||
@@ -219,7 +219,7 @@ main(value) {
|
||||
BELOW_ZERO_CHECK,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List(7);
|
||||
var a = List.filled(7, null);
|
||||
var sum = 0;
|
||||
for (int i = 0; i < a.length;) {
|
||||
sum += a[i];
|
||||
@@ -231,7 +231,7 @@ main(value) {
|
||||
BELOW_ZERO_CHECK,
|
||||
"""
|
||||
main(value) {
|
||||
var a = List(7);
|
||||
var a = List.filled(7, null);
|
||||
var sum = 0;
|
||||
for (int i = -2; i < a.length; i = 0) {
|
||||
sum += a[i];
|
||||
|
||||
@@ -139,9 +139,9 @@ class A6 {
|
||||
/*update: [exact=A6]*/ f6b = "2";
|
||||
}
|
||||
if (x) {
|
||||
/*update: [exact=A6]*/ f6b = List();
|
||||
/*update: [exact=A6]*/ f6b = [];
|
||||
} else {
|
||||
/*update: [exact=A6]*/ f6b = List();
|
||||
/*update: [exact=A6]*/ f6b = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,10 +168,10 @@ class A7 {
|
||||
/*update: [exact=A7]*/ f7b = "2";
|
||||
}
|
||||
if (x) {
|
||||
/*update: [exact=A7]*/ f7a = List();
|
||||
/*update: [exact=A7]*/ f7b = List();
|
||||
/*update: [exact=A7]*/ f7a = [];
|
||||
/*update: [exact=A7]*/ f7b = [];
|
||||
} else {
|
||||
/*update: [exact=A7]*/ f7b = List();
|
||||
/*update: [exact=A7]*/ f7b = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,7 @@ class A15 {
|
||||
|
||||
/*member: A15.other:[exact=A15]*/
|
||||
A15.other() {
|
||||
/*update: [exact=A15]*/ f15 = List();
|
||||
/*update: [exact=A15]*/ f15 = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,8 @@ main() {
|
||||
constList();
|
||||
constNullList();
|
||||
intList();
|
||||
newList();
|
||||
newFixedList();
|
||||
newFilledList();
|
||||
newFilledGrowableList();
|
||||
newFloat32x4List();
|
||||
newInt32x4List();
|
||||
newFloat64x2List();
|
||||
@@ -46,15 +45,12 @@ constNullList() => const [null];
|
||||
/*member: intList:Container([exact=JSExtendableArray], element: [exact=JSUInt31], length: 3)*/
|
||||
intList() => [1, 2, 3];
|
||||
|
||||
/*member: newList:Container([exact=JSExtendableArray], element: [empty], length: 0)*/
|
||||
newList() => List();
|
||||
|
||||
/*member: newFixedList:Container([exact=JSFixedArray], element: [null], length: 2)*/
|
||||
newFixedList() => List(2);
|
||||
|
||||
/*member: newFilledList:Container([exact=JSFixedArray], element: Value([exact=JSString], value: ""), length: 3)*/
|
||||
newFilledList() => List.filled(3, '');
|
||||
|
||||
/*member: newFilledGrowableList:Container([exact=JSExtendableArray], element: Value([exact=JSString], value: ""), length: 3)*/
|
||||
newFilledGrowableList() => List.filled(3, '', growable: true);
|
||||
|
||||
/*member: newFloat32x4List:[exact=NativeFloat32x4List]*/
|
||||
newFloat32x4List() => Float32x4List(4);
|
||||
|
||||
|
||||
@@ -14,11 +14,14 @@ main() {
|
||||
hugeList4();
|
||||
}
|
||||
|
||||
/*member: thing:[null]*/
|
||||
dynamic thing;
|
||||
|
||||
/*member: _huge1:[subclass=JSPositiveInt]*/
|
||||
final _huge1 = 5000000000;
|
||||
|
||||
/*member: hugeList1:Container([exact=JSFixedArray], element: [null], length: null)*/
|
||||
hugeList1() => List(_huge1);
|
||||
hugeList1() => List.filled(_huge1, thing);
|
||||
|
||||
const _huge2a = 10000000000 * 10000000000;
|
||||
|
||||
@@ -26,7 +29,7 @@ const _huge2a = 10000000000 * 10000000000;
|
||||
final _huge2b = _huge2a;
|
||||
|
||||
/*member: hugeList2:Container([exact=JSFixedArray], element: [null], length: null)*/
|
||||
hugeList2() => List(_huge2b);
|
||||
hugeList2() => List.filled(_huge2b, thing);
|
||||
|
||||
const _huge3a = -10000000;
|
||||
|
||||
@@ -34,7 +37,7 @@ const _huge3a = -10000000;
|
||||
final _huge3b = _huge3a;
|
||||
|
||||
/*member: hugeList3:Container([exact=JSFixedArray], element: [null], length: null)*/
|
||||
hugeList3() => List(_huge3b);
|
||||
hugeList3() => List.filled(_huge3b, thing);
|
||||
|
||||
// 'Small' limits are still tracked.
|
||||
|
||||
@@ -42,4 +45,4 @@ hugeList3() => List(_huge3b);
|
||||
final _huge4 = 10000000;
|
||||
|
||||
/*member: hugeList4:Container([exact=JSFixedArray], element: [null], length: 10000000)*/
|
||||
hugeList4() => List(_huge4);
|
||||
hugeList4() => List.filled(_huge4, thing);
|
||||
|
||||
@@ -13,7 +13,7 @@ var myList = [42];
|
||||
/*member: main:[exact=JSUInt31]*/
|
||||
main() {
|
||||
/// ignore: unused_local_variable
|
||||
var a = List(42);
|
||||
var a = List.filled(42, null);
|
||||
return myList
|
||||
/*Container([exact=JSExtendableArray], element: [exact=JSUInt31], length: 1)*/
|
||||
[0];
|
||||
|
||||
@@ -208,9 +208,7 @@ void main() {
|
||||
// Test literal list.
|
||||
await doTest('<dynamic>[]', nullify: false);
|
||||
// Test growable list.
|
||||
await doTest('new List<dynamic>()', nullify: false);
|
||||
// Test fixed list.
|
||||
await doTest('new List<dynamic>(1)', nullify: true);
|
||||
await doTest('new List<dynamic>.empty()', nullify: false);
|
||||
// Test List.filled.
|
||||
await doTest('new List<dynamic>.filled(1, 0)', nullify: false);
|
||||
// Test List.filled.
|
||||
|
||||
@@ -27,6 +27,6 @@ class C1 implements C {}
|
||||
class C2 implements C {}
|
||||
|
||||
main() {
|
||||
makeLive(new B<List<A<C>>>().method(new List<A1>()));
|
||||
makeLive(new B<List<A<C2>>>().method(new List<A1>()));
|
||||
makeLive(new B<List<A<C>>>().method(<A1>[]));
|
||||
makeLive(new B<List<A<C2>>>().method(<A1>[]));
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class Check2<T> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
var things = List(3);
|
||||
var things = List<dynamic>.filled(3, null);
|
||||
things.setRange(0, 3, [Instantiated(), 1, Object()]);
|
||||
|
||||
var checkX = Check<Instantiated>();
|
||||
|
||||
@@ -3055,7 +3055,6 @@ class Iterable<E> {
|
||||
}
|
||||
|
||||
class List<E> extends Iterable<E> {
|
||||
factory List() => null;
|
||||
factory List.unmodifiable(elements) => null;
|
||||
factory List.empty({bool growable = false}) => null;
|
||||
factory List.filled(int length, E fill, {bool growable = false}) => null;
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:vm/transformations/specializer/factory_specializer.dart';
|
||||
/// Replaces invocation of List factory constructors with
|
||||
/// factories of VM-specific classes.
|
||||
///
|
||||
/// new List() => new _GrowableList(0)
|
||||
/// new List.empty() => new _List.empty()
|
||||
/// new List.empty(growable: false) => new _List.empty()
|
||||
/// new List.empty(growable: true) => new _GrowableList.empty()
|
||||
|
||||
@@ -98,10 +98,9 @@ class Candidate<T> {
|
||||
}
|
||||
}
|
||||
|
||||
List<Candidate<ObjectMirror>> candidateReceivers =
|
||||
new List<Candidate<ObjectMirror>>();
|
||||
List<Candidate<ObjectMirror>> candidateReceivers = <Candidate<ObjectMirror>>[];
|
||||
List<Candidate<InstanceMirror>> candidateArguments =
|
||||
new List<Candidate<InstanceMirror>>();
|
||||
<Candidate<InstanceMirror>>[];
|
||||
|
||||
void addInstance(var instance) {
|
||||
addInstanceMirror(reflect(instance));
|
||||
@@ -345,7 +344,7 @@ void garbageCollect() {
|
||||
// page in old space.
|
||||
var n;
|
||||
for (int i = 0; i < 2048; i++) {
|
||||
var m = new List(512);
|
||||
var m = new List.filled(512, null);
|
||||
m[0] = n;
|
||||
n = m;
|
||||
}
|
||||
|
||||
@@ -512,23 +512,6 @@ class Stopwatch {
|
||||
// Patch for List implementation.
|
||||
@patch
|
||||
class List<E> {
|
||||
@patch
|
||||
factory List([@undefined int? length]) {
|
||||
dynamic list;
|
||||
if (JS<bool>('!', '# === void 0', length)) {
|
||||
list = JS('', '[]');
|
||||
} else {
|
||||
int _length = JS('!', '#', length);
|
||||
if (length == null || _length < 0) {
|
||||
throw ArgumentError("Length must be a non-negative integer: $_length");
|
||||
}
|
||||
list = JS('', 'new Array(#)', _length);
|
||||
JS('', '#.fill(null)', list);
|
||||
JSArray.markFixedList(list);
|
||||
}
|
||||
return JSArray<E>.of(list);
|
||||
}
|
||||
|
||||
@patch
|
||||
factory List.empty({bool growable = false}) {
|
||||
var list = JSArray<E>.of(JS('', 'new Array()'));
|
||||
|
||||
@@ -421,9 +421,6 @@ class Stopwatch {
|
||||
// Patch for List implementation.
|
||||
@patch
|
||||
class List<E> {
|
||||
@patch
|
||||
factory List([int? length]) = JSArray<E>.list;
|
||||
|
||||
@patch
|
||||
factory List.filled(int length, E fill, {bool growable = false}) {
|
||||
var result = growable
|
||||
|
||||
@@ -17,15 +17,6 @@ const _ListConstructorSentinel = const _Growable();
|
||||
class JSArray<E> extends JavaScriptObject implements List<E>, JSIndexable<E> {
|
||||
const JSArray();
|
||||
|
||||
// This factory constructor is the redirection target of the List() factory
|
||||
// constructor. [length] has no type to permit the sentinel value.
|
||||
factory JSArray.list([length = _ListConstructorSentinel]) {
|
||||
if (_ListConstructorSentinel == length) {
|
||||
return new JSArray<E>.emptyGrowable();
|
||||
}
|
||||
return new JSArray<E>.fixed(length);
|
||||
}
|
||||
|
||||
/// Returns a fresh JavaScript Array, marked as fixed-length. The holes in the
|
||||
/// array yield `undefined`, making the Dart List appear to be filled with
|
||||
/// `null` values.
|
||||
|
||||
@@ -14,5 +14,5 @@ class B
|
||||
|
||||
main() {
|
||||
new C(); // //# 01: continued
|
||||
new List<C>(); // //# 02: continued
|
||||
new List<C>.empty(); // //# 02: continued
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ class B
|
||||
|
||||
main() {
|
||||
new C(); // //# 01: continued
|
||||
new List<C>(); // //# 02: continued
|
||||
new List<C>.empty(); // //# 02: continued
|
||||
}
|
||||
|
||||
@@ -22,6 +22,6 @@ class C1 implements C {}
|
||||
class C2 implements C {}
|
||||
|
||||
main() {
|
||||
Expect.isTrue(new B<List<A<C>>>().method(new List<A1>()));
|
||||
Expect.isFalse(new B<List<A<C2>>>().method(new List<A1>()));
|
||||
Expect.isTrue(new B<List<A<C>>>().method(<A1>[]));
|
||||
Expect.isFalse(new B<List<A<C2>>>().method(<A1>[]));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// @dart = 2.7
|
||||
|
||||
abstract class Bar<C> {
|
||||
final List<C> _one = new List<C>();
|
||||
final List<C> _one = <C>[];
|
||||
|
||||
final bool _two = Foo is C;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class AppRuntimeLaunchData extends ChromeObject {
|
||||
}
|
||||
|
||||
List<AppRuntimeLaunchItem> get items {
|
||||
List<AppRuntimeLaunchItem> __proxy_items = new List<AppRuntimeLaunchItem>();
|
||||
List<AppRuntimeLaunchItem> __proxy_items = <AppRuntimeLaunchItem>[];
|
||||
int count = JS('int', '#.items.length', this._jsObject);
|
||||
for (int i = 0; i < count; i++) {
|
||||
var item = JS('', '#.items[#]', this._jsObject, i);
|
||||
|
||||
@@ -98,8 +98,7 @@ class FilesystemChooseEntryOptions extends ChromeObject {
|
||||
/// The optional list of accept options for this file opener. Each option will
|
||||
/// be presented as a unique group to the end-user.
|
||||
List<FilesystemAcceptOption> get accepts {
|
||||
List<FilesystemAcceptOption> __proxy_accepts =
|
||||
new List<FilesystemAcceptOption>();
|
||||
List<FilesystemAcceptOption> __proxy_accepts = <FilesystemAcceptOption>[];
|
||||
int count = JS('int', '#.accepts.length', this._jsObject);
|
||||
for (int i = 0; i < count; i++) {
|
||||
var item = JS('', '#.accepts[#]', this._jsObject, i);
|
||||
|
||||
@@ -55,7 +55,7 @@ Object _convertMapArgument(Map argument) {
|
||||
* Returns the new List object.
|
||||
*/
|
||||
List _convertListArgument(List argument) {
|
||||
List l = new List();
|
||||
List l = [];
|
||||
for (var i = 0; i < argument.length; i++) l.add(convertArgument(argument[i]));
|
||||
return l;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class Event {
|
||||
// proxy the callback
|
||||
void __proxy_callback(List rules) {
|
||||
if (callback != null) {
|
||||
List<Rule> __proxy_rules = new List<Rule>();
|
||||
List<Rule> __proxy_rules = <Rule>[];
|
||||
|
||||
for (Object o in rules) __proxy_rules.add(new Rule._proxy(o));
|
||||
|
||||
@@ -233,7 +233,7 @@ class Event {
|
||||
// proxy the callback
|
||||
void __proxy_callback(List rules) {
|
||||
if (callback != null) {
|
||||
List<Rule> __proxy_rules = new List<Rule>();
|
||||
List<Rule> __proxy_rules = <Rule>[];
|
||||
|
||||
for (Object o in rules) __proxy_rules.add(new Rule._proxy(o));
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ class _Utils {
|
||||
static List convertToList(List list) {
|
||||
// FIXME: [possible optimization]: do not copy the array if Dart_IsArray is fine w/ it.
|
||||
final length = list.length;
|
||||
List result = new List(length);
|
||||
List result = new List.filled(length, null);
|
||||
result.setRange(0, length, list);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user