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

Unified Diff: pkg/analyzer/lib/src/generated/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/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 4a70c667c78425be69ed028fa4618aa25b3be919..0640fe48888a43ac28f587473b9d43d683151fca 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -562,6 +562,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
}
return element.isDeprecated;
}
+
if (!inDeprecatedMember && isDeprecated(element)) {
String displayName = element.displayName;
if (element is ConstructorElement) {
@@ -971,6 +972,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
}
return false;
}
+
FunctionBody body = node.body;
if (body is ExpressionFunctionBody) {
if (isNonObjectNoSuchMethodInvocation(body.expression)) {
@@ -1916,7 +1918,7 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitExportDirective(ExportDirective node) {
ExportElement exportElement = node.element;
- if (exportElement != null) {
+ if (exportElement != null && exportElement.context.exists(node.source)) {
// The element is null when the URI is invalid
LibraryElement library = exportElement.exportedLibrary;
if (library != null) {
@@ -1960,8 +1962,9 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitImportDirective(ImportDirective node) {
ImportElement importElement = node.element;
- if (importElement != null) {
- // The element is null when the URI is invalid
+ if (importElement != null && importElement.context.exists(node.source)) {
+ // The element is null when the URI is invalid, but not when the URI is
+ // valid but refers to a non-existent file.
LibraryElement library = importElement.importedLibrary;
if (library != null) {
for (Combinator combinator in node.combinators) {
@@ -2547,8 +2550,10 @@ class DeclarationResolver extends RecursiveAstVisitor<Object>
String nameOfMethod = methodName.name;
if (property == null) {
String elementName = nameOfMethod == '-' &&
- node.parameters != null &&
- node.parameters.parameters.isEmpty ? 'unary-' : nameOfMethod;
+ node.parameters != null &&
+ node.parameters.parameters.isEmpty
+ ? 'unary-'
+ : nameOfMethod;
_enclosingExecutable = _findWithNameAndOffset(_enclosingClass.methods,
methodName, elementName, methodName.offset);
_expectedElements.remove(_enclosingExecutable);
@@ -3963,6 +3968,7 @@ class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor {
}
return false;
}
+
AstNode parent = identifier.parent;
if (parent is MethodInvocation && parent.methodName == identifier) {
return recordIfTargetIsPrefixElement(parent.target);
@@ -4439,11 +4445,13 @@ class ImportsVerifier {
int length = _unusedImports.length;
for (int i = 0; i < length; i++) {
ImportDirective unusedImport = _unusedImports[i];
- // Check that the import isn't dart:core
+ // Check that the imported URI exists and isn't dart:core
ImportElement importElement = unusedImport.element;
if (importElement != null) {
LibraryElement libraryElement = importElement.importedLibrary;
- if (libraryElement != null && libraryElement.isDartCore) {
+ if (libraryElement == null ||
+ libraryElement.isDartCore ||
+ !importElement.context.exists(unusedImport.source)) {
continue;
}
}
@@ -8542,6 +8550,11 @@ class TypeNameResolver {
node.type = voidType;
return;
}
+ if (nameScope.shouldIgnoreUndefined(typeName)) {
+ typeName.staticType = undefinedType;
+ node.type = undefinedType;
+ return;
+ }
//
// If not, the look to see whether we might have created the wrong AST
// structure for a constructor name. If so, fix the AST structure and then
@@ -8558,6 +8571,11 @@ class TypeNameResolver {
SimpleIdentifier prefix = prefixedIdentifier.prefix;
element = nameScope.lookup(prefix, definingLibrary);
if (element is PrefixElement) {
+ if (nameScope.shouldIgnoreUndefined(typeName)) {
+ typeName.staticType = undefinedType;
+ node.type = undefinedType;
+ return;
+ }
AstNode grandParent = parent.parent;
if (grandParent is InstanceCreationExpression &&
grandParent.isConst) {
@@ -8592,6 +8610,11 @@ class TypeNameResolver {
}
}
}
+ if (nameScope.shouldIgnoreUndefined(typeName)) {
+ typeName.staticType = undefinedType;
+ node.type = undefinedType;
+ return;
+ }
}
// check element
bool elementValid = element is! MultiplyDefinedElement;
@@ -10413,7 +10436,7 @@ class TypeResolverVisitor extends ScopedVisitor {
Identifier name = typeName.name;
if (name.name == Keyword.DYNAMIC.syntax) {
errorReporter.reportErrorForNode(dynamicTypeError, name, [name.name]);
- } else {
+ } else if (!nameScope.shouldIgnoreUndefined(name)) {
errorReporter.reportErrorForNode(nonTypeError, name, [name.name]);
}
return null;

Powered by Google App Engine
This is Rietveld 408576698