Skip to content

Commit 1023b1c

Browse files
committed
ClangImporter: Fix finishSignatureConformances() to support associated types
1 parent 052ff42 commit 1023b1c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7402,12 +7402,20 @@ static void finishSignatureConformances(
74027402
if (req.getKind() != RequirementKind::Conformance)
74037403
continue;
74047404

7405-
assert(req.getFirstType()->isEqual(proto->getSelfInterfaceType()));
7405+
Type substTy;
7406+
auto origTy = req.getFirstType();
7407+
if (origTy->isEqual(proto->getSelfInterfaceType())) {
7408+
substTy = conformance->getType();
7409+
} else {
7410+
auto *depMemTy = origTy->castTo<DependentMemberType>();
7411+
assert(depMemTy->getBase()->isEqual(proto->getSelfInterfaceType()));
7412+
substTy = conformance->getTypeWitness(depMemTy->getAssocType(),
7413+
/*resolver=*/nullptr);
7414+
}
74067415
auto reqProto = req.getSecondType()->castTo<ProtocolType>()->getDecl();
74077416

74087417
ModuleDecl *M = conformance->getDeclContext()->getParentModule();
7409-
auto reqConformance = M->lookupConformance(conformance->getType(),
7410-
reqProto);
7418+
auto reqConformance = M->lookupConformance(substTy, reqProto);
74117419
assert(reqConformance && reqConformance->isConcrete() &&
74127420
"required conformance not found");
74137421
reqConformances.push_back(*reqConformance);

0 commit comments

Comments
 (0)