Skip to content

Break ambiguity for types conforming to both UEC and SVEC #72800

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

Merged
merged 2 commits into from
Apr 3, 2024
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
26 changes: 26 additions & 0 deletions stdlib/public/core/Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7102,3 +7102,29 @@ extension SingleValueDecodingContainer {
)
}
}

// Default implementations for types with stricter availability than SVEC & UEC
// We need these to break ambiguity when an encoding container conforms to both.
extension SingleValueEncodingContainer where Self: UnkeyedEncodingContainer {
@available(SwiftStdlib 6.0, *)
public mutating func encode(_ value: Int128) throws {
throw EncodingError.invalidValue(
value,
EncodingError.Context(
codingPath: codingPath,
debugDescription: "Encoder has not implemented support for Int128"
)
)
}

@available(SwiftStdlib 6.0, *)
public mutating func encode(_ value: UInt128) throws {
throw EncodingError.invalidValue(
value,
EncodingError.Context(
codingPath: codingPath,
debugDescription: "Encoder has not implemented support for UInt128"
)
)
}
}
2 changes: 2 additions & 0 deletions test/abi/macOS/arm64/stdlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ Added: _$ss28SingleValueDecodingContainerPsE6decodeys6Int128VAEmKF
Added: _$ss28SingleValueEncodingContainerP6encodeyys6Int128VKFTj
Added: _$ss28SingleValueEncodingContainerP6encodeyys6Int128VKFTq
Added: _$ss28SingleValueEncodingContainerPsE6encodeyys6Int128VKF
Added: _$ss28SingleValueEncodingContainerPss07UnkeyedcD0RzrlE6encodeyys6Int128VKF
Added: _$ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys6Int128VSgAFm_0I0QztKFTj
Added: _$ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys6Int128VSgAFm_0I0QztKFTq
Added: _$ss30KeyedDecodingContainerProtocolP6decode_6forKeys6Int128VAFm_0G0QztKFTj
Expand Down Expand Up @@ -408,6 +409,7 @@ Added: _$ss28SingleValueDecodingContainerPsE6decodeys7UInt128VAEmKF
Added: _$ss28SingleValueEncodingContainerP6encodeyys7UInt128VKFTj
Added: _$ss28SingleValueEncodingContainerP6encodeyys7UInt128VKFTq
Added: _$ss28SingleValueEncodingContainerPsE6encodeyys7UInt128VKF
Added: _$ss28SingleValueEncodingContainerPss07UnkeyedcD0RzrlE6encodeyys7UInt128VKF
Added: _$ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys7UInt128VSgAFm_0I0QztKFTj
Added: _$ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys7UInt128VSgAFm_0I0QztKFTq
Added: _$ss30KeyedDecodingContainerProtocolP6decode_6forKeys7UInt128VAFm_0G0QztKFTj
Expand Down
2 changes: 2 additions & 0 deletions test/abi/macOS/x86_64/stdlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ Added: _$ss28SingleValueDecodingContainerPsE6decodeys6Int128VAEmKF
Added: _$ss28SingleValueEncodingContainerP6encodeyys6Int128VKFTj
Added: _$ss28SingleValueEncodingContainerP6encodeyys6Int128VKFTq
Added: _$ss28SingleValueEncodingContainerPsE6encodeyys6Int128VKF
Added: _$ss28SingleValueEncodingContainerPss07UnkeyedcD0RzrlE6encodeyys6Int128VKF
Added: _$ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys6Int128VSgAFm_0I0QztKFTj
Added: _$ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys6Int128VSgAFm_0I0QztKFTq
Added: _$ss30KeyedDecodingContainerProtocolP6decode_6forKeys6Int128VAFm_0G0QztKFTj
Expand Down Expand Up @@ -408,6 +409,7 @@ Added: _$ss28SingleValueDecodingContainerPsE6decodeys7UInt128VAEmKF
Added: _$ss28SingleValueEncodingContainerP6encodeyys7UInt128VKFTj
Added: _$ss28SingleValueEncodingContainerP6encodeyys7UInt128VKFTq
Added: _$ss28SingleValueEncodingContainerPsE6encodeyys7UInt128VKF
Added: _$ss28SingleValueEncodingContainerPss07UnkeyedcD0RzrlE6encodeyys7UInt128VKF
Added: _$ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys7UInt128VSgAFm_0I0QztKFTj
Added: _$ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys7UInt128VSgAFm_0I0QztKFTq
Added: _$ss30KeyedDecodingContainerProtocolP6decode_6forKeys7UInt128VAFm_0G0QztKFTj
Expand Down