-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SE-0163] Migrate from deprecated Unicode APIs #32920
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
Conversation
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.
6477ba7
to
3cc0ad1
Compare
@swift-ci Please smoke test |
@inlinable | ||
public static func == ( | ||
lhs: UnicodeDecodingResult, | ||
rhs: UnicodeDecodingResult | ||
) -> Bool { | ||
switch (lhs, rhs) { | ||
case (.scalarValue(let lhsScalar), .scalarValue(let rhsScalar)): | ||
return lhsScalar == rhsScalar | ||
case (.emptyInput, .emptyInput): | ||
return true | ||
case (.error, .error): | ||
return true | ||
default: | ||
return false | ||
} | ||
} |
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 can be synthesized by the compiler.
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 is not exactly the same, because the synthesized definition isn’t inlinable. How that will affect performance/code size of code using these APIs is difficult to predict.
} | ||
|
||
extension Unicode.UTF8 { |
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 non-deprecated APIs could be moved into UTF8.swift:
Unicode.UTF8.isContinuation(_:)
Unicode.UTF8._nullCodeUnitOffset(in:)
Unicode.UTF8._decodeOne(_:)
(used in UnicodeLongTest.swift)
The deprecated APIs could be moved into MigrationSupport.swift:
UnicodeDecodingResult
enum,UnicodeCodec
protocol and conformances.
The unused APIs could be moved into LegacyABI.swift:
Unicode.UTF16._decodeOne(_:)
transcode(_:_:_:_:stopOnError:)
(unavailable since Swift 3).
@CodaFi Please could you review, and merge if possible? I've added some comments above, for anything which requires more attention or follow-up PRs. |
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.
Benchmarks and test changes LGTM. But @milseman or @airspeedswift should sign off on the stdlib changes
@swift-ci benchmark |
This comment has been minimized.
This comment has been minimized.
I realize this went through SE quite a while ago, but I think it's a bad idea to formally remove the Unicode aliases, especially for UTF8/UTF16. |
//===--- Slicing Support --------------------------------------------------===// | ||
|
||
// @available(swift,deprecated: 5.0, renamed: "Unicode.UTF8") | ||
@available(swift, deprecated: 100000, /*obsoleted: TODO,*/ renamed: "Unicode.UTF8") |
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.
Even if these deprecations were part of SE-0163, and even if we tie them into a new language mode, implementing them at this point would be wildly disruptive. Swift 4.0 with SE-0163 was released three years ago; a huge amount of Swift code has been written since then that uses these names. Thus, I believe these changes would deserve a standalone proposal.
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.
Also, that batch of SEs were part of a larger attempt to reformulate strings that didn't pan out in practice. They have several portions that weren't fully thought through, much less implemented, so I don't think we want to blindly apply them without some reevaluation.
Why? The version number 100000 has no special meaning, and it should not appear in any compiler diagnostics or generated documentation. If the reason why SE-0163 intended to deprecate these names still stands, then I think we should reconfirm this through swift-evolution and set the deprecation to a valid version number. |
@lorentey Version number 100000 is from the It seems to affect only the documentation, at least when applied to an OS availability attribute. For example, in SwiftUI the @available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Sets this view's color scheme.
///
/// Use `colorScheme(_:)` to set the color scheme for the view to which you
/// apply it and any subviews. If you want to set the color scheme for all
/// views in the presentation, use ``View/preferredColorScheme(_:)``
/// instead.
///
/// - Parameter colorScheme: The color scheme for this view.
///
/// - Returns: A view that sets this view's color scheme.
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@available(OSX, introduced: 10.15, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")
@inlinable public func colorScheme(_ colorScheme: ColorScheme) -> some View
} |
3cc0ad1
to
90c4e4b
Compare
90c4e4b
to
f5421bd
Compare
@swift-ci Please smoke test |
The 9999s we use elsewhere set an unfortunate precedent for doing such things; I guess it's time to replace them too with a better system. |
UnicodeCodec
,UnicodeDecodingResult
, and some typealiases were deprecated by the SE-0163 proposal.