mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Make operator methods to module-scope name lookup.
Fixes the operator name lookup issue in <rdar://problem/15715996>. Swift SVN r11724
This commit is contained in:
@@ -252,6 +252,9 @@ bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
case index_block::CLASS_MEMBERS:
|
||||
ClassMembersByName = readDeclTable(scratch, blobData);
|
||||
break;
|
||||
case index_block::OPERATOR_METHODS:
|
||||
OperatorMethodDecls = readDeclTable(scratch, blobData);
|
||||
break;
|
||||
default:
|
||||
// Unknown index kind, which this version of the compiler won't use.
|
||||
break;
|
||||
@@ -530,16 +533,26 @@ void ModuleFile::lookupValue(Identifier name,
|
||||
SmallVectorImpl<ValueDecl*> &results) {
|
||||
PrettyModuleFileDeserialization stackEntry(*this);
|
||||
|
||||
if (!TopLevelDecls)
|
||||
return;
|
||||
if (TopLevelDecls) {
|
||||
// Find top-level declarations with the given name.
|
||||
auto iter = TopLevelDecls->find(name);
|
||||
if (iter != TopLevelDecls->end()) {
|
||||
for (auto item : *iter) {
|
||||
auto VD = cast<ValueDecl>(getDecl(item.second));
|
||||
results.push_back(VD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto iter = TopLevelDecls->find(name);
|
||||
if (iter == TopLevelDecls->end())
|
||||
return;
|
||||
|
||||
for (auto item : *iter) {
|
||||
auto VD = cast<ValueDecl>(getDecl(item.second));
|
||||
results.push_back(VD);
|
||||
// If the name is an operator name, also look for operator methods.
|
||||
if (name.isOperator() && OperatorMethodDecls) {
|
||||
auto iter = OperatorMethodDecls->find(name);
|
||||
if (iter != OperatorMethodDecls->end()) {
|
||||
for (auto item : *iter) {
|
||||
auto VD = cast<ValueDecl>(getDecl(item.second));
|
||||
results.push_back(VD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user