Skip to content

Commit 12f9755

Browse files
committed
NCGenerics: fix PCT's genSig minimization
We need to fold away inverses here too, so use `getRequirementsWithInverses`.
1 parent bfb4fc0 commit 12f9755

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/AST/Type.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3999,14 +3999,25 @@ CanType ProtocolCompositionType::getMinimalCanonicalType(
39993999
// represent the minimal composition.
40004000
auto sig = useDC->getGenericSignatureOfContext();
40014001
const auto Sig = Ctx.getOpenedExistentialSignature(CanTy, sig);
4002-
const auto &Reqs = Sig.getRequirements();
4002+
SmallVector<Requirement, 2> Reqs;
4003+
SmallVector<InverseRequirement, 2> Inverses;
4004+
Sig->getRequirementsWithInverses(Reqs, Inverses);
4005+
40034006
if (Reqs.size() == 1) {
40044007
return Reqs.front().getSecondType()->getCanonicalType();
40054008
}
40064009

40074010
// The set of inverses is already minimal.
40084011
auto MinimalInverses = Composition->getInverses();
40094012

4013+
#ifndef NDEBUG
4014+
// Check that the generic signature's inverses matches.
4015+
InvertibleProtocolSet genSigInverses;
4016+
for (InverseRequirement ireq : Inverses)
4017+
genSigInverses.insert(ireq.getKind());
4018+
assert(genSigInverses == MinimalInverses);
4019+
#endif
4020+
40104021
llvm::SmallVector<Type, 2> MinimalMembers;
40114022
bool MinimalHasExplicitAnyObject = false;
40124023
auto ifaceTy = Sig.getGenericParams().back();

0 commit comments

Comments
 (0)