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

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

Issue 1720433002: fixes #25477, downward inference of generic methods (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
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 496b821de8f7b985808eea72ca1e4ce9c9071f30..59359c19e033baa505730e881a6fa2a963e29a0b 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -8162,7 +8162,7 @@ class ResolverVisitor extends ScopedVisitor {
safelyVisit(node.function);
node.accept(elementResolver);
_inferFunctionExpressionsParametersTypes(node.argumentList);
- InferenceContext.setType(node.argumentList, node.function.staticType);
+ _inferArgumentTypesFromContext(node);
safelyVisit(node.argumentList);
node.accept(typeAnalyzer);
return null;
@@ -8381,13 +8381,30 @@ class ResolverVisitor extends ScopedVisitor {
safelyVisit(node.typeArguments);
node.accept(elementResolver);
_inferFunctionExpressionsParametersTypes(node.argumentList);
+ _inferArgumentTypesFromContext(node);
+ safelyVisit(node.argumentList);
+ node.accept(typeAnalyzer);
+ return null;
+ }
+
+ void _inferArgumentTypesFromContext(InvocationExpression node) {
DartType contextType = node.staticInvokeType;
if (contextType is FunctionType) {
+ DartType originalType = node.function.staticType;
+ DartType returnContextType = InferenceContext.getType(node);
+ TypeSystem ts = typeSystem;
+ if (returnContextType != null &&
+ node.typeArguments == null &&
+ originalType is FunctionType &&
+ originalType.typeFormals.isNotEmpty &&
+ ts is StrongTypeSystemImpl) {
+
+ contextType = ts.inferGenericFunctionCall(typeProvider, originalType,
+ DartType.EMPTY_LIST, DartType.EMPTY_LIST, returnContextType);
+ }
+
InferenceContext.setType(node.argumentList, contextType);
}
- safelyVisit(node.argumentList);
- node.accept(typeAnalyzer);
- return null;
}
@override

Powered by Google App Engine
This is Rietveld 408576698