Skip to content

Commit ecc552f

Browse files
committed
ConstExtract: Stop calling getAllConformances() on protocols
1 parent 82bd81e commit ecc552f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/ConstExtract/ConstExtract.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,27 @@
2626
#include <sstream>
2727
#include <string>
2828

29+
using namespace swift;
30+
2931
namespace {
3032
/// A helper class to collect all nominal type declarations that conform to
3133
/// specific protocols provided as input.
32-
class NominalTypeConformanceCollector : public swift::ASTWalker {
34+
class NominalTypeConformanceCollector : public ASTWalker {
3335
const std::unordered_set<std::string> &Protocols;
34-
std::vector<swift::NominalTypeDecl *> &ConformanceTypeDecls;
36+
std::vector<NominalTypeDecl *> &ConformanceTypeDecls;
3537

3638
public:
3739
NominalTypeConformanceCollector(
3840
const std::unordered_set<std::string> &Protocols,
39-
std::vector<swift::NominalTypeDecl *> &ConformanceDecls)
41+
std::vector<NominalTypeDecl *> &ConformanceDecls)
4042
: Protocols(Protocols), ConformanceTypeDecls(ConformanceDecls) {}
4143

42-
bool walkToDeclPre(swift::Decl *D) override {
43-
if (auto *NTD = llvm::dyn_cast<swift::NominalTypeDecl>(D))
44-
for (auto &Protocol : NTD->getAllProtocols())
45-
if (Protocols.count(Protocol->getName().str().str()) != 0)
46-
ConformanceTypeDecls.push_back(NTD);
44+
bool walkToDeclPre(Decl *D) override {
45+
if (auto *NTD = llvm::dyn_cast<NominalTypeDecl>(D))
46+
if (!isa<ProtocolDecl>(NTD))
47+
for (auto &Protocol : NTD->getAllProtocols())
48+
if (Protocols.count(Protocol->getName().str().str()) != 0)
49+
ConformanceTypeDecls.push_back(NTD);
4750
return true;
4851
}
4952
};

0 commit comments

Comments
 (0)