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

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

Issue 1149953005: Issue 23518. Match prefixes of prefixed types. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/generated/incremental_resolver_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/incremental_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/incremental_resolver.dart b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
index c22ec67a97c9ab6b6f71b84e0d6b6d9111fc86a5..82165c02118c4decad815374878f634a50ff0ca6 100644
--- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
@@ -571,7 +571,7 @@ class DeclarationMatcher extends RecursiveAstVisitor {
}
void _assertSameType(TypeName node, DartType type) {
- // no return type == dynamic
+ // no type == dynamic
if (node == null) {
return _assertTrue(type == null || type.isDynamic);
}
@@ -579,14 +579,18 @@ class DeclarationMatcher extends RecursiveAstVisitor {
return _assertTrue(false);
}
// prepare name
+ SimpleIdentifier prefixIdentifier = null;
Identifier nameIdentifier = node.name;
if (nameIdentifier is PrefixedIdentifier) {
- nameIdentifier = (nameIdentifier as PrefixedIdentifier).identifier;
+ PrefixedIdentifier prefixedIdentifier = nameIdentifier;
+ prefixIdentifier = prefixedIdentifier.prefix;
+ nameIdentifier = prefixedIdentifier.identifier;
}
String nodeName = nameIdentifier.name;
// check specific type kinds
if (type is ParameterizedType) {
_assertEquals(nodeName, type.name);
+ _assertElementVisibleWithPrefix(prefixIdentifier, type.element);
// check arguments
TypeArgumentList nodeArgumentList = node.typeArguments;
List<DartType> typeArguments = type.typeArguments;
@@ -614,6 +618,29 @@ class DeclarationMatcher extends RecursiveAstVisitor {
}
}
+ /**
+ * Asserts that there is an import with the same prefix as the given
+ * [prefixNode], which exposes the given [element].
+ */
+ void _assertElementVisibleWithPrefix(
+ SimpleIdentifier prefixNode, Element element) {
+ if (prefixNode == null) {
+ return;
+ }
+ String prefixName = prefixNode.name;
+ for (ImportElement import in _enclosingLibrary.imports) {
+ if (import.prefix != null && import.prefix.name == prefixName) {
+ Namespace namespace =
+ new NamespaceBuilder().createImportNamespaceForDirective(import);
+ Iterable<Element> visibleElements = namespace.definedNames.values;
+ if (visibleElements.contains(element)) {
+ return;
+ }
+ }
+ }
+ _assertTrue(false);
+ }
+
void _assertSameTypeParameter(
TypeParameter node, TypeParameterElement element) {
_assertSameType(node.bound, element.bound);
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/incremental_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698