Sema: Use protocol generic signature instead of requirement signature to check type witnesses

Regression was introduced by
ec60c88412.

I don't have a reduced test case, but this solves
<rdar://problem/32668454>.
This commit is contained in:
Slava Pestov
2017-06-15 22:57:38 -07:00
parent 61b7effbb2
commit aa84dc604f

View File

@@ -3291,17 +3291,17 @@ static CheckTypeWitnessResult checkTypeWitness(TypeChecker &tc, DeclContext *dc,
AssociatedTypeDecl *assocType,
Type type) {
auto *moduleDecl = dc->getParentModule();
auto *reqtSig = assocType->getProtocol()->getRequirementSignature();
auto *genericSig = proto->getGenericSignature();
auto *depTy = DependentMemberType::get(proto->getSelfInterfaceType(),
assocType);
if (auto superclass = reqtSig->getSuperclassBound(depTy, *moduleDecl)) {
if (auto superclass = genericSig->getSuperclassBound(depTy, *moduleDecl)) {
if (!superclass->isExactSuperclassOf(type))
return superclass->getAnyNominal();
}
// Check protocol conformances.
for (auto reqProto : reqtSig->getConformsTo(depTy, *moduleDecl)) {
for (auto reqProto : genericSig->getConformsTo(depTy, *moduleDecl)) {
if (!tc.conformsToProtocol(type, reqProto, dc, None))
return reqProto;