Index: pkg/analyzer/lib/src/task/strong/checker.dart |
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart |
index c074b7938c7aec46eabdae9302f15523b0dd0659..1cd23fbd91e5a94c364e31640b1be25f9d8b549e 100644 |
--- a/pkg/analyzer/lib/src/task/strong/checker.dart |
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart |
@@ -21,8 +21,11 @@ import 'package:analyzer/src/generated/type_system.dart'; |
import 'ast_properties.dart'; |
-bool isKnownFunction(Expression expression) { |
+bool isKnownFunction(Expression expression, {bool instanceMethods: false}) { |
Jennifer Messerly
2016/08/04 15:57:40
Of funny, I wondered what was up with this differe
Leaf
2016/08/04 16:22:01
Do you have an example of something that is change
Jennifer Messerly
2016/08/04 18:27:37
yeah, that was my thought, it might make more sens
|
Element element = null; |
+ if (expression is ParenthesizedExpression) { |
+ expression = (expression as ParenthesizedExpression).expression; |
+ } |
if (expression is FunctionExpression) { |
return true; |
} else if (expression is PropertyAccess) { |
@@ -30,10 +33,10 @@ bool isKnownFunction(Expression expression) { |
} else if (expression is Identifier) { |
element = expression.staticElement; |
} |
-// First class functions and static methods, where we know the original |
-// declaration, will have an exact type, so we know a downcast will fail. |
+ // First class functions and static methods, where we know the original |
+ // declaration, will have an exact type, so we know a downcast will fail. |
return element is FunctionElement || |
- element is MethodElement && element.isStatic; |
+ element is MethodElement && (instanceMethods || element.isStatic); |
} |
DartType _elementType(Element e) { |
@@ -985,14 +988,9 @@ class CodeChecker extends RecursiveAstVisitor { |
// a dynamic parameter type requires a dynamic call in general. |
// However, as an optimization, if we have an original definition, we know |
// dynamic is reified as Object - in this case a regular call is fine. |
- if (call is SimpleIdentifier) { |
- var element = call.staticElement; |
- if (element is FunctionElement || element is MethodElement) { |
- // An original declaration. |
- return false; |
- } |
+ if (isKnownFunction(call, instanceMethods: true)) { |
+ return false; |
} |
- |
return rules.anyParameterType(ft, (pt) => pt.isDynamic); |
} |