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

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

Issue 1594313002: Create a public interface for AST nodes and rename the implementation classes (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/ast.dart ('k') | 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/element_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index d1189e204298c58be9c873636daa9f2fed2a75af..b018994ca3b91009c4640aad8d62f7cf5bb7644c 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -1352,6 +1352,49 @@ class ElementResolver extends SimpleAstVisitor<Object> {
return null;
}
+ DartType _computeMethodInvokeType(MethodInvocation node, Element element) {
+ if (element == null) {
+ return null;
+ }
+
+ DartType invokeType;
+ if (element is PropertyAccessorElement) {
+ invokeType = element.returnType;
+ } else if (element is ExecutableElement) {
+ invokeType = element.type;
+ } else if (element is VariableElement) {
+ invokeType = _promoteManager.getStaticType(element);
+ }
+
+ //
+ // Check for a generic method & apply type arguments if any were passed.
+ //
+ // TODO(jmesserly): support generic "call" methods on InterfaceType.
+ if (invokeType is FunctionType) {
+ FunctionType type = invokeType;
+ List<TypeParameterElement> parameters = type.typeFormals;
+
+ NodeList<TypeName> arguments = node.typeArguments?.arguments;
+ if (arguments != null && arguments.length != parameters.length) {
+ // Wrong number of type arguments. Ignore them
+ arguments = null;
+ _resolver.reportErrorForNode(
+ StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS,
+ node.methodName,
+ [type, parameters.length, arguments?.length ?? 0]);
+ }
+ if (parameters.isNotEmpty) {
+ if (arguments == null) {
+ invokeType = _resolver.typeSystem.instantiateToBounds(type);
+ } else {
+ invokeType = type.instantiate(arguments.map((n) => n.type).toList());
+ }
+ }
+ }
+
+ return invokeType;
+ }
+
/**
* Given an element, computes the type of the invocation.
*
@@ -2573,7 +2616,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
* AST when the parser could not distinguish between a method invocation and an
* invocation of a top-level function imported with a prefix.
*/
-class SyntheticIdentifier extends Identifier {
+class SyntheticIdentifier extends IdentifierImpl {
/**
* The name of the synthetic identifier.
*/
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698