Skip to content

Commit 8d52f71

Browse files
committed
[NFC][Sema] Rename checkUnsupportedProtocolType to checkExistentialTypes.
1 parent 37c0964 commit 8d52f71

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
@@ -3927,15 +3927,15 @@ Type TypeChecker::substMemberTypeWithBase(ModuleDecl *module,
39273927

39283928
namespace {
39293929

3930-
class UnsupportedProtocolVisitor
3931-
: public TypeReprVisitor<UnsupportedProtocolVisitor>, public ASTWalker
3930+
class ExistentialTypeVisitor
3931+
: public TypeReprVisitor<ExistentialTypeVisitor>, public ASTWalker
39323932
{
39333933
ASTContext &Ctx;
39343934
bool checkStatements;
39353935
bool hitTopStmt;
39363936

39373937
public:
3938-
UnsupportedProtocolVisitor(ASTContext &ctx, bool checkStatements)
3938+
ExistentialTypeVisitor(ASTContext &ctx, bool checkStatements)
39393939
: Ctx(ctx), checkStatements(checkStatements), hitTopStmt(false) { }
39403940

39413941
bool walkToTypeReprPre(TypeRepr *T) override {
@@ -3990,60 +3990,60 @@ class UnsupportedProtocolVisitor
39903990

39913991
} // end anonymous namespace
39923992

3993-
void TypeChecker::checkUnsupportedProtocolType(Decl *decl) {
3993+
void TypeChecker::checkExistentialTypes(Decl *decl) {
39943994
if (!decl || decl->isInvalid())
39953995
return;
39963996

39973997
auto &ctx = decl->getASTContext();
39983998
if (auto *protocolDecl = dyn_cast<ProtocolDecl>(decl)) {
3999-
checkUnsupportedProtocolType(ctx, protocolDecl->getTrailingWhereClause());
3999+
checkExistentialTypes(ctx, protocolDecl->getTrailingWhereClause());
40004000
} else if (auto *genericDecl = dyn_cast<GenericTypeDecl>(decl)) {
4001-
checkUnsupportedProtocolType(ctx, genericDecl->getGenericParams());
4002-
checkUnsupportedProtocolType(ctx, genericDecl->getTrailingWhereClause());
4001+
checkExistentialTypes(ctx, genericDecl->getGenericParams());
4002+
checkExistentialTypes(ctx, genericDecl->getTrailingWhereClause());
40034003
} else if (auto *assocType = dyn_cast<AssociatedTypeDecl>(decl)) {
4004-
checkUnsupportedProtocolType(ctx, assocType->getTrailingWhereClause());
4004+
checkExistentialTypes(ctx, assocType->getTrailingWhereClause());
40054005
} else if (auto *extDecl = dyn_cast<ExtensionDecl>(decl)) {
4006-
checkUnsupportedProtocolType(ctx, extDecl->getTrailingWhereClause());
4006+
checkExistentialTypes(ctx, extDecl->getTrailingWhereClause());
40074007
} else if (auto *subscriptDecl = dyn_cast<SubscriptDecl>(decl)) {
4008-
checkUnsupportedProtocolType(ctx, subscriptDecl->getGenericParams());
4009-
checkUnsupportedProtocolType(ctx, subscriptDecl->getTrailingWhereClause());
4008+
checkExistentialTypes(ctx, subscriptDecl->getGenericParams());
4009+
checkExistentialTypes(ctx, subscriptDecl->getTrailingWhereClause());
40104010
} else if (auto *funcDecl = dyn_cast<AbstractFunctionDecl>(decl)) {
40114011
if (!isa<AccessorDecl>(funcDecl)) {
4012-
checkUnsupportedProtocolType(ctx, funcDecl->getGenericParams());
4013-
checkUnsupportedProtocolType(ctx, funcDecl->getTrailingWhereClause());
4012+
checkExistentialTypes(ctx, funcDecl->getGenericParams());
4013+
checkExistentialTypes(ctx, funcDecl->getTrailingWhereClause());
40144014
}
40154015
}
40164016

40174017
if (isa<TypeDecl>(decl) || isa<ExtensionDecl>(decl))
40184018
return;
40194019

4020-
UnsupportedProtocolVisitor visitor(ctx, /*checkStatements=*/false);
4020+
ExistentialTypeVisitor visitor(ctx, /*checkStatements=*/false);
40214021
decl->walk(visitor);
40224022
}
40234023

4024-
void TypeChecker::checkUnsupportedProtocolType(ASTContext &ctx, Stmt *stmt) {
4024+
void TypeChecker::checkExistentialTypes(ASTContext &ctx, Stmt *stmt) {
40254025
if (!stmt)
40264026
return;
40274027

4028-
UnsupportedProtocolVisitor visitor(ctx, /*checkStatements=*/true);
4028+
ExistentialTypeVisitor visitor(ctx, /*checkStatements=*/true);
40294029
stmt->walk(visitor);
40304030
}
40314031

4032-
void TypeChecker::checkUnsupportedProtocolType(
4032+
void TypeChecker::checkExistentialTypes(
40334033
ASTContext &ctx, TrailingWhereClause *whereClause) {
40344034
if (whereClause == nullptr)
40354035
return;
40364036

4037-
UnsupportedProtocolVisitor visitor(ctx, /*checkStatements=*/false);
4037+
ExistentialTypeVisitor visitor(ctx, /*checkStatements=*/false);
40384038
visitor.visitRequirements(whereClause->getRequirements());
40394039
}
40404040

4041-
void TypeChecker::checkUnsupportedProtocolType(
4041+
void TypeChecker::checkExistentialTypes(
40424042
ASTContext &ctx, GenericParamList *genericParams) {
40434043
if (genericParams == nullptr)
40444044
return;
40454045

4046-
UnsupportedProtocolVisitor visitor(ctx, /*checkStatements=*/false);
4046+
ExistentialTypeVisitor visitor(ctx, /*checkStatements=*/false);
40474047
visitor.visitRequirements(genericParams->getRequirements());
40484048
}
40494049

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)