Chromium Code Reviews| 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 98e7ca78cbaede97ce66dff3477fe77518309c88..07e6c70629dafe689bcf297a12f6d25cf5ee40b5 100644 |
| --- a/pkg/analyzer/lib/src/generated/resolver.dart |
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart |
| @@ -5758,15 +5758,25 @@ class ResolverVisitor extends ScopedVisitor { |
| } |
| /** |
| - * Returns true if this method is `Future.then`. |
| + * Returns true if this method is `Future.then` or an override thereof. |
| * |
| * If so we will apply special typing rules in strong mode, to handle the |
| * implicit union of `S | Future<S>` |
| */ |
| bool isFutureThen(Element element) { |
| - return element is MethodElement && |
| - element.name == 'then' && |
| - element.enclosingElement.type.isDartAsyncFuture; |
| + // If we are a method named then |
| + if (element is MethodElement && element.name == 'then') { |
| + // On Future, then we're good. |
| + if (element.enclosingElement.type.isDartAsyncFuture) { |
|
Jennifer Messerly
2016/08/19 19:36:46
could be worth a "DartType type = element.enclosin
Leaf
2016/08/19 19:47:00
Done.
|
| + return true; |
| + } |
| + // On a subtype of Future we're good. |
| + if (typeSystem.isSubtypeOf( |
| + element.enclosingElement.type, typeProvider.futureDynamicType)) { |
| + return true; |
| + } |
| + } |
| + return false; |
| } |
| /** |
| @@ -6725,6 +6735,12 @@ class ResolverVisitor extends ScopedVisitor { |
| @override |
| Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| TypeName classTypeName = node.constructorName.type; |
| + // TODO(leafp): Currently, we may re-infer types here, since we |
| + // sometimes resolve multiple times. We should really check that we |
| + // have not already inferred something. However, the obvious ways to |
| + // check this don't work, since we class may have been instantiated |
| + // to bounds in an earlier phase, and we *do* want to do inference |
| + // in that case. |
| if (classTypeName.typeArguments == null) { |
| // Given a union of context types ` T0 | T1 | ... | Tn`, find the first |
| // valid instantiation `new C<Ti>`, if it exists. |