-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Added Hashable conformance to Async(Throwing)Stream.Continuation #79457
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
Added Hashable conformance to Async(Throwing)Stream.Continuation #79457
Conversation
I think we'll need to take this through evolution; the type is not frozen and in general any public api changes need to be evolved. |
Evolution PR - swiftlang/swift-evolution#2700 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was accepted through evolution
@swift-ci please smoke test |
To fix failing test/api-digester/stability-concurrency-abi.test
f37c498
to
d8cbaeb
Compare
return hasher.combine(ObjectIdentifier(storage)) | ||
} | ||
@available(SwiftStdlib 9999, *) | ||
public var hashValue: Int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why that, isn't the hash function enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently no. If omitted it gets synthesised as expected, but then test complains that it does not have availability annotations. I'm not sure if this is expected or a bug in code gen of the Hashable conformance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this expected @lorentey ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely is a bug! Conformances with availability are a relatively recent development, and evidently we have not yet tried to combine them with synthesized requirements. The expected behavior is that the synthesized requirement would match the availability of the conformance itself.
It feels like this might be a good candidate for a starter task in compiler development.
(The hashValue
as implemented matches the synthesized one; when the compiler issue is resolved, then it can simply be deleted to have it be replaced with the implicit default.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hang on -- can you tell me what test is failing?
The compiler itself seems fine with it; this compiles with no diagnostic:
@available(macOS 11, *)
public struct Foo {
public var value: Int
}
@available(macOS 12, *)
extension Foo: Hashable {
@available(macOS 12, *)
public func hash(into hasher: inout Hasher) {
hasher.combine(value)
}
}
The generated .swiftinterface indeed doesn't set availability directly on the synthesized members (==
and hashValue
), but they still inherit that from the extension's own context:
import Swift
import _Concurrency
import _StringProcessing
import _SwiftConcurrencyShims
@available(macOS 11, *)
public struct Foo {
public var value: Swift.Int
}
@available(macOS 12, *)
extension foo.Foo : Swift.Hashable {
@available(macOS 12, *)
public func hash(into hasher: inout Swift.Hasher)
public static func == (a: foo.Foo, b: foo.Foo) -> Swift.Bool
public var hashValue: Swift.Int {
get
}
}
This sounds like it might actually be due to an overzealous test that attempts to analyze the interface. (If my diagnosis is correct, then the choice is between seeing if the test can be adjusted, or changing the compiler to generate the extra @available
attributes anyway.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failing test was test/api-digester/stability-concurrency-abi.test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that makes sense.
@swift-ci please smoke test |
|
@swift-ci please smoke test Linux |
1 similar comment
@swift-ci please smoke test Linux |
Unrelated failure
|
Was done in: swiftlang/swift#79457 We missed the 6.2 cherry pick, I'll do that
See the pitch.