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

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

Issue 994253002: Add an analyzer option to properly check ".call" methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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/analyzer_impl.dart ('k') | pkg/analyzer/lib/src/generated/engine.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 4084137f578edb1b83a47e6d08784bfb8700a258..3751fe5f36b6f98a921efa2a2e599326ae8d4364 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -81,6 +81,12 @@ class ElementResolver extends SimpleAstVisitor<Object> {
bool _enableHints = false;
/**
+ * A flag indicating whether we should strictly follow the specification when
+ * generating warnings on "call" methods (fixes dartbug.com/21938).
+ */
+ bool _enableStrictCallChecks = false;
+
+ /**
* The type representing the type 'dynamic'.
*/
DartType _dynamicType;
@@ -109,6 +115,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
this._definingLibrary = _resolver.definingLibrary;
AnalysisOptions options = _definingLibrary.context.analysisOptions;
_enableHints = options.hint;
+ _enableStrictCallChecks = options.enableStrictCallChecks;
_dynamicType = _resolver.typeProvider.dynamicType;
_typeType = _resolver.typeProvider.typeType;
_subtypeManager = new SubtypeManager();
@@ -695,7 +702,8 @@ class ElementResolver extends SimpleAstVisitor<Object> {
targetType = _getStaticType(target);
}
}
- if (targetType != null &&
+ if (!_enableStrictCallChecks &&
+ targetType != null &&
targetType.isDartCoreFunction &&
methodName.name == FunctionElement.CALL_METHOD_NAME) {
// TODO(brianwilkerson) Can we ever resolve the function being
@@ -1472,10 +1480,10 @@ class ElementResolver extends SimpleAstVisitor<Object> {
* @return `true` if the given type represents an object that could be invoked
*/
bool _isExecutableType(DartType type) {
- if (type.isDynamic ||
- (type is FunctionType) ||
- type.isDartCoreFunction ||
- type.isObject) {
+ if (type.isDynamic || type is FunctionType) {
+ return true;
+ } else if (!_enableStrictCallChecks &&
+ (type.isDartCoreFunction || type.isObject)) {
return true;
} else if (type is InterfaceType) {
ClassElement classElement = type.element;
@@ -2579,7 +2587,8 @@ class ElementResolver extends SimpleAstVisitor<Object> {
staticOrPropagatedEnclosingElt is ClassElement) {
ClassElement classElement = staticOrPropagatedEnclosingElt;
InterfaceType targetType = classElement.type;
- if (targetType != null &&
+ if (!_enableStrictCallChecks &&
+ targetType != null &&
targetType.isDartCoreFunction &&
propertyName.name == FunctionElement.CALL_METHOD_NAME) {
// TODO(brianwilkerson) Can we ever resolve the function being
« no previous file with comments | « pkg/analyzer/lib/src/analyzer_impl.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698