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

Unified Diff: pkg/analyzer/lib/src/generated/element_resolver.dart

Issue 2980383002: ignore `@proxy` in strong mode (Closed)
Patch Set: Created 3 years, 5 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 | « no previous file | 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/generated/element_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index 87aeba38555a09b0592a8c84f6bfc897169b8a85..2fa521d801390e87163e011f3cdf9bcf6e18ffee 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -759,6 +759,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
if (errorCode == null) {
return null;
}
+
if (identical(
errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION) ||
identical(errorCode,
@@ -816,10 +817,12 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
}
}
+
targetTypeName = targetType?.displayName;
ErrorCode proxyErrorCode = (generatedWithTypePropagation
? HintCode.UNDEFINED_METHOD
: StaticTypeWarningCode.UNDEFINED_METHOD);
+
_recordUndefinedNode(targetType.element, proxyErrorCode, methodName,
[methodName.name, targetTypeName]);
}
@@ -1415,11 +1418,15 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
/**
- * Return `true` if the given [element] is not a proxy. See
- * [ClassElement.isOrInheritsProxy].
+ * Return `true` if the given [element] is or inherits from a class marked
+ * with `@proxy`.
+ *
+ * See [ClassElement.isOrInheritsProxy].
*/
- bool _doesntHaveProxy(Element element) =>
- !(element is ClassElement && element.isOrInheritsProxy);
+ bool _hasProxy(Element element) =>
+ !_resolver.strongMode &&
+ element is ClassElement &&
+ element.isOrInheritsProxy;
/**
* Look for any declarations of the given [identifier] that are imported using
@@ -1638,7 +1645,8 @@ class ElementResolver extends SimpleAstVisitor<Object> {
// treat it as an executable type.
// example code: NonErrorResolverTest.
// test_invocationOfNonFunction_proxyOnFunctionClass()
- if (classElement.isProxy &&
+ if (!_resolver.strongMode &&
+ classElement.isProxy &&
type.isSubtypeOf(_resolver.typeProvider.functionType)) {
return true;
}
@@ -1873,7 +1881,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
*/
void _recordUndefinedNode(Element declaringElement, ErrorCode errorCode,
AstNode node, List<Object> arguments) {
- if (_doesntHaveProxy(declaringElement)) {
+ if (!_hasProxy(declaringElement)) {
_resolver.errorReporter.reportErrorForNode(errorCode, node, arguments);
}
}
@@ -1888,7 +1896,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
*/
void _recordUndefinedOffset(Element declaringElement, ErrorCode errorCode,
int offset, int length, List<Object> arguments) {
- if (_doesntHaveProxy(declaringElement)) {
+ if (!_hasProxy(declaringElement)) {
_resolver.errorReporter
.reportErrorForOffset(errorCode, offset, length, arguments);
}
@@ -1904,7 +1912,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
*/
void _recordUndefinedToken(Element declaringElement, ErrorCode errorCode,
Token token, List<Object> arguments) {
- if (_doesntHaveProxy(declaringElement)) {
+ if (!_hasProxy(declaringElement)) {
_resolver.errorReporter.reportErrorForToken(errorCode, token, arguments);
}
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698