mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make LookupConformanceFn callbacks return Optional<ProtocolConformanceRef>.
NFC yet, but this is a step toward centralizing error handling policy for failed conformance lookups instead of leaving it ad-hoc.
This commit is contained in:
@@ -315,9 +315,10 @@ getSubstitutions(ModuleDecl &mod,
|
||||
for (auto req: reqs) {
|
||||
assert(req.getKind() == RequirementKind::Conformance);
|
||||
auto protoType = req.getSecondType()->castTo<ProtocolType>();
|
||||
// TODO: Error handling for failed conformance lookup.
|
||||
currentConformances.push_back(
|
||||
lookupConformance(depTy->getCanonicalType(), currentReplacement,
|
||||
protoType));
|
||||
*lookupConformance(depTy->getCanonicalType(), currentReplacement,
|
||||
protoType));
|
||||
}
|
||||
|
||||
// Add it to the final substitution list.
|
||||
@@ -336,9 +337,9 @@ getSubstitutions(ModuleDecl &mod,
|
||||
SmallVectorImpl<Substitution> &result) const {
|
||||
auto lookupConformanceFn =
|
||||
[&](CanType original, Type replacement, ProtocolType *protoType)
|
||||
-> ProtocolConformanceRef {
|
||||
return *subMap.lookupConformance(original, protoType->getDecl());
|
||||
};
|
||||
-> Optional<ProtocolConformanceRef> {
|
||||
return subMap.lookupConformance(original, protoType->getDecl());
|
||||
};
|
||||
|
||||
getSubstitutions(mod, subMap.getMap(), lookupConformanceFn, result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user