Skip to content

Commit 9f45b9e

Browse files
committed
have suppressed entries checked early
In situations like building a generic signature or simply visiting members like a deinit, it's important that we've already resolved the types in the SuppressedEntries list of a TypeDecl, otherwise we may get incorrect answers about whether the type is suppressed or not.
1 parent b69241e commit 9f45b9e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,6 @@ static void checkInheritanceClause(
187187
const ExtensionDecl *ext = nullptr;
188188
const TypeDecl *typeDecl = nullptr;
189189
const Decl *decl;
190-
191-
/// The suppressed implicit conformances are physically separate but part of
192-
/// the same syntactic inheritance clause sequence.
193-
checkSuppressedEntries(declUnion);
194-
195190
if ((ext = declUnion.dyn_cast<const ExtensionDecl *>())) {
196191
decl = ext;
197192

@@ -570,6 +565,7 @@ static void checkGenericParams(GenericContext *ownerCtx) {
570565

571566
for (auto gp : *genericParams) {
572567
TypeChecker::checkDeclAttributes(gp);
568+
assert(gp->getSuppressed().empty() && "unexpected suppressed conformances");
573569
checkInheritanceClause(gp);
574570
}
575571

@@ -2544,6 +2540,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
25442540
void visitAssociatedTypeDecl(AssociatedTypeDecl *AT) {
25452541
TypeChecker::checkDeclAttributes(AT);
25462542

2543+
assert(AT->getSuppressed().empty() && "unexpected suppressed conformances");
25472544
checkInheritanceClause(AT);
25482545
auto *proto = AT->getProtocol();
25492546

@@ -2625,6 +2622,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
26252622
void visitEnumDecl(EnumDecl *ED) {
26262623
checkUnsupportedNestedType(ED);
26272624

2625+
// Establish suppressed conformances early to support queries elsewhere.
2626+
checkSuppressedEntries(ED);
2627+
26282628
// FIXME: Remove this once we clean up the mess involving raw values.
26292629
(void) ED->getInterfaceType();
26302630

@@ -2696,6 +2696,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
26962696
void visitStructDecl(StructDecl *SD) {
26972697
checkUnsupportedNestedType(SD);
26982698

2699+
// Establish suppressed conformances early to support queries elsewhere.
2700+
checkSuppressedEntries(SD);
2701+
26992702
checkGenericParams(SD);
27002703

27012704
// Force lowering of stored properties.
@@ -2884,6 +2887,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
28842887
void visitClassDecl(ClassDecl *CD) {
28852888
checkUnsupportedNestedType(CD);
28862889

2890+
// Establish suppressed conformances early to support queries elsewhere.
2891+
checkSuppressedEntries(CD);
2892+
28872893
// Force creation of the generic signature.
28882894
(void) CD->getGenericSignature();
28892895

@@ -3051,6 +3057,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
30513057
void visitProtocolDecl(ProtocolDecl *PD) {
30523058
checkUnsupportedNestedType(PD);
30533059

3060+
// Establish suppressed conformances early to support queries elsewhere.
3061+
checkSuppressedEntries(PD);
3062+
30543063
// Check for circular inheritance within the protocol.
30553064
(void) PD->hasCircularInheritedProtocols();
30563065

0 commit comments

Comments
 (0)