Skip to content

Commit ab0d531

Browse files
committed
SIL: Fix SILFunctionType::getDefaultWitnessMethodProtocol() for class-constrained 'self' archetypes
Right now witness_method functions either have a concrete type as the 'self' argument or a type parameter with a single protocol conformance constraint. Soon we will also have class-constrained archetypes here, so tweak the assertion here to detect this case.
1 parent da87b83 commit ab0d531

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/SIL/SILFunctionType.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ SILFunctionType::getDefaultWitnessMethodProtocol(ModuleDecl &M) const {
100100
assert(getRepresentation() == SILFunctionTypeRepresentation::WitnessMethod);
101101
auto selfTy = getSelfInstanceType();
102102
if (auto paramTy = dyn_cast<GenericTypeParamType>(selfTy)) {
103+
auto superclass = GenericSig->getSuperclassBound(paramTy, M);
104+
if (superclass)
105+
return nullptr;
103106
assert(paramTy->getDepth() == 0 && paramTy->getIndex() == 0);
104107
auto protos = GenericSig->getConformsTo(paramTy, M);
105108
assert(protos.size() == 1);

0 commit comments

Comments
 (0)