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

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

Issue 2675963004: fix #28630, instance method tear-offs are treated as strict arrows (Closed)
Patch Set: fix sdk Created 3 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
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 7ccdcc97f08140025a5d11887d1ff2b5cd580aac..62bb922a87177129234ce3a1ad42ede429bb5bb6 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -36,21 +36,13 @@ DartType getDefiniteType(
DartType type = expression.staticType ?? DynamicTypeImpl.instance;
if (typeSystem is StrongTypeSystemImpl &&
type is FunctionType &&
- _hasStrictArrow(expression)) {
+ hasStrictArrow(expression)) {
// Remove fuzzy arrow if possible.
return typeSystem.functionTypeToConcreteType(type);
}
return type;
}
-bool isKnownFunction(Expression expression) {
- var element = _getKnownElement(expression);
- // 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;
-}
-
DartType _elementType(Element e) {
if (e == null) {
// Malformed code - just return dynamic.
@@ -105,7 +97,7 @@ FieldElement _getMemberField(
FunctionType _getMemberType(InterfaceType type, ExecutableElement member) =>
_memberTypeGetter(member)(type);
-bool _hasStrictArrow(Expression expression) {
+bool hasStrictArrow(Expression expression) {
var element = _getKnownElement(expression);
return element is FunctionElement || element is MethodElement;
}
@@ -1002,7 +994,7 @@ 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 (_hasStrictArrow(call.function)) {
+ if (hasStrictArrow(call.function)) {
return false;
}
return rules.anyParameterType(ft, (pt) => pt.isDynamic);
@@ -1090,8 +1082,8 @@ class CodeChecker extends RecursiveAstVisitor {
}
}
- if (isKnownFunction(expr)) {
- Element e = _getKnownElement(expr);
+ Element e = _getKnownElement(expr);
+ if (e is FunctionElement || e is MethodElement && e.isStatic) {
_recordMessage(
expr,
e is MethodElement
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.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