| Index: sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
|
| index acacbe25c19d9af2f880d5eab6e3f0b82f8d075c..27db3f3aa726735fdf3be6593b3f25440b07f8c4 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
|
| @@ -357,11 +357,6 @@ abstract class InferrerEngine<T, V extends TypeSystem>
|
| T typeOfElement(Element element);
|
|
|
| /**
|
| - * Returns the return type of [element].
|
| - */
|
| - T returnTypeOfElement(Element element);
|
| -
|
| - /**
|
| * Records that [node] sets final field [element] to be of type [type].
|
| *
|
| * [nodeHolder] is the element holder of [node].
|
| @@ -556,37 +551,6 @@ abstract class InferrerEngine<T, V extends TypeSystem>
|
| return returnType;
|
| }
|
|
|
| - /**
|
| - * Returns the type of [element] when being called with [selector].
|
| - */
|
| - T typeOfElementWithSelector(Element element, Selector selector) {
|
| - if (element.name == Compiler.NO_SUCH_METHOD
|
| - && selector.name != element.name) {
|
| - // An invocation can resolve to a [noSuchMethod], in which case
|
| - // we get the return type of [noSuchMethod].
|
| - return returnTypeOfElement(element);
|
| - } else if (selector.isGetter()) {
|
| - if (element.isFunction()) {
|
| - // [functionType] is null if the inferrer did not run.
|
| - return types.functionType == null
|
| - ? types.dynamicType
|
| - : types.functionType;
|
| - } else if (element.isField()) {
|
| - return typeOfElement(element);
|
| - } else if (Elements.isUnresolved(element)) {
|
| - return types.dynamicType;
|
| - } else {
|
| - assert(element.isGetter());
|
| - return returnTypeOfElement(element);
|
| - }
|
| - } else if (element.isGetter() || element.isField()) {
|
| - assert(selector.isCall() || selector.isSetter());
|
| - return types.dynamicType;
|
| - } else {
|
| - return returnTypeOfElement(element);
|
| - }
|
| - }
|
| -
|
| void updateSelectorInTree(Element owner, Node node, Selector selector) {
|
| var elements = compiler.enqueuer.resolution.getCachedElements(owner);
|
| if (node.asSendSet() != null) {
|
| @@ -621,8 +585,54 @@ abstract class InferrerEngine<T, V extends TypeSystem>
|
| }
|
| }
|
|
|
| +/**
|
| + * An [InferrerEngine] which provides a [typeOfElementWithSelector] method
|
| + * assuming the existence of a [returnTypeOfElement] method.
|
| + */
|
| +abstract class SimpleInferrerEngine<T, V extends TypeSystem>
|
| + extends InferrerEngine<T, V> {
|
| +
|
| + SimpleInferrerEngine(Compiler compiler, V types) : super(compiler, types);
|
| +
|
| + /**
|
| + * Returns the return type of [element].
|
| + */
|
| + T returnTypeOfElement(Element element);
|
| +
|
| + /**
|
| + * Returns the type of [element] when being called with [selector].
|
| + */
|
| + T typeOfElementWithSelector(Element element, Selector selector) {
|
| + if (element.name == Compiler.NO_SUCH_METHOD
|
| + && selector.name != element.name) {
|
| + // An invocation can resolve to a [noSuchMethod], in which case
|
| + // we get the return type of [noSuchMethod].
|
| + return returnTypeOfElement(element);
|
| + } else if (selector.isGetter()) {
|
| + if (element.isFunction()) {
|
| + // [functionType] is null if the inferrer did not run.
|
| + return types.functionType == null
|
| + ? types.dynamicType
|
| + : types.functionType;
|
| + } else if (element.isField()) {
|
| + return typeOfElement(element);
|
| + } else if (Elements.isUnresolved(element)) {
|
| + return types.dynamicType;
|
| + } else {
|
| + assert(element.isGetter());
|
| + return returnTypeOfElement(element);
|
| + }
|
| + } else if (element.isGetter() || element.isField()) {
|
| + assert(selector.isCall() || selector.isSetter());
|
| + return types.dynamicType;
|
| + } else {
|
| + return returnTypeOfElement(element);
|
| + }
|
| + }
|
| +}
|
| +
|
| class InternalSimpleTypesInferrer
|
| - extends InferrerEngine<TypeMask, TypeMaskSystem>
|
| + extends SimpleInferrerEngine<TypeMask, TypeMaskSystem>
|
| implements TypesInferrer {
|
| /**
|
| * Maps a class to a [ClassTypeInformation] to help collect type
|
| @@ -2183,13 +2193,17 @@ class SimpleTypeInferrerVisitor<T>
|
| node.visitChildren(this);
|
| Element element = elements[node];
|
| Selector selector = elements.getSelector(node);
|
| + visit(node.receiver);
|
| + ArgumentsTypes arguments = analyzeArguments(node.arguments);
|
| if (element != null && element.isFunction()) {
|
| assert(Elements.isLocal(element));
|
| // This only works for function statements. We need a
|
| // more sophisticated type system with function types to support
|
| // more.
|
| inferrer.updateSideEffects(sideEffects, selector, element);
|
| - return inferrer.returnTypeOfElement(element);
|
| + return inferrer.registerCalledElement(
|
| + node, selector, outermostElement, element, arguments, null,
|
| + sideEffects, inLoop);
|
| }
|
| sideEffects.setDependsOnSomething();
|
| sideEffects.setAllSideEffects();
|
| @@ -2291,15 +2305,14 @@ class SimpleTypeInferrerVisitor<T>
|
| }
|
| });
|
| ArgumentsTypes arguments = new ArgumentsTypes<T>(unnamed, named);
|
| - inferrer.registerCalledElement(node,
|
| - null,
|
| - outermostElement,
|
| - element,
|
| - arguments,
|
| - null,
|
| - sideEffects,
|
| - inLoop);
|
| - return inferrer.returnTypeOfElement(element);
|
| + return inferrer.registerCalledElement(node,
|
| + null,
|
| + outermostElement,
|
| + element,
|
| + arguments,
|
| + null,
|
| + sideEffects,
|
| + inLoop);
|
| }
|
|
|
| T visitReturn(Return node) {
|
|
|