-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Explicitly State CodingKeys as a Codable Requirement #28665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
0bcc686
to
d2136a3
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
Infrastructure problems with the macOS build @swift-ci please smoke test macOS platform |
State the previously unstated nested type requirement that CodingKeys adds to the witness requirements of a given type. The goal is to make this member cheap to synthesize, and independent of the expensive protocol conformance checks required to append it to the member list. Further, this makes a clean conceptual separation between what I'm calling "nested type requirements" and actual type and value requirements. With luck, we'll never have to use this attribute anywhere else.
CodableConformanceType::TypeNotValidated is unused since the InterfaceTypeRequest changes went through. We can just use the validity of the ProtocolConformanceRef here.
The semantic checks for CodingKeys are being duplicated across the value witness synthesis code paths. Just synthesize a CodingKeys enum and let validateCodingKeysEnum do the heavy lifting when we actually need to go emit diagnostics.
The presence of this attribute will be used to guide the protocol derivation machinery to synthesize CodingKeys.
d2136a3
to
3bda241
Compare
Let's get this merged @swift-ci please smoke test |
⛵️ |
Revert "Merge pull request #28665 from CodaFi/the-phantom-menace"
Refactors the way we model the
CodingKeys
"requirement" in Codable. The idea is that it should be cheap and easy to synthesizeCodingKeys
. But it should also be clear thatCodable
synthesis has the unique ability to synthesize type witnesses to requirements that don't formally exist, hence "Phantom Requirements". This patch adds a new, terrifyingly-named, user-inaccessible attribute@_implicitly_synthesizes_nested_requirement
, and attaches it toEncodable
andDecodable
. The synthesis machinery looks for the attribute and, if it must synthesize a value witness, attempts to install the phantom witness first.This pull request and #28624 together will let us eliminate
ImplicitMemberAction::ResolveEncodable
andImplicitMemberAction::ResolveDecodable
.Relates to rdar://56844567