Index: pkg/analyzer/lib/src/generated/resolver.dart |
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart |
index 479a787c3d1c2bed22d656edaa82bbca9102b379..208206703d13eaf8f6d8bf37b210d43b4eec2e2d 100644 |
--- a/pkg/analyzer/lib/src/generated/resolver.dart |
+++ b/pkg/analyzer/lib/src/generated/resolver.dart |
@@ -8768,9 +8768,7 @@ class ResolverVisitor extends ScopedVisitor { |
InterfaceType wrapperType = _enclosingFunction.isSynchronous |
? typeProvider.iterableType |
: typeProvider.streamType; |
- List<DartType> candidates = |
- _findImplementedTypeArgument(type, wrapperType); |
- type = InterfaceTypeImpl.findMostSpecificType(candidates, typeSystem); |
+ type = typeSystem.mostSpecificTypeArgument(type, wrapperType); |
} |
if (type != null) { |
inferenceContext.addReturnOrYieldType(type); |
@@ -8842,39 +8840,6 @@ class ResolverVisitor extends ScopedVisitor { |
} |
/** |
- * Starting from t1, search its class hierarchy for types of the form |
- * `t2<R>`, and return a list of the resulting R's. |
- * |
- * For example, given t1 = `List<int>` and t2 = `Iterable<T>`, this will |
- * return [int]. |
- */ |
- // TODO(jmesserly): this is very similar to code used for flattening futures. |
- // The only difference is, because of a lack of TypeProvider, the other method |
- // has to match the Future type by its name and library. Here was are passed |
- // in the correct type. |
- List<DartType> _findImplementedTypeArgument(DartType t1, InterfaceType t2) { |
Jennifer Messerly
2016/03/08 19:14:11
oh awesome! I was wondering when reading error ver
|
- List<DartType> result = <DartType>[]; |
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); |
- void recurse(InterfaceTypeImpl type) { |
- if (type.element == t2.element && type.typeArguments.isNotEmpty) { |
- result.add(type.typeArguments[0]); |
- } |
- if (visitedClasses.add(type.element)) { |
- if (type.superclass != null) { |
- recurse(type.superclass); |
- } |
- type.mixins.forEach(recurse); |
- type.interfaces.forEach(recurse); |
- visitedClasses.remove(type.element); |
- } |
- } |
- if (t1 is InterfaceType) { |
- recurse(t1); |
- } |
- return result; |
- } |
- |
- /** |
* The given expression is the expression used to compute the iterator for a |
* for-each statement. Attempt to compute the type of objects that will be |
* assigned to the loop variable and return that type. Return `null` if the |