Skip to content

Commit 5599df0

Browse files
committed
Resolve CodingKeys before visiting member decls in the primary
Force this check to occur so that the interface types of members can successfully make reference to CodingKeys. This is an egregious emergent behavior of Codable that currently forces two protocol conformance checks just to synthesize a type witness. We can definitely get away with just creating the witness up front. rdar://56844567
1 parent d23ab39 commit 5599df0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ static void checkInheritanceClause(
333333
}
334334
}
335335

336+
static void installCodingKeysIfNecessary(NominalTypeDecl *NTD) {
337+
auto req =
338+
ResolveImplicitMemberRequest{NTD, ImplicitMemberAction::ResolveCodingKeys};
339+
(void)evaluateOrDefault(NTD->getASTContext().evaluator, req, false);
340+
}
341+
336342
// Check for static properties that produce empty option sets
337343
// using a rawValue initializer with a value of '0'
338344
static void checkForEmptyOptionSet(const VarDecl *VD) {
@@ -1666,6 +1672,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
16661672

16671673
TypeChecker::addImplicitConstructors(SD);
16681674

1675+
installCodingKeysIfNecessary(SD);
1676+
16691677
for (Decl *Member : SD->getMembers())
16701678
visit(Member);
16711679

0 commit comments

Comments
 (0)