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

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

Issue 2260313002: Extend Future.then inference to subclasses (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase 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 | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/static_type_analyzer.dart
diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
index b3484a9669f10f2a400eea6da6415c7340da9d7b..628c340c7848f7a473a69525538c683a65e7c74d 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -1947,7 +1947,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
DartType returnContext = InferenceContext.getContext(node);
DartType returnType;
if (returnContext is FutureUnionType) {
- returnType = fnType.returnType.isDartAsyncFuture
+ returnType = _resolver.isSubtypeOfFuture(fnType.returnType)
? returnContext.futureOfType
: returnContext.type;
} else {
@@ -1974,7 +1974,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
// S or Future<S> in a conditional.
if (!argReturnType.isObject && !argReturnType.isDynamic) {
DartType paramReturnType = fnType.typeFormals[0].type;
- if (argReturnType.isDartAsyncFuture) {
+ if (_resolver.isSubtypeOfFuture(argReturnType)) {
// Given an argument of (T) -> Future<S>, instantiate with <S>
paramReturnType =
_typeProvider.futureType.instantiate([paramReturnType]);
@@ -1986,13 +1986,11 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
..shareParameters(firstParamType.parameters)
..returnType = paramReturnType;
function.type = new FunctionTypeImpl(function);
-
// Use this as the expected 1st parameter type.
paramTypes[0] = function.type;
}
}
}
-
return ts.inferGenericFunctionCall(
_typeProvider, fnType, paramTypes, argTypes, returnType);
}
@@ -2016,6 +2014,13 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
return;
}
+ // TODO(leafp): Currently, we may re-infer types here, since we
+ // sometimes resolve multiple times. We should really check that we
+ // have not already inferred something. However, the obvious ways to
+ // check this don't work, since we may have been instantiated
+ // to bounds in an earlier phase, and we *do* want to do inference
+ // in that case.
+
// Get back to the uninstantiated generic constructor.
// TODO(jmesserly): should we store this earlier in resolution?
// Or look it up, instead of jumping backwards through the Member?
@@ -2076,7 +2081,6 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
}
computedType = _computeReturnTypeOfFunction(body, computedType);
-
functionElement.returnType = computedType;
_recordPropagatedTypeOfFunction(functionElement, node.body);
_recordStaticType(node, functionElement.type);
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698