Skip to content

Commit 40ef504

Browse files
committed
[Index] Don't report extensions with nothing to index in system modules
The indexer was looking into “empty” extensions to public types, triggering computing their USR which could fail at deserializing the implementation-only imported types. As a solution, don’t index extensions with nothing to index in system modules. rdar://70225906
1 parent 0d8f689 commit 40ef504

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/Index/Index.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,22 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
631631
return true;
632632
}
633633

634+
// Are there members or conformances in \c D that should be indexed?
635+
bool shouldIndexMembers(ExtensionDecl *D) {
636+
for (auto Member : D->getMembers())
637+
if (auto VD = dyn_cast<ValueDecl>(Member))
638+
if (shouldIndex(VD, /*IsRef=*/false))
639+
return true;
640+
641+
for (auto Inherit : D->getInherited())
642+
if (auto T = Inherit.getType())
643+
if (T->getAnyNominal() &&
644+
shouldIndex(T->getAnyNominal(), /*IsRef=*/false))
645+
return true;
646+
647+
return false;
648+
}
649+
634650
/// Reports all implicit member value decl conformances that \p D introduces
635651
/// as implicit overrides at the source location of \p D, and returns the
636652
/// explicit ones so we can check against them later on when visiting them as
@@ -1068,6 +1084,10 @@ bool IndexSwiftASTWalker::reportExtension(ExtensionDecl *D) {
10681084
if (!shouldIndex(NTD, /*IsRef=*/false))
10691085
return true;
10701086

1087+
// Don't index "empty" extensions in imported modules.
1088+
if (IsModuleFile && !shouldIndexMembers(D))
1089+
return true;
1090+
10711091
IndexSymbol Info;
10721092
if (initIndexSymbol(D, NTD, Loc, Info))
10731093
return true;

0 commit comments

Comments
 (0)