Open
Description
Description
Automatic synthesis of hashable, encodable, and decodable proceeds without issue when containing a nested type with an unavailable conformance.
Reproduction
The following compiles when it shouldn't:
struct G {
var g: Int
}
@available(*, unavailable)
extension G: Encodable {
func encode(to encoder: any Encoder) throws {
fatalError()
}
}
@available(*, unavailable)
extension G: Decodable {
init(from decoder: any Decoder) throws {
fatalError()
}
}
struct S: Codable {
var x = G(g: 1)
}
Another example using Hashable
:
struct G: Equatable {
var g: Int
}
@available(*, unavailable)
extension G: Hashable {
func hash(into hasher: inout Hasher) {
fatalError()
}
}
struct S: Hashable {
var x = G(g: 1)
}
Expected behavior
I expect the conformances to not be synthesized with a compile-time error.
Environment
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
Additional information
No response