Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(902)

Unified Diff: sdk/lib/_internal/compiler/implementation/types/container_tracer.dart

Issue 17334003: Do not treat elements of lists allocated through new List() and new List.filled() as potentially nu… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/types/container_tracer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/container_tracer.dart (revision 24172)
+++ sdk/lib/_internal/compiler/implementation/types/container_tracer.dart (working copy)
@@ -166,7 +166,6 @@
// that adds elements to the list.
if (potentialType == null) return new TypeMask.empty();
- potentialType = potentialType.nullable();
// Walk over the found constraints and update the type according
// to the selectors of these constraints.
for (Selector constraint in constraints) {
@@ -176,7 +175,7 @@
inferrer.getTypeOfSelector(constraint), compiler);
}
if (_VERBOSE) {
- print('$potentialType for $analyzedNode');
+ print('$potentialType for $analyzedNode $startElement');
}
return potentialType;
}
@@ -520,27 +519,43 @@
TypeMask visitStaticSend(Send node) {
Element element = elements[node];
- bool isEscaping = visitArguments(node.arguments, element);
- if (element.isForeign(compiler)) {
- if (isEscaping) return tracer.bailout('Used in a JS');
- }
-
- if (tracer.couldBeTheList(element)) {
- escaping = true;
- }
-
if (Elements.isGrowableListConstructorCall(element, node, compiler)) {
+ visitArguments(node.arguments, element);
if (tracer.couldBeTheList(node)) {
escaping = true;
}
return inferrer.growableListType;
} else if (Elements.isFixedListConstructorCall(element, node, compiler)) {
+ tracer.unionPotentialTypeWith(inferrer.nullType);
+ visitArguments(node.arguments, element);
if (tracer.couldBeTheList(node)) {
escaping = true;
}
return inferrer.fixedListType;
- } else if (element.isFunction() || element.isConstructor()) {
+ } else if (Elements.isFilledListConstructorCall(element, node, compiler)) {
+ if (tracer.couldBeTheList(node)) {
+ escaping = true;
+ visit(node.arguments.head);
+ TypeMask fillWithType = visit(node.arguments.tail.head);
+ tracer.unionPotentialTypeWith(fillWithType);
+ } else {
+ visitArguments(node.arguments, element);
+ }
+ return inferrer.fixedListType;
+ }
+
+ bool isEscaping = visitArguments(node.arguments, element);
+
+ if (element.isForeign(compiler)) {
+ if (isEscaping) return tracer.bailout('Used in a JS');
+ }
+
+ if (tracer.couldBeTheList(element)) {
+ escaping = true;
+ }
+
+ if (element.isFunction() || element.isConstructor()) {
return inferrer.getReturnTypeOfElement(element);
} else {
// Closure call or unresolved.

Powered by Google App Engine
This is Rietveld 408576698