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

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

Issue 2226613004: Suppress follow-on errors when a file is imported with either a prefix or a show clause (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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/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 029b5c6759abc85ffcba5d66c3c6141a90e70b38..87d3fd2d5a0d680c9795f7616e91b167adf6365c 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -711,6 +711,15 @@ class ElementResolver extends SimpleAstVisitor<Object> {
// Then check for error conditions.
//
ErrorCode errorCode = _checkForInvocationError(target, true, staticElement);
+ if (errorCode != null &&
+ target is SimpleIdentifier &&
+ target.staticElement is PrefixElement) {
+ Identifier functionName =
+ new PrefixedIdentifierImpl.temp(target, methodName);
+ if (_resolver.nameScope.shouldIgnoreUndefined(functionName)) {
+ return null;
+ }
+ }
bool generatedWithTypePropagation = false;
if (_enableHints && errorCode == null && staticElement == null) {
// The method lookup may have failed because there were multiple
@@ -750,8 +759,10 @@ class ElementResolver extends SimpleAstVisitor<Object> {
identical(errorCode,
CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT) ||
identical(errorCode, StaticTypeWarningCode.UNDEFINED_FUNCTION)) {
- _resolver.errorReporter
- .reportErrorForNode(errorCode, methodName, [methodName.name]);
+ if (!_resolver.nameScope.shouldIgnoreUndefined(methodName)) {
+ _resolver.errorReporter
+ .reportErrorForNode(errorCode, methodName, [methodName.name]);
+ }
} else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) {
String targetTypeName;
if (target == null) {
@@ -817,6 +828,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
return type;
}
+
DartType targetType = getSuperType(_getStaticType(target));
String targetTypeName = targetType?.name;
_resolver.errorReporter.reportErrorForNode(
@@ -894,6 +906,9 @@ class ElementResolver extends SimpleAstVisitor<Object> {
"${node.identifier.name}=", node.identifier.offset - 1)));
element = _resolver.nameScope.lookup(setterName, _definingLibrary);
}
+ if (element == null && _resolver.nameScope.shouldIgnoreUndefined(node)) {
+ return null;
+ }
if (element == null) {
if (identifier.inSetterContext()) {
_resolver.errorReporter.reportErrorForNode(
@@ -1112,7 +1127,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT,
node,
[_resolver.enclosingFunction.displayName]);
- } else {
+ } else if (!_resolver.nameScope.shouldIgnoreUndefined(node)) {
_recordUndefinedNode(_resolver.enclosingClass,
StaticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]);
}
@@ -1177,6 +1192,15 @@ class ElementResolver extends SimpleAstVisitor<Object> {
name.staticElement = element;
}
node.staticElement = element;
+ // TODO(brianwilkerson) Defer this check until we know there's an error (by
+ // in-lining _resolveArgumentsToFunction below).
+ ClassDeclaration declaration =
+ node.getAncestor((AstNode node) => node is ClassDeclaration);
+ Identifier superclassName = declaration.extendsClause?.superclass?.name;
+ if (superclassName != null &&
+ _resolver.nameScope.shouldIgnoreUndefined(superclassName)) {
+ return null;
+ }
ArgumentList argumentList = node.argumentList;
List<ParameterElement> parameters = _resolveArgumentsToFunction(
isInConstConstructor, argumentList, element);
@@ -1212,7 +1236,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
* error code that should be reported, or `null` if no error should be
* reported. The [target] is the target of the invocation, or `null` if there
* was no target. The flag [useStaticContext] should be `true` if the
- * invocation is in a static constant (does not have access to instance state.
+ * invocation is in a static constant (does not have access to instance state).
*/
ErrorCode _checkForInvocationError(
Expression target, bool useStaticContext, Element element) {
@@ -1283,6 +1307,10 @@ class ElementResolver extends SimpleAstVisitor<Object> {
targetType = _getBestType(target);
}
if (targetType == null) {
+ if (target is Identifier &&
+ _resolver.nameScope.shouldIgnoreUndefined(target)) {
+ return null;
+ }
return StaticTypeWarningCode.UNDEFINED_FUNCTION;
} else if (!targetType.isDynamic && !targetType.isBottom) {
// Proxy-conditional warning, based on state of

Powered by Google App Engine
This is Rietveld 408576698