mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[cxx-interop][serialization] resolve x-refs to instantiated/synthesized C++ iterator conformance operators
These x-refs might not be resolvable using regular lookup from the 'std' module as they could be instantiated/synthesized by the clang importer. Augment the lookup logic in that case to try clang importer lookup logic that is used during the conformance to the C++ iterator protocol.
This commit is contained in:
@@ -2039,6 +2039,26 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
|
||||
}
|
||||
filterValues(filterTy, nullptr, nullptr, isType, inProtocolExt,
|
||||
importedFromClang, isStatic, std::nullopt, values);
|
||||
if (values.empty() && importedFromClang && name.isOperator() && filterTy) {
|
||||
// This could be a Clang-importer instantiated/synthesized conformance
|
||||
// operator, like '==', '-' or '+=', that are required for conformances to
|
||||
// one of the Cxx iterator protocols. Attempt to resolve it using clang importer
|
||||
// lookup logic for the given type instead of looking for it in the module.
|
||||
if (auto *fty = dyn_cast<AnyFunctionType>(filterTy.getPointer())) {
|
||||
if (fty->getNumParams()) {
|
||||
assert(fty->getNumParams() <= 2);
|
||||
auto p = fty->getParams()[0].getParameterType();
|
||||
if (auto sty = dyn_cast<NominalType>(p.getPointer())) {
|
||||
if (auto *op = importer::getImportedMemberOperator(
|
||||
name, sty->getDecl(),
|
||||
fty->getNumParams() > 1
|
||||
? fty->getParams()[1].getParameterType()
|
||||
: std::optional<Type>{}))
|
||||
values.push_back(op);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user