Skip to content

Commit b4f2324

Browse files
committed
Sema: Move some logic out of DeclChecker::visit() to individual visitors
Also kill a usage of IsFirstPass.
1 parent 46d4163 commit b4f2324

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3974,6 +3974,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
39743974

39753975
DeclVisitor<DeclChecker>::visit(decl);
39763976

3977+
if (IsFirstPass)
3978+
TC.checkUnsupportedProtocolType(decl);
3979+
39773980
if (auto VD = dyn_cast<ValueDecl>(decl)) {
39783981
checkRedeclaration(TC, VD);
39793982

@@ -3995,17 +3998,6 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
39953998
"`" + VD->getBaseName().userFacingName().str() + "`");
39963999
}
39974000
}
3998-
3999-
if (!IsFirstPass) {
4000-
TC.checkUnsupportedProtocolType(decl);
4001-
if (auto nominal = dyn_cast<NominalTypeDecl>(decl)) {
4002-
TC.checkDeclCircularity(nominal);
4003-
}
4004-
if (auto protocol = dyn_cast<ProtocolDecl>(decl)) {
4005-
if (protocol->isResilient())
4006-
TC.inferDefaultWitnesses(protocol);
4007-
}
4008-
}
40094001
}
40104002

40114003
//===--------------------------------------------------------------------===//
@@ -4393,6 +4385,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
43934385
// enums haven't.
43944386
checkEnumRawValues(TC, ED);
43954387
}
4388+
4389+
TC.checkDeclCircularity(ED);
43964390
}
43974391

43984392
void visitStructDecl(StructDecl *SD) {
@@ -4419,6 +4413,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
44194413

44204414
TC.checkDeclAttributes(SD);
44214415
checkAccessControl(TC, SD);
4416+
4417+
TC.checkDeclCircularity(SD);
44224418
}
44234419

44244420
/// Check whether the given properties can be @NSManaged in this class.
@@ -4651,6 +4647,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
46514647

46524648
TC.checkDeclAttributes(CD);
46534649
checkAccessControl(TC, CD);
4650+
4651+
TC.checkDeclCircularity(CD);
46544652
}
46554653

46564654
void visitProtocolDecl(ProtocolDecl *PD) {
@@ -4707,6 +4705,10 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
47074705
GenericTypeToArchetypeResolver resolver(PD);
47084706
TC.validateWhereClauses(PD, &resolver);
47094707

4708+
TC.checkDeclCircularity(PD);
4709+
if (PD->isResilient())
4710+
TC.inferDefaultWitnesses(PD);
4711+
47104712
if (TC.Context.LangOpts.DebugGenericSignatures) {
47114713
auto requirementsSig =
47124714
GenericSignature::get({PD->getProtocolSelfType()},

0 commit comments

Comments
 (0)