Index: pkg/analyzer/lib/src/task/strong/info.dart |
diff --git a/pkg/analyzer/lib/src/task/strong/info.dart b/pkg/analyzer/lib/src/task/strong/info.dart |
index 82954395b981c280bf19aa23b365d4ea816a45c9..ec5b09c644fd2a697a11b191f11f5dfd144871ea 100644 |
--- a/pkg/analyzer/lib/src/task/strong/info.dart |
+++ b/pkg/analyzer/lib/src/task/strong/info.dart |
@@ -138,16 +138,7 @@ abstract class DownCast extends CoercionInfo { |
} |
} |
- Element element = null; |
- if (expression is PropertyAccess) { |
- element = expression.propertyName.staticElement; |
- } 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. |
- if (element is FunctionElement || |
- element is MethodElement && element.isStatic) { |
+ if (StaticInfo.isKnownFunction(expression)) { |
return new StaticTypeError(rules, expression, toT, reason: reason); |
} |
@@ -551,6 +542,19 @@ abstract class StaticInfo { |
// TODO(jmesserly): review the usage of error codes. We probably want our own, |
// as well as some DDC specific [ErrorType]s. |
ErrorCode toErrorCode(); |
+ |
+ static bool isKnownFunction(Expression expression) { |
+ Element element = null; |
+ if (expression is PropertyAccess) { |
+ element = expression.propertyName.staticElement; |
+ } 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. |
+ return element is FunctionElement || |
+ element is MethodElement && element.isStatic; |
+ } |
} |
class StaticTypeError extends StaticError { |