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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 2253923002: fix #27088, future then upwards inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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/lib/src/generated/static_type_analyzer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cec835498ebd710d9abd819f8f3d5b0ce5811125..71d2e7b9ee3e69c16de835b4b74fadfe759730eb 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -5758,6 +5758,18 @@ class ResolverVisitor extends ScopedVisitor {
}
/**
+ * Returns true if this method is `Future.then`.
+ *
+ * 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;
+ }
+
+ /**
* Given a downward inference type [fnType], and the declared
* [typeParameterList] for a function expression, determines if we can enable
* downward inference and if so, returns the function type to use for
@@ -6583,7 +6595,7 @@ class ResolverVisitor extends ScopedVisitor {
_inferFormalParameterList(node.parameters, functionType);
DartType returnType;
- if (_isFutureThenLambda(node)) {
+ if (isFutureThen(node.staticParameterElement?.enclosingElement)) {
var futureThenType =
InferenceContext.getContext(node.parent) as FunctionType;
@@ -7394,19 +7406,6 @@ class ResolverVisitor extends ScopedVisitor {
}
/**
- * Returns true if this expression is being passed to `Future.then`.
- *
- * If so we will apply special typing rules in strong mode, to handle the
- * implicit union of `S | Future<S>`
- */
- bool _isFutureThenLambda(FunctionExpression node) {
- Element element = node.staticParameterElement?.enclosingElement;
- return element is MethodElement &&
- element.name == 'then' &&
- element.enclosingElement.type.isDartAsyncFuture;
- }
-
- /**
* Return `true` if the given variable is accessed within a closure in the given
* [AstNode] and also mutated somewhere in variable scope. This information is only
* available for local variables (including parameters).
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/static_type_analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698