Index: pkg/analyzer/lib/src/summary/link.dart |
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart |
index eb440e0274f71517d0a561cd6630742a4ab3ae15..67c5149995836fc7f1a3150fcd2d7f90422406d1 100644 |
--- a/pkg/analyzer/lib/src/summary/link.dart |
+++ b/pkg/analyzer/lib/src/summary/link.dart |
@@ -2862,6 +2862,9 @@ class FunctionElementForLink_Initializer extends Object |
String get identifier => ''; |
@override |
+ bool get isAsynchronous => _unlinkedExecutable.isAsynchronous; |
+ |
+ @override |
DartType get returnType { |
// If this is a variable whose type needs inferring, infer it. |
if (_variable.hasImplicitType) { |
@@ -2997,6 +3000,9 @@ class FunctionElementForLink_Local_NonSynthetic extends ExecutableElementForLink |
} |
@override |
+ bool get isAsynchronous => _unlinkedExecutable.isAsynchronous; |
+ |
+ @override |
bool get _hasTypeBeenInferred => _inferredReturnType != null; |
@override |
@@ -4649,8 +4655,15 @@ class TypeInferenceNode extends Node<TypeInferenceNode> { |
if (inCycle) { |
functionElement._setInferredType(DynamicTypeImpl.instance); |
} else { |
- functionElement |
- ._setInferredType(new ExprTypeComputer(functionElement).compute()); |
+ var bodyType = new ExprTypeComputer(functionElement).compute(); |
+ if (functionElement.isAsynchronous) { |
+ var linker = functionElement.compilationUnit.library._linker; |
+ var typeProvider = linker.typeProvider; |
+ var typeSystem = linker.typeSystem; |
+ bodyType = typeProvider.futureType |
+ .instantiate([bodyType.flattenFutures(typeSystem)]); |
+ } |
+ functionElement._setInferredType(bodyType); |
} |
} |