Protect the operator/precedencegroup lookup code against modules that

import themselves.

It's not clear to me whether this situation is really intended, but
this does fix build modules with this strange situation.
This commit is contained in:
John McCall
2016-07-27 12:34:36 -07:00
parent 79bc7f93be
commit cfd9b83d39
2 changed files with 17 additions and 0 deletions

View File

@@ -1008,8 +1008,13 @@ lookupOperatorDeclForName(const FileUnit &File, SourceLoc Loc, Identifier Name,
// Record whether they come from re-exported modules.
// FIXME: We ought to prefer operators elsewhere in this module before we
// check imports.
auto ownModule = SF.getParentModule();
ImportedOperatorsMap<OP_DECL> importedOperators;
for (auto &imported : SourceFile::Impl::getImportsForSourceFile(SF)) {
// Protect against source files that contrive to import their own modules.
if (imported.first.second == ownModule)
continue;
bool isExported =
imported.second.contains(SourceFile::ImportFlags::Exported);
if (!includePrivate && !isExported)