-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger #19006
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
[Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger #19006
Conversation
@swift-ci please smoke test |
@swift-ci please test source compatibility |
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 remember looking at making this change and deciding that it did the wrong thing for unsigned integers. Since the code is just a bit pattern, you want to reinterpret-cast between Int and the raw type rather than numeric-cast.
@swift-ci please test |
@swift-ci please test source compatibility |
1 similar comment
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test Linux |
@swift-ci please test source compatibility |
@swift-ci please smoke test Linux |
4 similar comments
@swift-ci please smoke test Linux |
@swift-ci please smoke test Linux |
@swift-ci please smoke test Linux |
@swift-ci please smoke test Linux |
Build failed |
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 guess this works. Don't forget to update corelibs Foundation too.
4536099
to
d1d85aa
Compare
…dWidthInteger. Simplify the default implementations provided for RawRepresentable error types whose raw values are integral, replacing duplicated code (for SignedInteger or UnsignedInteger) with a single constraint on BinaryInteger. Fixes rdar://problem/35230187.
When working with Error types with unsigned raw values, numeric-cast into a UInt and then map the bits over to an Int so we preserve values not representable in an Int without wrapping. Thanks to @jrose-apple for pointing this out!
d1d85aa
to
f64d5db
Compare
@swift-ci please smoke test |
Corelibs Foundation bit is in swiftlang/swift-corelibs-foundation#1675 |
@swift-ci please smoke test |
@swift-ci please smoke test Linux |
Simplify the default implementations provided for RawRepresentable
error types whose raw values are integral, replacing duplicated code
(for SignedInteger or UnsignedInteger) with a single constraint on
BinaryInteger.
Fixes rdar://problem/35230187.