Change extension lookup so that decls in the current module don't always shadow imports, which should be enough to unblock demo work. <rdar://problem/11492474>.

Swift SVN r1950
This commit is contained in:
Eli Friedman
2012-05-23 03:16:20 +00:00
parent 3d11eebb69
commit 8d985dcc38

View File

@@ -233,8 +233,7 @@ void Module::lookupGlobalValue(Identifier Name, NLKind LookupKind,
// Do a local lookup within the current module.
lookupValue(AccessPathTy(), Name, LookupKind, Result);
// If we get any hits, we're done. Also, the builtin module never has
// imports, so it is always done at this point.
// The builtin module has no imports.
if (isa<BuiltinModule>(this)) return;
TranslationUnit &TU = *cast<TranslationUnit>(this);
@@ -281,17 +280,17 @@ static void DoGlobalExtensionLookup(Type BaseType, Identifier Name,
}
}
if (BaseModule == CurModule) {
for (ValueDecl *VD : BaseMembers) {
if (VD->getName() == Name) {
Result.push_back(VD);
for (ValueDecl *VD : BaseMembers) {
if (VD->getName() == Name) {
Result.push_back(VD);
if (BaseModule == CurModule) {
CurModuleHasMetatype |= isa<MetaTypeType>(VD->getType());
}
}
}
// If we found anything in local extensions, they shadow imports.
if (!Result.empty() || isa<BuiltinModule>(CurModule)) return;
// The builtin module has no imports.
if (isa<BuiltinModule>(CurModule)) return;
TranslationUnit &TU = *cast<TranslationUnit>(CurModule);
@@ -312,12 +311,6 @@ static void DoGlobalExtensionLookup(Type BaseType, Identifier Name,
}
}
}
for (ValueDecl *VD : BaseMembers) {
if (VD->getName() == Name &&
!(CurModuleHasMetatype && isa<MetaTypeType>(VD->getType())))
Result.push_back(VD);
}
}
/// lookupGlobalExtensionMethods - Lookup the extensions members for the