| Index: sdk/lib/_internal/compiler/implementation/types/types.dart
|
| ===================================================================
|
| --- sdk/lib/_internal/compiler/implementation/types/types.dart (revision 17700)
|
| +++ sdk/lib/_internal/compiler/implementation/types/types.dart (working copy)
|
| @@ -21,12 +21,21 @@
|
| class TypesTask extends CompilerTask {
|
| final String name = 'Type inference';
|
| final Set<Element> untypedElements;
|
| + /**
|
| + * A map from a method to the types its parameters will get.
|
| + */
|
| final Map<Element, Link<Element>> typedSends;
|
| +
|
| + /**
|
| + * Contains the types a specific node can have.
|
| + */
|
| + final Map<Node, Link<Element>> typedNodes;
|
| final ConcreteTypesInferrer concreteTypesInferrer;
|
|
|
| TypesTask(Compiler compiler)
|
| : untypedElements = new Set<Element>(),
|
| typedSends = new Map<Element, Link<Element>>(),
|
| + typedNodes = new Map<Node, Link<Element>>(),
|
| concreteTypesInferrer = compiler.enableConcreteTypeInference
|
| ? new ConcreteTypesInferrer(compiler) : null,
|
| super(compiler);
|
| @@ -64,14 +73,13 @@
|
| if (guaranteedType != null) return guaranteedType;
|
| }
|
| Element holder = element.enclosingElement;
|
| + if (!holder.isFunction()) return null;
|
| Link<Element> types = typedSends[holder];
|
| - if (types == null) return null;
|
| - if (!holder.isFunction()) return null;
|
| + if (types == null || types.isEmpty) return null;
|
| if (untypedElements.contains(holder)) return null;
|
| FunctionElement function = holder;
|
| FunctionSignature signature = function.computeSignature(compiler);
|
| for (Element parameter in signature.requiredParameters) {
|
| - if (types.isEmpty) return null;
|
| if (element == parameter) {
|
| return new ConcreteType.singleton(compiler.maxConcreteTypeSize,
|
| new ClassBaseType(types.head));
|
| @@ -91,7 +99,10 @@
|
| if (concreteTypesInferrer != null) {
|
| return concreteTypesInferrer.getConcreteTypeOfNode(node);
|
| }
|
| - return null;
|
| + Link<Element> types = typedNodes[node];
|
| + if (types == null || types.isEmpty) return null;
|
| + return new UnionType(new Set.from(
|
| + types.mappedBy((element) => new ClassBaseType(element))));
|
| });
|
| }
|
| }
|
|
|