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

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

Issue 1700523002: fixes #24507, allow known functions to be treated as strict arrows (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/task/strong/checker.dart ('k') | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c3a58396d83da95d1cac5966860aa57397a84129..6169815f12b423841c35e64a6577f4a2d985cdad 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);
}
@@ -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 {
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698