Skip to content

Commit ea01582

Browse files
committed
ClangImporter: Remove a usage of getExistentialTypeProtocols()
1 parent ff20d06 commit ea01582

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/AST/Builtins.h"
2424
#include "swift/AST/Decl.h"
2525
#include "swift/AST/DiagnosticsClangImporter.h"
26+
#include "swift/AST/ExistentialLayout.h"
2627
#include "swift/AST/Expr.h"
2728
#include "swift/AST/GenericEnvironment.h"
2829
#include "swift/AST/GenericSignature.h"
@@ -4742,12 +4743,15 @@ static bool inheritanceListContainsProtocol(ArrayRef<TypeLoc> inherited,
47424743
return llvm::any_of(inherited, [proto](TypeLoc type) -> bool {
47434744
if (!type.getType()->isExistentialType())
47444745
return false;
4745-
SmallVector<ProtocolDecl *, 8> protos;
4746-
type.getType()->getExistentialTypeProtocols(protos);
4747-
return ProtocolType::visitAllProtocols(protos,
4748-
[proto](const ProtocolDecl *next) {
4749-
return next == proto;
4750-
});
4746+
4747+
auto layout = type.getType()->getExistentialLayout();
4748+
for (auto protoTy : layout.getProtocols()) {
4749+
auto *protoDecl = protoTy->getDecl();
4750+
if (protoDecl == proto || protoDecl->inheritsFrom(proto))
4751+
return true;
4752+
}
4753+
4754+
return false;
47514755
});
47524756
}
47534757

0 commit comments

Comments
 (0)