Skip to content

Further ambiguity breakers for UDC & SEDC #72822

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
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 @@ -7128,3 +7128,29 @@ extension SingleValueEncodingContainer where Self: UnkeyedEncodingContainer {
)
}
}

// Default implementations for types with stricter availability than SVDC & UDC
// We need these to break ambiguity when an encoding container conforms to both.
extension SingleValueDecodingContainer where Self: UnkeyedDecodingContainer {
@available(SwiftStdlib 6.0, *)
public func decode(_ type: Int128.Type) throws -> Int128 {
throw DecodingError.typeMismatch(
Int128.self,
DecodingError.Context(
codingPath: codingPath,
debugDescription: "Decoder has not implemented support for Int128"
)
)
}

@available(SwiftStdlib 6.0, *)
public func decode(_ type: UInt128.Type) throws -> UInt128 {
throw DecodingError.typeMismatch(
UInt128.self,
DecodingError.Context(
codingPath: codingPath,
debugDescription: "Decoder 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 @@ -268,6 +268,7 @@ Added: _$ss24UnkeyedEncodingContainerPsE6encodeyys6Int128VKF
Added: _$ss28SingleValueDecodingContainerP6decodeys6Int128VAEmKFTj
Added: _$ss28SingleValueDecodingContainerP6decodeys6Int128VAEmKFTq
Added: _$ss28SingleValueDecodingContainerPsE6decodeys6Int128VAEmKF
Added: _$ss28SingleValueDecodingContainerPss07UnkeyedcD0RzrlE6decodeys6Int128VAFmKF
Added: _$ss28SingleValueEncodingContainerP6encodeyys6Int128VKFTj
Added: _$ss28SingleValueEncodingContainerP6encodeyys6Int128VKFTq
Added: _$ss28SingleValueEncodingContainerPsE6encodeyys6Int128VKF
Expand Down Expand Up @@ -406,6 +407,7 @@ Added: _$ss24UnkeyedEncodingContainerPsE6encodeyys7UInt128VKF
Added: _$ss28SingleValueDecodingContainerP6decodeys7UInt128VAEmKFTj
Added: _$ss28SingleValueDecodingContainerP6decodeys7UInt128VAEmKFTq
Added: _$ss28SingleValueDecodingContainerPsE6decodeys7UInt128VAEmKF
Added: _$ss28SingleValueDecodingContainerPss07UnkeyedcD0RzrlE6decodeys7UInt128VAFmKF
Added: _$ss28SingleValueEncodingContainerP6encodeyys7UInt128VKFTj
Added: _$ss28SingleValueEncodingContainerP6encodeyys7UInt128VKFTq
Added: _$ss28SingleValueEncodingContainerPsE6encodeyys7UInt128VKF
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 @@ -268,6 +268,7 @@ Added: _$ss24UnkeyedEncodingContainerPsE6encodeyys6Int128VKF
Added: _$ss28SingleValueDecodingContainerP6decodeys6Int128VAEmKFTj
Added: _$ss28SingleValueDecodingContainerP6decodeys6Int128VAEmKFTq
Added: _$ss28SingleValueDecodingContainerPsE6decodeys6Int128VAEmKF
Added: _$ss28SingleValueDecodingContainerPss07UnkeyedcD0RzrlE6decodeys6Int128VAFmKF
Added: _$ss28SingleValueEncodingContainerP6encodeyys6Int128VKFTj
Added: _$ss28SingleValueEncodingContainerP6encodeyys6Int128VKFTq
Added: _$ss28SingleValueEncodingContainerPsE6encodeyys6Int128VKF
Expand Down Expand Up @@ -406,6 +407,7 @@ Added: _$ss24UnkeyedEncodingContainerPsE6encodeyys7UInt128VKF
Added: _$ss28SingleValueDecodingContainerP6decodeys7UInt128VAEmKFTj
Added: _$ss28SingleValueDecodingContainerP6decodeys7UInt128VAEmKFTq
Added: _$ss28SingleValueDecodingContainerPsE6decodeys7UInt128VAEmKF
Added: _$ss28SingleValueDecodingContainerPss07UnkeyedcD0RzrlE6decodeys7UInt128VAFmKF
Added: _$ss28SingleValueEncodingContainerP6encodeyys7UInt128VKFTj
Added: _$ss28SingleValueEncodingContainerP6encodeyys7UInt128VKFTq
Added: _$ss28SingleValueEncodingContainerPsE6encodeyys7UInt128VKF
Expand Down