Simplify the interface to Module::lookupConformance.

Rather than returning a weird PointerIntPair, return an
Optional<ProtocolConformanceRef>. NFC
This commit is contained in:
Doug Gregor
2016-03-15 22:07:14 -07:00
parent b051c5a70f
commit a31edf53d0
15 changed files with 122 additions and 175 deletions

View File

@@ -1312,7 +1312,9 @@ getConformanceOfReplacement(Parser &P, Type subReplacement,
ProtocolDecl *proto) {
auto conformance = P.SF.getParentModule()->lookupConformance(
subReplacement, proto, nullptr);
return conformance.getPointer();
if (conformance && conformance->isConcrete())
return conformance->getConcrete();
return nullptr;
}
static bool isImpliedBy(ProtocolDecl *proto, ArrayRef<ProtocolDecl*> derived) {
@@ -2845,11 +2847,11 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB) {
if (!isa<ArchetypeType>(LookupTy)) {
auto lookup = P.SF.getParentModule()->lookupConformance(
LookupTy, proto, nullptr);
if (lookup.getInt() != ConformanceKind::Conforms) {
if (!lookup) {
P.diagnose(TyLoc, diag::sil_witness_method_type_does_not_conform);
return true;
}
Conformance = ProtocolConformanceRef(lookup.getPointer());
Conformance = ProtocolConformanceRef(*lookup);
}
ResultVal = B.createWitnessMethod(InstLoc, LookupTy, Conformance, Member,
@@ -4046,17 +4048,15 @@ static NormalProtocolConformance *parseNormalProtocolConformance(Parser &P,
P.Context);
auto lookup = P.SF.getParentModule()->lookupConformance(
lookupTy, proto, nullptr);
if (!lookup.getPointer()) {
if (!lookup) {
P.diagnose(KeywordLoc, diag::sil_witness_protocol_conformance_not_found);
return nullptr;
}
NormalProtocolConformance *theConformance =
dyn_cast<NormalProtocolConformance>(lookup.getPointer());
if (!theConformance) {
if (!lookup->isConcrete()) {
P.diagnose(KeywordLoc, diag::sil_witness_protocol_conformance_not_found);
return nullptr;
}
return theConformance;
return lookup->getConcrete()->getRootNormalConformance();
}
/// Parse the substitution list for a specialized conformance.