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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.resolver; 5 library analyzer.src.generated.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 8144 matching lines...) Expand 10 before | Expand all | Expand 10 after
8155 _enclosingFunction = outerFunction; 8155 _enclosingFunction = outerFunction;
8156 } 8156 }
8157 return null; 8157 return null;
8158 } 8158 }
8159 8159
8160 @override 8160 @override
8161 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 8161 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
8162 safelyVisit(node.function); 8162 safelyVisit(node.function);
8163 node.accept(elementResolver); 8163 node.accept(elementResolver);
8164 _inferFunctionExpressionsParametersTypes(node.argumentList); 8164 _inferFunctionExpressionsParametersTypes(node.argumentList);
8165 InferenceContext.setType(node.argumentList, node.function.staticType); 8165 _inferArgumentTypesFromContext(node);
8166 safelyVisit(node.argumentList); 8166 safelyVisit(node.argumentList);
8167 node.accept(typeAnalyzer); 8167 node.accept(typeAnalyzer);
8168 return null; 8168 return null;
8169 } 8169 }
8170 8170
8171 @override 8171 @override
8172 Object visitFunctionTypeAlias(FunctionTypeAlias node) { 8172 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
8173 // Resolve the metadata in the library scope. 8173 // Resolve the metadata in the library scope.
8174 if (node.metadata != null) { 8174 if (node.metadata != null) {
8175 node.metadata.accept(this); 8175 node.metadata.accept(this);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
8374 @override 8374 @override
8375 Object visitMethodInvocation(MethodInvocation node) { 8375 Object visitMethodInvocation(MethodInvocation node) {
8376 // 8376 //
8377 // We visit the target and argument list, but do not visit the method name 8377 // We visit the target and argument list, but do not visit the method name
8378 // because it needs to be visited in the context of the invocation. 8378 // because it needs to be visited in the context of the invocation.
8379 // 8379 //
8380 safelyVisit(node.target); 8380 safelyVisit(node.target);
8381 safelyVisit(node.typeArguments); 8381 safelyVisit(node.typeArguments);
8382 node.accept(elementResolver); 8382 node.accept(elementResolver);
8383 _inferFunctionExpressionsParametersTypes(node.argumentList); 8383 _inferFunctionExpressionsParametersTypes(node.argumentList);
8384 DartType contextType = node.staticInvokeType; 8384 _inferArgumentTypesFromContext(node);
8385 if (contextType is FunctionType) {
8386 InferenceContext.setType(node.argumentList, contextType);
8387 }
8388 safelyVisit(node.argumentList); 8385 safelyVisit(node.argumentList);
8389 node.accept(typeAnalyzer); 8386 node.accept(typeAnalyzer);
8390 return null; 8387 return null;
8391 } 8388 }
8392 8389
8390 void _inferArgumentTypesFromContext(InvocationExpression node) {
8391 DartType contextType = node.staticInvokeType;
8392 if (contextType is FunctionType) {
8393 DartType originalType = node.function.staticType;
8394 DartType returnContextType = InferenceContext.getType(node);
8395 TypeSystem ts = typeSystem;
8396 if (returnContextType != null &&
8397 node.typeArguments == null &&
8398 originalType is FunctionType &&
8399 originalType.typeFormals.isNotEmpty &&
8400 ts is StrongTypeSystemImpl) {
8401
8402 contextType = ts.inferGenericFunctionCall(typeProvider, originalType,
8403 DartType.EMPTY_LIST, DartType.EMPTY_LIST, returnContextType);
8404 }
8405
8406 InferenceContext.setType(node.argumentList, contextType);
8407 }
8408 }
8409
8393 @override 8410 @override
8394 Object visitNamedExpression(NamedExpression node) { 8411 Object visitNamedExpression(NamedExpression node) {
8395 InferenceContext.setType(node.expression, InferenceContext.getType(node)); 8412 InferenceContext.setType(node.expression, InferenceContext.getType(node));
8396 return super.visitNamedExpression(node); 8413 return super.visitNamedExpression(node);
8397 } 8414 }
8398 8415
8399 @override 8416 @override
8400 Object visitNode(AstNode node) { 8417 Object visitNode(AstNode node) {
8401 node.visitChildren(this); 8418 node.visitChildren(this);
8402 node.accept(elementResolver); 8419 node.accept(elementResolver);
(...skipping 4380 matching lines...) Expand 10 before | Expand all | Expand 10 after
12783 nonFields.add(node); 12800 nonFields.add(node);
12784 return null; 12801 return null;
12785 } 12802 }
12786 12803
12787 @override 12804 @override
12788 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 12805 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
12789 12806
12790 @override 12807 @override
12791 Object visitWithClause(WithClause node) => null; 12808 Object visitWithClause(WithClause node) => null;
12792 } 12809 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698