Skip to content

Commit b2e85f7

Browse files
committed
SILGen: Use a concrete conformance if we have a witness_method call on a concrete type
1 parent 0d1a0a6 commit b2e85f7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,18 +590,20 @@ class Callee {
590590
case Kind::WitnessMethod: {
591591
auto constantInfo = SGF.getConstantInfo(*constant);
592592

593-
auto proto = cast<ProtocolDecl>(
594-
Constant.getDecl()->getDeclContext());
595-
auto lookupType = getSubstFormalType()
596-
.getInput()
597-
->getRValueInstanceType()
598-
->getCanonicalType();
593+
auto proto = cast<ProtocolDecl>(Constant.getDecl()->getDeclContext());
594+
auto genericSig = cast<AbstractFunctionDecl>(Constant.getDecl())
595+
->getGenericSignature();
596+
auto subMap = genericSig->getSubstitutionMap(Substitutions);
597+
auto selfType = proto->getSelfInterfaceType()->getCanonicalType();
598+
auto lookupType = selfType.subst(subMap)->getCanonicalType();
599+
auto conformance = *subMap.lookupConformance(selfType, proto);
599600

600601
SILValue fn;
601602

602603
if (!constant->isForeign) {
604+
603605
fn = SGF.B.createWitnessMethod(
604-
Loc, lookupType, ProtocolConformanceRef(proto), *constant,
606+
Loc, lookupType, conformance, *constant,
605607
constantInfo.getSILType());
606608
} else {
607609
fn = SGF.B.createObjCMethod(Loc, borrowedSelf->getValue(),

0 commit comments

Comments
 (0)