Implement proper shadowing rules for qualified lookup.

This required a general reworking of the algorithm for qualified name lookup.
Originally, qualified lookup only applied to a module -- not to its exports.
This meant that "Cocoa.NSWindow" would fail, so that was changed to grovel
through all exported modules looking for decls if the top-level module didn't
provide any.

Now, we actually do a breadth-based search, stopping at each level if decls
are provided for a given name. We also now prefer scoped imports to unscoped
imports, so "import abcde" and "import struct asdf.D" will result in a
(qualified) reference to 'D' being unambiguous.

Not working yet:
 - Shadowing for unqualified lookup.
 - Shadowing by types, so that overloads from this module can merge with
   overloads from its exports.

Swift SVN r7014
This commit is contained in:
Jordan Rose
2013-08-07 22:56:49 +00:00
parent 42a109674d
commit 027565a9a9
4 changed files with 83 additions and 43 deletions

View File

@@ -215,6 +215,12 @@ public:
});
}
/// Returns true if the two access paths contain the same chain of
/// identifiers.
///
/// Source locations are ignored here.
static bool isSameAccessPath(AccessPathTy lhs, AccessPathTy rhs);
static bool classof(const DeclContext *DC) {
return DC->isModuleContext();
}