Skip to content

Commit 412c4b1

Browse files
authored
Merge pull request #83046 from slavapestov/fix-rdar155798849
SILGen: Fix crash when default witness table entry comes from a concrete conformance
2 parents f85b2c5 + 43b8407 commit 412c4b1

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/SILGen/SILGenType.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,13 +778,14 @@ SILFunction *SILGenModule::emitProtocolWitness(
778778
// in a protocol extension, the generic signature will have an additional
779779
// generic parameter representing Self, so the generic parameters of the
780780
// class will all be shifted down by one.
781-
auto conformance = reqtSubMap.lookupConformance(M.getASTContext().TheSelfType,
782-
origConformance.getProtocol())
783-
.mapConformanceOutOfContext();
784-
ASSERT(conformance.isAbstract() == origConformance.isAbstract());
785-
781+
auto conformance = origConformance;
786782
ProtocolConformance *manglingConformance = nullptr;
787783
if (conformance.isConcrete()) {
784+
conformance = reqtSubMap.lookupConformance(M.getASTContext().TheSelfType,
785+
origConformance.getProtocol())
786+
.mapConformanceOutOfContext();
787+
ASSERT(!conformance.isAbstract());
788+
788789
manglingConformance = conformance.getConcrete();
789790
if (auto *inherited = dyn_cast<InheritedProtocolConformance>(manglingConformance)) {
790791
manglingConformance = inherited->getInheritedConformance();

test/SILGen/protocol_resilience.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@ public protocol ResilientAssocTypes {
259259
associatedtype AssocType: P = ConformsToP
260260
}
261261

262+
// rdar://155798849 - This is a pointless protocol and conformance but it shouldn't crash
263+
public protocol SillyP: SillyC {
264+
func f()
265+
}
266+
267+
public class SillyC: SillyP {
268+
public func f() {}
269+
}
270+
262271
// CHECK-LABEL: sil_default_witness_table P {
263272
// CHECK-NEXT: }
264273

0 commit comments

Comments
 (0)