Skip to content

Commit f567b8f

Browse files
committed
AST: Use new module shadowing rule for qualified lookups too
1 parent da8ef33 commit f567b8f

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/AST/NameLookup.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,22 +261,19 @@ static void recordShadowedDeclsAfterSignatureMatch(
261261
isa<ProtocolDecl>(secondDecl->getDeclContext()))
262262
continue;
263263

264-
// Prefer declarations in the current module over those in another
265-
// module.
266-
// FIXME: This is a hack. We should query a (lazily-built, cached)
267-
// module graph to determine shadowing.
268-
if ((firstModule == curModule) != (secondModule == curModule)) {
269-
// If the first module is the current module, the second declaration
270-
// is shadowed by the first.
271-
if (firstModule == curModule) {
264+
// [Backward compatibility] For members of types, the general module
265+
// shadowing check is performed after unavailable candidates have
266+
// already been dropped.
267+
if (firstModule != secondModule &&
268+
!firstDecl->getDeclContext()->isModuleScopeContext() &&
269+
!secondDecl->getDeclContext()->isModuleScopeContext()) {
270+
if (imports.isShadowedBy(firstModule, secondModule, dc)) {
271+
shadowed.insert(firstDecl);
272+
break;
273+
} else if (imports.isShadowedBy(secondModule, firstModule, dc)) {
272274
shadowed.insert(secondDecl);
273275
continue;
274276
}
275-
276-
// Otherwise, the first declaration is shadowed by the second. There is
277-
// no point in continuing to compare the first declaration to others.
278-
shadowed.insert(firstDecl);
279-
break;
280277
}
281278

282279
// Prefer declarations in the any module over those in the standard

0 commit comments

Comments
 (0)