Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ ERROR(broken_decodable_requirement,none,
NOTE(codable_extraneous_codingkey_case_here,none,
"CodingKey case %0 does match any stored properties", (Identifier))
NOTE(codable_non_conforming_property_here,none,
"cannot automatically synthesize %0 because %1 does not conform to %0", (Type, Identifier))
"cannot automatically synthesize %0 because %1 does not conform to %0", (Type, Type))
NOTE(codable_non_decoded_property_here,none,
"cannot automatically synthesize %0 because %1 does not have a matching CodingKey and does not have a default value", (Type, Identifier))
NOTE(codable_codingkeys_type_is_not_an_enum_here,none,
Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/KnownIdentifiers.def
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ IDENTIFIER(Darwin)
IDENTIFIER(dealloc)
IDENTIFIER(Decodable)
IDENTIFIER(decode)
IDENTIFIER(decodeIfPresent)
IDENTIFIER(Decoder)
IDENTIFIER(decoder)
IDENTIFIER(deinit)
IDENTIFIER(Element)
IDENTIFIER(Encodable)
IDENTIFIER(encode)
IDENTIFIER(encodeIfPresent)
IDENTIFIER(Encoder)
IDENTIFIER(encoder)
IDENTIFIER(error)
Expand Down
272 changes: 192 additions & 80 deletions lib/Sema/DerivedConformanceCodable.cpp

Large diffs are not rendered by default.

304 changes: 213 additions & 91 deletions stdlib/public/SDK/Foundation/JSONEncoder.swift

Large diffs are not rendered by default.

290 changes: 216 additions & 74 deletions stdlib/public/SDK/Foundation/PlistEncoder.swift

Large diffs are not rendered by default.

612 changes: 528 additions & 84 deletions stdlib/public/core/Codable.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/IDE/complete_generic_optional.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ struct Foo<T> {
// SR-642 Code completion does not instantiate generic arguments of a type wrapped in an optional
let x: Foo<Bar>? = Foo<Bar>()
x.#^FOO_OPTIONAL_1^#
// FOO_OPTIONAL_1: Begin completions, 6 items
// FOO_OPTIONAL_1: Begin completions, 7 items
// FOO_OPTIONAL_1-DAG: Decl[InstanceMethod]/CurrNominal/Erase[1]: ?.myFunction({#(foobar): Bar#})[#Void#]; name=myFunction(foobar: Bar)
// FOO_OPTIONAL_1: End completions

Large diffs are not rendered by default.

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions test/stdlib/TestJSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ class TestJSONEncoder : TestJSONEncoderSuper {

func testEncodingTopLevelStructuredClass() {
// Person is a class with multiple fields.
let expectedJSON = "{\"name\":\"Johnny Appleseed\",\"email\":\"appleseed@apple.com\"}".data(using: .utf8)!
let person = Person.testValue
_testRoundTrip(of: person)
_testRoundTrip(of: person, expectedJSON: expectedJSON)
}

func testEncodingTopLevelDeepStructuredType() {
Expand Down Expand Up @@ -471,13 +472,21 @@ fileprivate class Person : Codable, Equatable {
let name: String
let email: String

init(name: String, email: String) {
// FIXME: This property is present only in order to test the expected result of Codable synthesis in the compiler.
// We want to test against expected encoded output (to ensure this generates an encodeIfPresent call), but we need an output format for that.
// Once we have a VerifyingEncoder for compiler unit tests, we should move this test there.
let website: URL?

init(name: String, email: String, website: URL? = nil) {
self.name = name
self.email = email
self.website = website
}

static func ==(_ lhs: Person, _ rhs: Person) -> Bool {
return lhs.name == rhs.name && lhs.email == rhs.email
return lhs.name == rhs.name &&
lhs.email == rhs.email &&
lhs.website == rhs.website
}

static var testValue: Person {
Expand Down