Skip to content

Commit ff20d06

Browse files
committed
Sema: Remove a usage of getExistentialTypeProtocols()
1 parent 61e0c55 commit ff20d06

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/Sema/ITCDecl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/Sema/IterativeTypeChecker.h"
2020
#include "swift/AST/ASTContext.h"
2121
#include "swift/AST/Decl.h"
22+
#include "swift/AST/ExistentialLayout.h"
2223
#include <tuple>
2324
using namespace swift;
2425

@@ -256,9 +257,12 @@ void IterativeTypeChecker::processInheritedProtocols(
256257
// Collect existential types.
257258
// FIXME: We'd prefer to keep what the user wrote here.
258259
if (inherited.getType()->isExistentialType()) {
259-
SmallVector<ProtocolDecl *, 4> protocols;
260-
inherited.getType()->getExistentialTypeProtocols(protocols);
261-
for (auto inheritedProtocol: protocols) {
260+
auto layout = inherited.getType()->getExistentialLayout();
261+
assert(!layout.superclass && "Need to redo inheritance clause "
262+
"typechecking");
263+
for (auto inheritedProtocolTy: layout.getProtocols()) {
264+
auto *inheritedProtocol = inheritedProtocolTy->getDecl();
265+
262266
if (inheritedProtocol == protocol ||
263267
inheritedProtocol->inheritsFrom(protocol)) {
264268
if (!diagnosedCircularity) {

0 commit comments

Comments
 (0)