When performing module lookups, respect the resolution mode when deciding whether or not to validate any found declarations.

Doing so prevents another common source of stack overflows in the validator, and addresses crash suite scenarios 002 and 004.
(rdar://problem/18232499, rdar://problem/18232668)

Swift SVN r22104
This commit is contained in:
Joe Pamer
2014-09-18 22:51:34 +00:00
parent b5680b24ae
commit b2891be810
3 changed files with 12 additions and 6 deletions

View File

@@ -162,8 +162,14 @@ static void lookupInModule(Module *module, Module::AccessPathTy accessPath,
if (respectAccessControl) {
auto newEndIter = std::remove_if(localDecls.begin(), localDecls.end(),
[=](ValueDecl *VD) {
if (typeResolver)
typeResolver->resolveDeclSignature(VD);
if (typeResolver) {
// Do not resolve values in a type context - doing so could potentially
// lead to an infinitely recursive validation loop.
if ((resolutionKind != ResolutionKind::TypesOnly) ||
dyn_cast<TypeDecl>(VD)) {
typeResolver->resolveDeclSignature(VD);
}
}
if (!VD->hasAccessibility())
return false;
return !VD->isAccessibleFrom(moduleScopeContext);