Commit Graph

5 Commits

Author SHA1 Message Date
Itai Ferber
fc8f6824f7 Typo fix in Codable test comment 2018-05-21 07:54:17 -07:00
Jordan Rose
28a1dc7770 Use 'fileprivate' for synthesized members of 'private' decls (#15980)
Since 'private' means "limit to the enclosing scope (and extensions
thereof)", putting it on a member means that the member can't be
accessed everywhere the type might show up. That's normally a good
thing, but it's not the desired effect for synthesized members used
for derived conformances, and when it comes to class initializers this
actually violates AST invariants.

rdar://problem/39478298
2018-04-17 15:19:35 -07:00
Itai Ferber
5eb58ef8d4 Improve experience of derivation of Codable types
* Introduce diagnostics that explain why derivation of
  Encodable/Decodable fail rather than just silently failing
* Allow properties with default values to be omitted from CodingKeys
  enum and from encoding/decoding
* If `CodingKeys` is a typealias, reach through it more consistently to
  get at the final target type
* Add unit tests to confirm this new behavior for classes and structs

NOTE: Although this made the diff bigger, standalone variables named
"type" have been renamed to "target" throughout, since the word "type"
may be ambiguous and makes debugging impossible. "target" is unique.
2017-05-19 09:45:54 -07:00
Itai Ferber
22185d237f CodingKey/*Codable tests don't need ObjC interop
Since all of the core types are now in the Swift stdlib, the tests no
longer rely on objc_interop or Foundation.
2017-04-25 14:11:24 -07:00
Itai Ferber
e2318392be Add CodingKey and *codable derived conformance
* Allow CodingKey conformance to be automatically derived for enums
  which have no raw type (with no associated values) and which have
  a raw type of String or Int.
* Allow Encodable and Decodable conformance to be automatically derived
  for classes and structs with Encodable/Decodable properties
* Add initial unit tests for verifying derived conformance
2017-04-25 13:13:35 -07:00