| 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..ceaa4bfceba38a32e15e992fe379d763f8c21b48 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}) {
|
| 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) {
|
| @@ -936,10 +939,6 @@ class CodeChecker extends RecursiveAstVisitor {
|
| }
|
| }
|
|
|
| - // Produce a coercion which coerces something of type fromT
|
| - // to something of type toT.
|
| - // Returns the error coercion if the types cannot be coerced
|
| - // according to our current criteria.
|
| DartType _getStaticType(Expression expr) {
|
| DartType t = expr.staticType ?? DynamicTypeImpl.instance;
|
|
|
| @@ -985,14 +984,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);
|
| }
|
|
|
|
|