| Index: sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
|
| ===================================================================
|
| --- sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart (revision 27995)
|
| +++ sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart (working copy)
|
| @@ -538,38 +538,31 @@
|
| }
|
|
|
| T visitLiteralList(LiteralList node) {
|
| - if (node.isConst()) {
|
| - // We only set the type once. We don't need to re-visit the children
|
| - // when re-analyzing the node.
|
| - return inferrer.concreteTypes.putIfAbsent(node, () {
|
| - T elementType;
|
| - int length = 0;
|
| - for (Node element in node.elements.nodes) {
|
| - T type = visit(element);
|
| - elementType = elementType == null
|
| - ? types.allocatePhi(null, null, type)
|
| - : types.addPhiInput(null, elementType, type);
|
| - length++;
|
| - }
|
| + // We only set the type once. We don't need to re-visit the children
|
| + // when re-analyzing the node.
|
| + return inferrer.concreteTypes.putIfAbsent(node, () {
|
| + T elementType;
|
| + int length = 0;
|
| + for (Node element in node.elements.nodes) {
|
| + T type = visit(element);
|
| elementType = elementType == null
|
| - ? types.nonNullEmpty()
|
| - : types.simplifyPhi(null, null, elementType);
|
| - return types.allocateContainer(
|
| - types.constListType,
|
| - node,
|
| - outermostElement,
|
| - elementType,
|
| - length);
|
| - });
|
| - } else {
|
| - node.visitChildren(this);
|
| - return inferrer.concreteTypes.putIfAbsent(node, () {
|
| - return types.allocateContainer(
|
| - types.growableListType,
|
| - node,
|
| - outermostElement);
|
| - });
|
| - }
|
| + ? types.allocatePhi(null, null, type)
|
| + : types.addPhiInput(null, elementType, type);
|
| + length++;
|
| + }
|
| + elementType = elementType == null
|
| + ? types.nonNullEmpty()
|
| + : types.simplifyPhi(null, null, elementType);
|
| + T containerType = node.isConst()
|
| + ? types.constListType
|
| + : types.growableListType;
|
| + return types.allocateContainer(
|
| + containerType,
|
| + node,
|
| + outermostElement,
|
| + elementType,
|
| + length);
|
| + });
|
| }
|
|
|
| bool isThisOrSuper(Node node) => node.isThis() || node.isSuper();
|
| @@ -826,12 +819,31 @@
|
| if (Elements.isGrowableListConstructorCall(element, node, compiler)) {
|
| return inferrer.concreteTypes.putIfAbsent(
|
| node, () => types.allocateContainer(
|
| - types.growableListType, node, outermostElement));
|
| + types.growableListType, node, outermostElement,
|
| + types.nonNullEmpty(), 0));
|
| } else if (Elements.isFixedListConstructorCall(element, node, compiler)
|
| || Elements.isFilledListConstructorCall(element, node, compiler)) {
|
| +
|
| + int initialLength;
|
| + T elementType;
|
| + if (Elements.isFixedListConstructorCall(element, node, compiler)) {
|
| + LiteralInt length = node.arguments.head.asLiteralInt();
|
| + if (length != null) {
|
| + initialLength = length.value;
|
| + }
|
| + elementType = types.nullType;
|
| + } else {
|
| + LiteralInt length = node.arguments.head.asLiteralInt();
|
| + if (length != null) {
|
| + initialLength = length.value;
|
| + }
|
| + elementType = arguments.positional[1];
|
| + }
|
| +
|
| return inferrer.concreteTypes.putIfAbsent(
|
| node, () => types.allocateContainer(
|
| - types.fixedListType, node, outermostElement));
|
| + types.fixedListType, node, outermostElement,
|
| + elementType, initialLength));
|
| } else if (element.isFunction() || element.isConstructor()) {
|
| return returnType;
|
| } else {
|
|
|