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

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

Issue 2022513002: Reorder Future.then checks in StrongTypeSystemImpl. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/type_system.dart
diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
index f34e7e67fda6049ce5bf5af7d85e1c24fce63d83..7e4103d9e10266574e2830246831c51f9d151ecc 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -73,7 +73,6 @@ class StrongTypeSystemImpl extends TypeSystem {
}
/// Computes the greatest lower bound of [type1] and [type2].
- @override
DartType getGreatestLowerBound(
TypeProvider provider, DartType type1, DartType type2) {
// The greatest lower bound relation is reflexive.
@@ -208,16 +207,16 @@ class StrongTypeSystemImpl extends TypeSystem {
// We don't have union types, so Future<T>.then<S> is typed to take a
// callback `T -> S`. However, the lambda might actually return a
// Future<S>. So we handle that special case here.
- Element element = fnType?.element;
- bool isFutureThen = element is MethodElement &&
- element.name == 'then' &&
- element.enclosingElement.type.isDartAsyncFuture;
- if (isFutureThen &&
- argumentTypes.isNotEmpty &&
- argumentTypes[0] is FunctionType) {
- // Ignore return context. We'll let the onValue function's return type
- // drive inference.
- returnContextType = null;
+ if (argumentTypes.isNotEmpty && argumentTypes[0] is FunctionType) {
+ Element element = fnType?.element;
+ bool isFutureThen = element is MethodElement &&
+ element.name == 'then' &&
+ element.enclosingElement.type.isDartAsyncFuture;
+ if (isFutureThen) {
+ // Ignore return context. We'll let the onValue function's return type
+ // drive inference.
+ returnContextType = null;
+ }
}
if (returnContextType != null) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698