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

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

Issue 1142853002: Handle type parameters correctly when generating hints (issue 23243) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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 | pkg/analyzer/test/generated/resolver_test.dart » ('j') | 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 4754e333477d9070076801757b6b928919d62bc5..291ac5b3a1c5dd35763499be54d0cc46053d0aad 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -651,7 +651,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
if (target == null) {
classElementContext = _resolver.enclosingClass;
} else {
- DartType type = target.bestType;
+ DartType type = _getBestType(target);
if (type != null) {
if (type.element is ClassElement) {
classElementContext = type.element as ClassElement;
@@ -1190,7 +1190,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
// Compute and use the propagated type, if it is null, then it may
// be the case that static type is some type, in which the static
// type should be used.
- targetType = target.bestType;
+ targetType = _getBestType(target);
}
if (targetType == null) {
return StaticTypeWarningCode.UNDEFINED_FUNCTION;
@@ -1392,6 +1392,22 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
/**
+ * Return the best type of the given [expression] that is to be used for
+ * type analysis.
+ */
+ DartType _getBestType(Expression expression) {
+ DartType bestType = _resolveTypeParameter(expression.bestType);
+ if (bestType is FunctionType) {
+ //
+ // All function types are subtypes of 'Function', which is itself a
+ // subclass of 'Object'.
+ //
+ bestType = _resolver.typeProvider.functionType;
+ }
+ return bestType;
+ }
+
+ /**
* Return the propagated type of the given [expression] that is to be used for
* type analysis.
*/
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698