Skip to content

Commit 1beed09

Browse files
authored
[Serialization] Remove bogus limitation on fast path (#17336)
The meaning of this bit changed way back in 3639343, but I forgot to update this fast path. Thanks to this code falling back to the slow path if things didn't work out, there wasn't a correctness issue here, but it might have been doing more work than necessary.
1 parent 26325e8 commit 1beed09

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,10 +1455,10 @@ ModuleFile::resolveCrossReference(ModuleDecl *baseModule, uint32_t pathLen) {
14551455
// members of the parent type.
14561456
IdentifierID IID;
14571457
IdentifierID privateDiscriminator;
1458-
bool onlyInNominal = false;
14591458
bool importedFromClang = false;
14601459
XRefTypePathPieceLayout::readRecord(scratch, IID, privateDiscriminator,
1461-
onlyInNominal, importedFromClang);
1460+
/*inProtocolExt*/None,
1461+
importedFromClang);
14621462
if (privateDiscriminator)
14631463
goto giveUpFastPath;
14641464

@@ -1470,29 +1470,23 @@ ModuleFile::resolveCrossReference(ModuleDecl *baseModule, uint32_t pathLen) {
14701470
"-Xfrontend -disable-serialization-nested-type-lookup-table"};
14711471

14721472
auto *baseType = cast<NominalTypeDecl>(values.front());
1473+
ModuleDecl *extensionModule = M;
1474+
if (!extensionModule)
1475+
extensionModule = baseType->getModuleContext();
1476+
1477+
// FIXME: If 'importedFromClang' is true but 'extensionModule' is an
1478+
// overlay module, the search below will fail and we'll fall back to
1479+
// the slow path.
1480+
1481+
// Fault in extensions, then ask every file in the module.
1482+
(void)baseType->getExtensions();
14731483
TypeDecl *nestedType = nullptr;
1474-
if (onlyInNominal) {
1475-
// Only look in the file containing the type itself.
1476-
const DeclContext *dc = values.front()->getDeclContext();
1477-
auto *containingFile =
1478-
dyn_cast<FileUnit>(dc->getModuleScopeContext());
1479-
if (containingFile) {
1480-
nestedType = containingFile->lookupNestedType(memberName, baseType);
1481-
}
1482-
} else {
1483-
// Fault in extensions, then ask every file in the module.
1484-
ModuleDecl *extensionModule = M;
1485-
if (!extensionModule)
1486-
extensionModule = baseType->getModuleContext();
1487-
1488-
(void)baseType->getExtensions();
1489-
for (FileUnit *file : extensionModule->getFiles()) {
1490-
if (file == getFile())
1491-
continue;
1492-
nestedType = file->lookupNestedType(memberName, baseType);
1493-
if (nestedType)
1494-
break;
1495-
}
1484+
for (FileUnit *file : extensionModule->getFiles()) {
1485+
if (file == getFile())
1486+
continue;
1487+
nestedType = file->lookupNestedType(memberName, baseType);
1488+
if (nestedType)
1489+
break;
14961490
}
14971491

14981492
if (nestedType) {

0 commit comments

Comments
 (0)