Index: pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart |
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart |
index 27fbf5ac4deef651777c339e1a9586d4f1eea80c..23c2c3008a5dcf29e8a3fefba42986e355747555 100644 |
--- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart |
+++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart |
@@ -664,15 +664,15 @@ class TypeGraphInferrerEngine |
if (compiler.options.verbose) { |
compiler.progress.reset(); |
} |
- sortResolvedElements().forEach((Element element) { |
- assert(compiler.enqueuer.resolution.hasBeenProcessed(element)); |
+ sortResolvedAsts().forEach((ResolvedAst resolvedAst) { |
if (compiler.shouldPrintProgress) { |
reporter.log('Added $addedInGraph elements in inferencing graph.'); |
compiler.progress.reset(); |
} |
// This also forces the creation of the [ElementTypeInformation] to ensure |
// it is in the graph. |
- types.withMember(element, () => analyze(element, null)); |
+ types.withMember(resolvedAst.element.implementation, |
+ () => analyze(resolvedAst, null)); |
}); |
reporter.log('Added $addedInGraph elements in inferencing graph.'); |
@@ -828,13 +828,13 @@ class TypeGraphInferrerEngine |
processLoopInformation(); |
} |
- void analyze(AstElement element, ArgumentsTypes arguments) { |
- element = element.implementation; |
+ void analyze(ResolvedAst resolvedAst, ArgumentsTypes arguments) { |
+ AstElement element = resolvedAst.element.implementation; |
if (analyzedElements.contains(element)) return; |
analyzedElements.add(element); |
SimpleTypeInferrerVisitor visitor = new SimpleTypeInferrerVisitor( |
- element, element.resolvedAst, compiler, this); |
+ element, resolvedAst, compiler, this); |
TypeInformation type; |
reporter.withCurrentElement(element, () { |
type = visitor.run(); |
@@ -843,11 +843,12 @@ class TypeGraphInferrerEngine |
if (element.isField) { |
VariableElement fieldElement = element; |
- ast.Node node = fieldElement.node; |
+ ast.Node node = resolvedAst.node; |
+ ast.Node initializer = resolvedAst.body; |
if (element.isFinal || element.isConst) { |
// If [element] is final and has an initializer, we record |
// the inferred type. |
- if (fieldElement.initializer != null) { |
+ if (resolvedAst.body != null) { |
if (type is! ListTypeInformation && type is! MapTypeInformation) { |
// For non-container types, the constant handler does |
// constant folding that could give more precise results. |
@@ -873,7 +874,7 @@ class TypeGraphInferrerEngine |
} else if (!element.isInstanceMember) { |
recordType(element, types.nullType); |
} |
- } else if (fieldElement.initializer == null) { |
+ } else if (initializer == null) { |
// Only update types of static fields if there is no |
// assignment. Instance fields are dealt with in the constructor. |
if (Elements.isStaticOrTopLevelField(element)) { |
@@ -883,9 +884,9 @@ class TypeGraphInferrerEngine |
recordTypeOfNonFinalField(node, element, type); |
} |
if (Elements.isStaticOrTopLevelField(element) && |
- fieldElement.initializer != null && |
+ resolvedAst.body != null && |
!element.isConst) { |
- var argument = fieldElement.initializer; |
+ var argument = resolvedAst.body; |
// TODO(13429): We could do better here by using the |
// constant handler to figure out if it's a lazy field or not. |
if (argument.asSend() != null || |
@@ -1230,15 +1231,15 @@ class TypeGraphInferrerEngine |
// Sorts the resolved elements by size. We do this for this inferrer |
// to get the same results for [ListTracer] compared to the |
// [SimpleTypesInferrer]. |
- Iterable<Element> sortResolvedElements() { |
+ Iterable<ResolvedAst> sortResolvedAsts() { |
int max = 0; |
- Map<int, Setlet<Element>> methodSizes = new Map<int, Setlet<Element>>(); |
+ Map<int, Setlet<ResolvedAst>> methodSizes = <int, Setlet<ResolvedAst>>{}; |
compiler.enqueuer.resolution.processedElements |
.forEach((AstElement element) { |
// TODO(ngeoffray): Not sure why the resolver would put a null |
// mapping. |
if (!compiler.enqueuer.resolution.hasBeenProcessed(element)) return; |
- ResolvedAst resolvedAst = element.resolvedAst; |
+ ResolvedAst resolvedAst = getResolvedAst(element); |
element = element.implementation; |
if (element.impliesType) return; |
assert(invariant( |
@@ -1258,14 +1259,14 @@ class TypeGraphInferrerEngine |
length = mapping.getSelectorCount(); |
} |
max = length > max ? length : max; |
- Setlet<Element> set = |
- methodSizes.putIfAbsent(length, () => new Setlet<Element>()); |
- set.add(element); |
+ Setlet<ResolvedAst> set = |
+ methodSizes.putIfAbsent(length, () => new Setlet<ResolvedAst>()); |
+ set.add(resolvedAst); |
}); |
- List<Element> result = <Element>[]; |
+ List<ResolvedAst> result = <ResolvedAst>[]; |
for (int i = 0; i <= max; i++) { |
- Setlet<Element> set = methodSizes[i]; |
+ Setlet<ResolvedAst> set = methodSizes[i]; |
if (set != null) result.addAll(set); |
} |
return result; |