@@ -1224,6 +1224,9 @@ ProtocolConformance::getInheritedConformance(ProtocolDecl *protocol) const {
1224
1224
1225
1225
#pragma mark Protocol conformance lookup
1226
1226
void NominalTypeDecl::prepareConformanceTable () const {
1227
+ assert (!isa<ProtocolDecl>(this ) &&
1228
+ " Protocols don't have a conformance table" );
1229
+
1227
1230
if (ConformanceTable)
1228
1231
return ;
1229
1232
@@ -1292,6 +1295,10 @@ void NominalTypeDecl::prepareConformanceTable() const {
1292
1295
bool NominalTypeDecl::lookupConformance (
1293
1296
ProtocolDecl *protocol,
1294
1297
SmallVectorImpl<ProtocolConformance *> &conformances) const {
1298
+ assert (!isa<ProtocolDecl>(this ) &&
1299
+ " Self-conformances are only found by the higher-level "
1300
+ " ModuleDecl::lookupConformance() entry point" );
1301
+
1295
1302
prepareConformanceTable ();
1296
1303
return ConformanceTable->lookupConformance (
1297
1304
const_cast <NominalTypeDecl *>(this ),
@@ -1301,6 +1308,10 @@ bool NominalTypeDecl::lookupConformance(
1301
1308
1302
1309
SmallVector<ProtocolDecl *, 2 >
1303
1310
NominalTypeDecl::getAllProtocols (bool sorted) const {
1311
+ assert (!isa<ProtocolDecl>(this ) &&
1312
+ " For inherited protocols, use ProtocolDecl::inheritsFrom() or "
1313
+ " ProtocolDecl::getInheritedProtocols()" );
1314
+
1304
1315
prepareConformanceTable ();
1305
1316
SmallVector<ProtocolDecl *, 2 > result;
1306
1317
ConformanceTable->getAllProtocols (const_cast <NominalTypeDecl *>(this ), result,
0 commit comments