@@ -1345,9 +1345,11 @@ void MemberLookupTable::addMembers(DeclRange members) {
1345
1345
}
1346
1346
1347
1347
void NominalTypeDecl::addedExtension (ExtensionDecl *ext) {
1348
- auto *table = LookupTable.getPointer ();
1348
+ if (!LookupTable.getInt ())
1349
+ return ;
1349
1350
1350
- if (!table) return ;
1351
+ auto *table = LookupTable.getPointer ();
1352
+ assert (table);
1351
1353
1352
1354
if (ext->hasLazyMembers ()) {
1353
1355
table->addMembers (ext->getCurrentMembersWithoutLoading ());
@@ -1361,10 +1363,12 @@ void NominalTypeDecl::addedMember(Decl *member) {
1361
1363
// If we have a lookup table, add the new member to it. If not, we'll pick up
1362
1364
// this member when we first create the table.
1363
1365
auto *vd = dyn_cast<ValueDecl>(member);
1364
- auto *table = LookupTable.getPointer ();
1365
- if (!vd || !table)
1366
+ if (!vd || !LookupTable.getInt ())
1366
1367
return ;
1367
1368
1369
+ auto *table = LookupTable.getPointer ();
1370
+ assert (table);
1371
+
1368
1372
table->addMember (vd);
1369
1373
}
1370
1374
@@ -1492,8 +1496,6 @@ void NominalTypeDecl::prepareLookupTable() {
1492
1496
if (LookupTable.getInt ())
1493
1497
return ;
1494
1498
1495
- LookupTable.setInt (true );
1496
-
1497
1499
auto *table = getLookupTable ();
1498
1500
1499
1501
// Otherwise start the first fill.
@@ -1521,6 +1523,10 @@ void NominalTypeDecl::prepareLookupTable() {
1521
1523
// Else, load all the members into the table.
1522
1524
table->addMembers (e->getMembers ());
1523
1525
}
1526
+
1527
+ // Any extensions added after this point will add their members to the
1528
+ // lookup table.
1529
+ LookupTable.setInt (true );
1524
1530
}
1525
1531
1526
1532
static TinyPtrVector<ValueDecl *>
0 commit comments