Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 2655463004: Fix summary type inference of async closures. (Closed)
Patch Set: Remove bogusly added test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698