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

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart

Issue 2921583002: Fix a corner case of function type inference. (Closed)
Patch Set: Created 3 years, 7 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/front_end/test/fasta/strong.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index 171c3d8278cf09a4fb68699b5be61a59b404b82e..3140de771faa09907c788e27c5b211699dca252e 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -107,6 +107,14 @@ class ClosureContext {
// TODO(paulberry): this is inherited from analyzer; it's not part of
// the spec. See also dartbug.com/29606.
inferredReturnType = greatestClosure(inferrer.coreTypes, returnContext);
+ } else if (isExpressionFunction &&
+ returnContext != null &&
+ inferredReturnType is DynamicType) {
+ // For expression-bodied functions, if the inferred return type is
+ // `dynamic`, we use the context.
+ // TODO(paulberry): this is inherited from analyzer; it's not part of the
+ // spec.
+ inferredReturnType = greatestClosure(inferrer.coreTypes, returnContext);
}
if (isGenerator) {
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698