Skip to content

Commit ac5dc85

Browse files
committed
[NFC][Sema] Rename checkUnsupportedProtocolType to checkExistentialTypes.
1 parent 6d00a24 commit ac5dc85

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3361,7 +3361,7 @@ static void checkSwitch(ASTContext &ctx, const SwitchStmt *stmt) {
33613361
// We want to warn about "case .Foo, .Bar where 1 != 100:" since the where
33623362
// clause only applies to the second case, and this is surprising.
33633363
for (auto cs : stmt->getCases()) {
3364-
TypeChecker::checkUnsupportedProtocolType(ctx, cs);
3364+
TypeChecker::checkExistentialTypes(ctx, cs);
33653365

33663366
// The case statement can have multiple case items, each can have a where.
33673367
// If we find a "where", and there is a preceding item without a where, and
@@ -4841,7 +4841,7 @@ void swift::performSyntacticExprDiagnostics(const Expr *E,
48414841
void swift::performStmtDiagnostics(const Stmt *S, DeclContext *DC) {
48424842
auto &ctx = DC->getASTContext();
48434843

4844-
TypeChecker::checkUnsupportedProtocolType(ctx, const_cast<Stmt *>(S));
4844+
TypeChecker::checkExistentialTypes(ctx, const_cast<Stmt *>(S));
48454845

48464846
if (auto switchStmt = dyn_cast<SwitchStmt>(S))
48474847
checkSwitch(ctx, switchStmt);

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
16961696

16971697
DeclVisitor<DeclChecker>::visit(decl);
16981698

1699-
TypeChecker::checkUnsupportedProtocolType(decl);
1699+
TypeChecker::checkExistentialTypes(decl);
17001700

17011701
if (auto VD = dyn_cast<ValueDecl>(decl)) {
17021702
auto &Context = getASTContext();

lib/Sema/TypeCheckType.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3945,15 +3945,15 @@ Type TypeChecker::substMemberTypeWithBase(ModuleDecl *module,
39453945

39463946
namespace {
39473947

3948-
class UnsupportedProtocolVisitor
3949-
: public TypeReprVisitor<UnsupportedProtocolVisitor>, public ASTWalker
3948+
class ExistentialTypeVisitor
3949+
: public TypeReprVisitor<ExistentialTypeVisitor>, public ASTWalker
39503950
{
39513951
ASTContext &Ctx;
39523952
bool checkStatements;
39533953
bool hitTopStmt;
39543954

39553955
public:
3956-
UnsupportedProtocolVisitor(ASTContext &ctx, bool checkStatements)
3956+
ExistentialTypeVisitor(ASTContext &ctx, bool checkStatements)
39573957
: Ctx(ctx), checkStatements(checkStatements), hitTopStmt(false) { }
39583958

39593959
bool walkToTypeReprPre(TypeRepr *T) override {
@@ -4008,60 +4008,60 @@ class UnsupportedProtocolVisitor
40084008

40094009
} // end anonymous namespace
40104010

4011-
void TypeChecker::checkUnsupportedProtocolType(Decl *decl) {
4011+
void TypeChecker::checkExistentialTypes(Decl *decl) {
40124012
if (!decl || decl->isInvalid())
40134013
return;
40144014

40154015
auto &ctx = decl->getASTContext();
40164016
if (auto *protocolDecl = dyn_cast<ProtocolDecl>(decl)) {
4017-
checkUnsupportedProtocolType(ctx, protocolDecl->getTrailingWhereClause());
4017+
checkExistentialTypes(ctx, protocolDecl->getTrailingWhereClause());
40184018
} else if (auto *genericDecl = dyn_cast<GenericTypeDecl>(decl)) {
4019-
checkUnsupportedProtocolType(ctx, genericDecl->getGenericParams());
4020-
checkUnsupportedProtocolType(ctx, genericDecl->getTrailingWhereClause());
4019+
checkExistentialTypes(ctx, genericDecl->getGenericParams());
4020+
checkExistentialTypes(ctx, genericDecl->getTrailingWhereClause());
40214021
} else if (auto *assocType = dyn_cast<AssociatedTypeDecl>(decl)) {
4022-
checkUnsupportedProtocolType(ctx, assocType->getTrailingWhereClause());
4022+
checkExistentialTypes(ctx, assocType->getTrailingWhereClause());
40234023
} else if (auto *extDecl = dyn_cast<ExtensionDecl>(decl)) {
4024-
checkUnsupportedProtocolType(ctx, extDecl->getTrailingWhereClause());
4024+
checkExistentialTypes(ctx, extDecl->getTrailingWhereClause());
40254025
} else if (auto *subscriptDecl = dyn_cast<SubscriptDecl>(decl)) {
4026-
checkUnsupportedProtocolType(ctx, subscriptDecl->getGenericParams());
4027-
checkUnsupportedProtocolType(ctx, subscriptDecl->getTrailingWhereClause());
4026+
checkExistentialTypes(ctx, subscriptDecl->getGenericParams());
4027+
checkExistentialTypes(ctx, subscriptDecl->getTrailingWhereClause());
40284028
} else if (auto *funcDecl = dyn_cast<AbstractFunctionDecl>(decl)) {
40294029
if (!isa<AccessorDecl>(funcDecl)) {
4030-
checkUnsupportedProtocolType(ctx, funcDecl->getGenericParams());
4031-
checkUnsupportedProtocolType(ctx, funcDecl->getTrailingWhereClause());
4030+
checkExistentialTypes(ctx, funcDecl->getGenericParams());
4031+
checkExistentialTypes(ctx, funcDecl->getTrailingWhereClause());
40324032
}
40334033
}
40344034

40354035
if (isa<TypeDecl>(decl) || isa<ExtensionDecl>(decl))
40364036
return;
40374037

4038-
UnsupportedProtocolVisitor visitor(ctx, /*checkStatements=*/false);
4038+
ExistentialTypeVisitor visitor(ctx, /*checkStatements=*/false);
40394039
decl->walk(visitor);
40404040
}
40414041

4042-
void TypeChecker::checkUnsupportedProtocolType(ASTContext &ctx, Stmt *stmt) {
4042+
void TypeChecker::checkExistentialTypes(ASTContext &ctx, Stmt *stmt) {
40434043
if (!stmt)
40444044
return;
40454045

4046-
UnsupportedProtocolVisitor visitor(ctx, /*checkStatements=*/true);
4046+
ExistentialTypeVisitor visitor(ctx, /*checkStatements=*/true);
40474047
stmt->walk(visitor);
40484048
}
40494049

4050-
void TypeChecker::checkUnsupportedProtocolType(
4050+
void TypeChecker::checkExistentialTypes(
40514051
ASTContext &ctx, TrailingWhereClause *whereClause) {
40524052
if (whereClause == nullptr)
40534053
return;
40544054

4055-
UnsupportedProtocolVisitor visitor(ctx, /*checkStatements=*/false);
4055+
ExistentialTypeVisitor visitor(ctx, /*checkStatements=*/false);
40564056
visitor.visitRequirements(whereClause->getRequirements());
40574057
}
40584058

4059-
void TypeChecker::checkUnsupportedProtocolType(
4059+
void TypeChecker::checkExistentialTypes(
40604060
ASTContext &ctx, GenericParamList *genericParams) {
40614061
if (genericParams == nullptr)
40624062
return;
40634063

4064-
UnsupportedProtocolVisitor visitor(ctx, /*checkStatements=*/false);
4064+
ExistentialTypeVisitor visitor(ctx, /*checkStatements=*/false);
40654065
visitor.visitRequirements(genericParams->getRequirements());
40664066
}
40674067

lib/Sema/TypeChecker.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,21 @@ Type getOptionalType(SourceLoc loc, Type elementType);
245245
Expr *resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE, DeclContext *Context,
246246
bool replaceInvalidRefsWithErrors);
247247

248-
/// Check for unsupported protocol types in the given declaration.
249-
void checkUnsupportedProtocolType(Decl *decl);
248+
/// Check for invalid existential types in the given declaration.
249+
void checkExistentialTypes(Decl *decl);
250250

251-
/// Check for unsupported protocol types in the given statement.
252-
void checkUnsupportedProtocolType(ASTContext &ctx, Stmt *stmt);
251+
/// Check for invalid existential types in the given statement.
252+
void checkExistentialTypes(ASTContext &ctx, Stmt *stmt);
253253

254-
/// Check for unsupported protocol types in the given generic requirement
254+
/// Check for invalid existential types in the given generic requirement
255255
/// list.
256-
void checkUnsupportedProtocolType(ASTContext &ctx,
257-
TrailingWhereClause *whereClause);
256+
void checkExistentialTypes(ASTContext &ctx,
257+
TrailingWhereClause *whereClause);
258258

259-
/// Check for unsupported protocol types in the given generic requirement
259+
/// Check for invalid existential types in the given generic requirement
260260
/// list.
261-
void checkUnsupportedProtocolType(ASTContext &ctx,
262-
GenericParamList *genericParams);
261+
void checkExistentialTypes(ASTContext &ctx,
262+
GenericParamList *genericParams);
263263

264264
/// Substitute the given base type into the type of the given nested type,
265265
/// producing the effective type that the nested type will have.

0 commit comments

Comments
 (0)