| Index: pkg/analyzer/lib/src/generated/element_resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
|
| index 442d1190a819efa8390f0ebef96157d989c0f486..9009aaed270bf70d39651a527dc41da4b0383361 100644
|
| --- a/pkg/analyzer/lib/src/generated/element_resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
|
| @@ -639,15 +639,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
|
| if (_enableHints && errorCode == null && staticElement == null) {
|
| // The method lookup may have failed because there were multiple
|
| // incompatible choices. In this case we don't want to generate a hint.
|
| - if (propagatedElement == null && propagatedType is UnionType) {
|
| - // TODO(collinsn): an improvement here is to make the propagated type
|
| - // of the method call the union of the propagated types of all possible
|
| - // calls.
|
| - if (_lookupMethods(target, propagatedType, methodName.name).length >
|
| - 1) {
|
| - return null;
|
| - }
|
| - }
|
| errorCode = _checkForInvocationError(target, false, propagatedElement);
|
| if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) {
|
| ClassElement classElementContext = null;
|
| @@ -1723,13 +1714,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
|
| }
|
| return _lookUpMethodInInterfaces(
|
| interfaceType, false, methodName, new HashSet<ClassElement>());
|
| - } else if (type is UnionType) {
|
| - // TODO (collinsn): I want [computeMergedExecutableElement] to be general
|
| - // and work with functions, methods, constructors, and property accessors.
|
| - // However, I won't be able to assume it returns [MethodElement] here
|
| - // then.
|
| - return _maybeMergeExecutableElements(
|
| - _lookupMethods(target, type, methodName)) as MethodElement;
|
| }
|
| return null;
|
| }
|
| @@ -1785,35 +1769,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Look up all methods with the given [methodName] that are defined on the
|
| - * given union [type].
|
| - */
|
| - Set<ExecutableElement> _lookupMethods(
|
| - Expression target, UnionType type, String methodName) {
|
| - Set<ExecutableElement> methods = new HashSet<ExecutableElement>();
|
| - bool allElementsHaveMethod = true;
|
| - for (DartType t in type.elements) {
|
| - MethodElement m = _lookUpMethod(target, t, methodName);
|
| - if (m != null) {
|
| - methods.add(m);
|
| - } else {
|
| - allElementsHaveMethod = false;
|
| - }
|
| - }
|
| - // For strict union types we require that all types in the union define the
|
| - // method.
|
| - if (AnalysisEngine.instance.strictUnionTypes) {
|
| - if (allElementsHaveMethod) {
|
| - return methods;
|
| - } else {
|
| - return new Set<ExecutableElement>();
|
| - }
|
| - } else {
|
| - return methods;
|
| - }
|
| - }
|
| -
|
| - /**
|
| * Look up the setter with the given [setterName] in the given [type]. Return
|
| * the element representing the setter that was found, or `null` if there is
|
| * no setter with the given name. The [target] is the target of the
|
| @@ -2389,7 +2344,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
|
| */
|
| Element _resolveInvokedElementWithTarget(
|
| Expression target, DartType targetType, SimpleIdentifier methodName) {
|
| - if (targetType is InterfaceType || targetType is UnionType) {
|
| + if (targetType is InterfaceType) {
|
| Element element = _lookUpMethod(target, targetType, methodName.name);
|
| if (element == null) {
|
| //
|
| @@ -2486,12 +2441,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
|
| _shouldReportMissingMember(propagatedType, propagatedElement) &&
|
| !_memberFoundInSubclass(
|
| propagatedType.element, propertyName.name, false, true);
|
| - // TODO(collinsn): add support for errors on union types by extending
|
| - // [lookupGetter] and [lookupSetter] in analogy with the earlier
|
| - // [lookupMethod] extensions.
|
| - if (propagatedType is UnionType) {
|
| - shouldReportMissingMember_propagated = false;
|
| - }
|
| if (shouldReportMissingMember_static ||
|
| shouldReportMissingMember_propagated) {
|
| DartType staticOrPropagatedType =
|
| @@ -2720,80 +2669,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Helper function for `maybeMergeExecutableElements` that does the actual
|
| - * merging. The [elementArrayToMerge] is the non-empty list of elements to
|
| - * merge.
|
| - */
|
| - static ExecutableElement _computeMergedExecutableElement(
|
| - List<ExecutableElement> elementArrayToMerge) {
|
| - // Flatten methods structurally. Based on
|
| - // [InheritanceManager.computeMergedExecutableElement] and
|
| - // [InheritanceManager.createSyntheticExecutableElement].
|
| - //
|
| - // However, the approach we take here is much simpler, but expected to work
|
| - // well in the common case. It degrades gracefully in the uncommon case,
|
| - // by computing the type [dynamic] for the method, preventing any
|
| - // hints from being generated (TODO: not done yet).
|
| - //
|
| - // The approach is: we require that each [ExecutableElement] has the
|
| - // same shape: the same number of required, optional positional, and
|
| - // optional named parameters, in the same positions, and with the named
|
| - // parameters in the same order. We compute a type by unioning pointwise.
|
| - ExecutableElement e_0 = elementArrayToMerge[0];
|
| - List<ParameterElement> ps_0 = e_0.parameters;
|
| - List<ParameterElementImpl> ps_out =
|
| - new List<ParameterElementImpl>(ps_0.length);
|
| - for (int j = 0; j < ps_out.length; j++) {
|
| - ps_out[j] = new ParameterElementImpl(ps_0[j].name, 0);
|
| - ps_out[j].synthetic = true;
|
| - ps_out[j].type = ps_0[j].type;
|
| - ps_out[j].parameterKind = ps_0[j].parameterKind;
|
| - }
|
| - DartType r_out = e_0.returnType;
|
| - for (int i = 1; i < elementArrayToMerge.length; i++) {
|
| - ExecutableElement e_i = elementArrayToMerge[i];
|
| - r_out = UnionTypeImpl.union([r_out, e_i.returnType]);
|
| - List<ParameterElement> ps_i = e_i.parameters;
|
| - // Each function must have the same number of params.
|
| - if (ps_0.length != ps_i.length) {
|
| - return null;
|
| - // TODO (collinsn): return an element representing [dynamic] here
|
| - // instead.
|
| - } else {
|
| - // Each function must have the same kind of params, with the same names,
|
| - // in the same order.
|
| - for (int j = 0; j < ps_i.length; j++) {
|
| - if (ps_0[j].parameterKind != ps_i[j].parameterKind ||
|
| - !identical(ps_0[j].name, ps_i[j].name)) {
|
| - return null;
|
| - } else {
|
| - // The output parameter type is the union of the input parameter
|
| - // types.
|
| - ps_out[j].type =
|
| - UnionTypeImpl.union([ps_out[j].type, ps_i[j].type]);
|
| - }
|
| - }
|
| - }
|
| - }
|
| - // TODO (collinsn): this code should work for functions and methods,
|
| - // so we may want [FunctionElementImpl]
|
| - // instead here in some cases?
|
| - // And then there are constructors and property accessors.
|
| - // Maybe the answer is to create a new subclass of [ExecutableElementImpl]
|
| - // which is used for merged executable elements, in analogy with
|
| - // [MultiplyInheritedMethodElementImpl] and
|
| - // [MultiplyInheritedPropertyAcessorElementImpl].
|
| - ExecutableElementImpl e_out = new MethodElementImpl(e_0.name, 0);
|
| - e_out.synthetic = true;
|
| - e_out.returnType = r_out;
|
| - e_out.parameters = ps_out;
|
| - e_out.type = new FunctionTypeImpl.con1(e_out);
|
| - // Get NPE in [toString()] w/o this.
|
| - e_out.enclosingElement = e_0.enclosingElement;
|
| - return e_out;
|
| - }
|
| -
|
| - /**
|
| * Return `true` if the given [identifier] is the return type of a constructor
|
| * declaration.
|
| */
|
| @@ -2839,25 +2714,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| - /**
|
| - * Return a method representing the merge of the given [elements]. The type of
|
| - * the merged element is the component-wise union of the types of the given
|
| - * elements. If not all input elements have the same shape then `null` is
|
| - * returned.
|
| - */
|
| - static ExecutableElement _maybeMergeExecutableElements(
|
| - Set<ExecutableElement> elements) {
|
| - List<ExecutableElement> elementArrayToMerge = new List.from(elements);
|
| - if (elementArrayToMerge.length == 0) {
|
| - return null;
|
| - } else if (elementArrayToMerge.length == 1) {
|
| - // If all methods are equal, don't bother building a new one.
|
| - return elementArrayToMerge[0];
|
| - } else {
|
| - return _computeMergedExecutableElement(elementArrayToMerge);
|
| - }
|
| - }
|
| }
|
|
|
| /**
|
|
|