@@ -261,22 +261,19 @@ static void recordShadowedDeclsAfterSignatureMatch(
261
261
isa<ProtocolDecl>(secondDecl->getDeclContext ()))
262
262
continue ;
263
263
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)) {
272
274
shadowed.insert (secondDecl);
273
275
continue ;
274
276
}
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 ;
280
277
}
281
278
282
279
// Prefer declarations in the any module over those in the standard
0 commit comments