Skip to content

Commit 1b458ee

Browse files
committed
swift-api-digester: avoid synthesizing nominal types from the same module.
Synthesizing types from the same module may bring back types that are not part the ABI/API, leading to false positives. Resolves: SR-9372
1 parent 897bd3c commit 1b458ee

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

test/api-digester/Inputs/cake.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ infix operator ..*..
9696
class UsableFromInlineClass {
9797
private var Prop = 1
9898
}
99+
100+
class InternalType {}
101+
102+
extension InternalType {}

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "llvm/ADT/STLExtras.h"
12
#include <ModuleAnalyzerNodes.h>
23
#include <algorithm>
34

@@ -1522,7 +1523,11 @@ void SwiftDeclCollector::lookupVisibleDecls(ArrayRef<ModuleDecl *> Modules) {
15221523
for (auto *D: KnownDecls) {
15231524
if (auto *Ext = dyn_cast<ExtensionDecl>(D)) {
15241525
if (HandledExtensions.find(Ext) == HandledExtensions.end()) {
1525-
ExtensionMap[Ext->getExtendedNominal()].push_back(Ext);
1526+
auto *NTD = Ext->getExtendedNominal();
1527+
// Check if the extension is from other modules.
1528+
if (!llvm::is_contained(Modules, NTD->getModuleContext())) {
1529+
ExtensionMap[NTD].push_back(Ext);
1530+
}
15261531
}
15271532
}
15281533
}

0 commit comments

Comments
 (0)