@@ -3384,13 +3384,13 @@ namespace {
3384
3384
class UnsupportedProtocolVisitor
3385
3385
: public TypeReprVisitor<UnsupportedProtocolVisitor>, public ASTWalker
3386
3386
{
3387
- TypeChecker &TC ;
3387
+ ASTContext &Ctx ;
3388
3388
bool checkStatements;
3389
3389
bool hitTopStmt;
3390
3390
3391
3391
public:
3392
- UnsupportedProtocolVisitor (TypeChecker &tc , bool checkStatements)
3393
- : TC(tc ), checkStatements(checkStatements), hitTopStmt(false ) { }
3392
+ UnsupportedProtocolVisitor (ASTContext &ctx , bool checkStatements)
3393
+ : Ctx(ctx ), checkStatements(checkStatements), hitTopStmt(false ) { }
3394
3394
3395
3395
bool walkToTypeReprPre (TypeRepr *T) override {
3396
3396
if (T->isInvalid ())
@@ -3429,8 +3429,8 @@ class UnsupportedProtocolVisitor
3429
3429
auto comp = T->getComponentRange ().back ();
3430
3430
if (auto *proto = dyn_cast_or_null<ProtocolDecl>(comp->getBoundDecl ())) {
3431
3431
if (!proto->existentialTypeSupported ()) {
3432
- TC .diagnose (comp->getIdLoc (), diag::unsupported_existential_type,
3433
- proto->getName ());
3432
+ Ctx. Diags .diagnose (comp->getIdLoc (), diag::unsupported_existential_type,
3433
+ proto->getName ());
3434
3434
T->setInvalid ();
3435
3435
}
3436
3436
} else if (auto *alias = dyn_cast_or_null<TypeAliasDecl>(comp->getBoundDecl ())) {
@@ -3446,8 +3446,9 @@ class UnsupportedProtocolVisitor
3446
3446
if (protoDecl->existentialTypeSupported ())
3447
3447
continue ;
3448
3448
3449
- TC.diagnose (comp->getIdLoc (), diag::unsupported_existential_type,
3450
- protoDecl->getName ());
3449
+ Ctx.Diags .diagnose (comp->getIdLoc (),
3450
+ diag::unsupported_existential_type,
3451
+ protoDecl->getName ());
3451
3452
T->setInvalid ();
3452
3453
}
3453
3454
}
@@ -3474,49 +3475,52 @@ void TypeChecker::checkUnsupportedProtocolType(Decl *decl) {
3474
3475
if (!decl || decl->isInvalid ())
3475
3476
return ;
3476
3477
3478
+ auto &ctx = decl->getASTContext ();
3477
3479
if (auto *protocolDecl = dyn_cast<ProtocolDecl>(decl))
3478
- checkUnsupportedProtocolType (protocolDecl->getTrailingWhereClause ());
3480
+ checkUnsupportedProtocolType (ctx, protocolDecl->getTrailingWhereClause ());
3479
3481
else if (auto *genericDecl = dyn_cast<GenericTypeDecl>(decl))
3480
- checkUnsupportedProtocolType (genericDecl->getGenericParams ());
3482
+ checkUnsupportedProtocolType (ctx, genericDecl->getGenericParams ());
3481
3483
else if (auto *assocType = dyn_cast<AssociatedTypeDecl>(decl))
3482
- checkUnsupportedProtocolType (assocType->getTrailingWhereClause ());
3484
+ checkUnsupportedProtocolType (ctx, assocType->getTrailingWhereClause ());
3483
3485
else if (auto *extDecl = dyn_cast<ExtensionDecl>(decl))
3484
- checkUnsupportedProtocolType (extDecl->getTrailingWhereClause ());
3486
+ checkUnsupportedProtocolType (ctx, extDecl->getTrailingWhereClause ());
3485
3487
else if (auto *subscriptDecl = dyn_cast<SubscriptDecl>(decl))
3486
- checkUnsupportedProtocolType (subscriptDecl->getGenericParams ());
3488
+ checkUnsupportedProtocolType (ctx, subscriptDecl->getGenericParams ());
3487
3489
else if (auto *funcDecl = dyn_cast<AbstractFunctionDecl>(decl)) {
3488
3490
if (!isa<AccessorDecl>(funcDecl))
3489
- checkUnsupportedProtocolType (funcDecl->getGenericParams ());
3491
+ checkUnsupportedProtocolType (ctx, funcDecl->getGenericParams ());
3490
3492
}
3491
3493
3492
3494
if (isa<TypeDecl>(decl) || isa<ExtensionDecl>(decl))
3493
3495
return ;
3494
3496
3495
- UnsupportedProtocolVisitor visitor (* this , /* checkStatements=*/ false );
3497
+ UnsupportedProtocolVisitor visitor (ctx , /* checkStatements=*/ false );
3496
3498
decl->walk (visitor);
3497
3499
}
3498
3500
3499
- void TypeChecker::checkUnsupportedProtocolType (Stmt *stmt) {
3501
+ void TypeChecker::checkUnsupportedProtocolType (ASTContext &ctx, Stmt *stmt) {
3500
3502
if (!stmt)
3501
3503
return ;
3502
3504
3503
- UnsupportedProtocolVisitor visitor (* this , /* checkStatements=*/ true );
3505
+ UnsupportedProtocolVisitor visitor (ctx , /* checkStatements=*/ true );
3504
3506
stmt->walk (visitor);
3505
3507
}
3506
3508
3507
- void TypeChecker::checkUnsupportedProtocolType (TrailingWhereClause *whereClause) {
3509
+ void TypeChecker::checkUnsupportedProtocolType (
3510
+ ASTContext &ctx, TrailingWhereClause *whereClause) {
3508
3511
if (whereClause == nullptr )
3509
3512
return ;
3510
3513
3511
- UnsupportedProtocolVisitor visitor (* this , /* checkStatements=*/ false );
3514
+ UnsupportedProtocolVisitor visitor (ctx , /* checkStatements=*/ false );
3512
3515
visitor.visitRequirements (whereClause->getRequirements ());
3513
3516
}
3514
3517
3515
- void TypeChecker::checkUnsupportedProtocolType (GenericParamList *genericParams) {
3518
+ void TypeChecker::checkUnsupportedProtocolType (
3519
+ ASTContext &ctx, GenericParamList *genericParams) {
3516
3520
if (genericParams == nullptr )
3517
3521
return ;
3518
3522
3519
- UnsupportedProtocolVisitor visitor (* this , /* checkStatements=*/ false );
3523
+ UnsupportedProtocolVisitor visitor (ctx , /* checkStatements=*/ false );
3520
3524
visitor.visitRequirements (genericParams->getRequirements ());
3521
3525
}
3522
3526
0 commit comments