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

Unified Diff: pkg/analyzer/lib/src/task/strong/checker.dart

Issue 2252183002: Fix calling object methods and properties on function types (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix calling object methods and properties on function types Created 4 years, 4 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
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 57b1cc2a445c03b588bd8e8104c409cd22256d59..c8dc14bd6fec6b6b26a2e7e4194b79c14843a91d 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -554,7 +554,7 @@ class CodeChecker extends RecursiveAstVisitor {
visitMethodInvocation(MethodInvocation node) {
var target = node.realTarget;
var element = node.methodName.staticElement;
- if (element == null && !_isObjectMethod(node, node.methodName)) {
+ if (element == null && !typeProvider.isObjectMethod(node.methodName)) {
_recordDynamicInvoke(node, target);
// Mark the tear-off as being dynamic, too. This lets us distinguish
@@ -768,7 +768,7 @@ class CodeChecker extends RecursiveAstVisitor {
}
void _checkFieldAccess(AstNode node, AstNode target, SimpleIdentifier field) {
- if (field.staticElement == null && !_isObjectProperty(target, field)) {
+ if (field.staticElement == null && !typeProvider.isObjectProperty(field)) {
_recordDynamicInvoke(node, target);
}
node.visitChildren(this);
@@ -908,7 +908,8 @@ class CodeChecker extends RecursiveAstVisitor {
}
void _checkUnary(
- /*PrefixExpression|PostfixExpression*/ node, Element element) {
+ /*PrefixExpression|PostfixExpression*/ node,
+ Element element) {
var op = node.operator;
if (op.isUserDefinableOperator ||
op.type == TokenType.PLUS_PLUS ||
@@ -1011,21 +1012,6 @@ class CodeChecker extends RecursiveAstVisitor {
return rules.anyParameterType(ft, (pt) => pt.isDynamic);
}
- bool _isObjectGetter(Expression target, SimpleIdentifier id) {
- PropertyAccessorElement element =
- typeProvider.objectType.element.getGetter(id.name);
- return (element != null && !element.isStatic);
- }
-
- bool _isObjectMethod(Expression target, SimpleIdentifier id) {
- MethodElement element = typeProvider.objectType.element.getMethod(id.name);
- return (element != null && !element.isStatic);
- }
-
- bool _isObjectProperty(Expression target, SimpleIdentifier id) {
- return _isObjectGetter(target, id) || _isObjectMethod(target, id);
- }
-
void _recordDynamicInvoke(AstNode node, Expression target) {
_recordMessage(node, StrongModeCode.DYNAMIC_INVOKE, [node]);
// TODO(jmesserly): we may eventually want to record if the whole operation

Powered by Google App Engine
This is Rietveld 408576698