mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user