-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[6.0][stdlib] Round out ~Copyable generalizations in stdlib primitives #73079
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
[6.0][stdlib] Round out ~Copyable generalizations in stdlib primitives #73079
Conversation
- `Optional.map`, `.flatMap`: Allow noncopyable results. Implement typed throws. - `Result.map`, `.flatMap`: Allow noncopyable types for the new success. - `Result.flatMapError`: Generalize for noncopyable Success. - `Unsafe[Mutable][Buffer]Pointer.withMemoryRebound`: Alllow typed throws. - `Unsafe[Mutable]BufferPointer: Generalize CustomDebugStringConvertible conformance for noncopyable `Element`s. - `OpaquePointer.init(_: UnsafeMutablePointer)`, `.init(_: UnsafeMutablePointer?)`: Allow noncopyable pointee types. - `ManagedBuffer.withUnsafeMutablePointerToHeader`, `.withUnsafeMutablePointerToElements`, `.withUnsafeMutablePointers`: Generalize for typed throws and noncopyable return types. Avoid `@_preInverseGenerics`. - `ManagedBufferPointer`: Ditto. - `withExtendedLifetime`: Use typed throws. Stop using `@_preInverseGenerics`. rdar://117753275 (cherry picked from commit cafc993)
We can’t do typed throws here yet. (They involve implicit stack allocations that interfere with the explicit stack allocation builtins.) (cherry picked from commit 5679bf6)
… → borrowing) (cherry picked from commit fab25dc)
(cherry picked from commit a681a3d)
swiftlang#73045 has uncovered a compiler crash with existing code of this form: try withExtendedLifetime(statement) { // 💥silgen crash do { try dbPool.close() XCTFail("Expected Error") } catch DatabaseError.SQLITE_BUSY { } } This patterns can happen with any of the newly typed throwing entry points, but the source compat suite only seems to have caught this with `withExtendedLifetime`; let’s see if we can get away with only rolling back this one. (cherry picked from commit 153c001)
…ound a shadowing issue The new ~Copyable generalizations have changed the function signature enough that alternative definitions of `map`/`flatMap` in existing code that used to be considered to shadow the originals no longer do so. This leads to use sites becoming ambiguous — a source break. While we consider approaches to resolve this on the compiler side, let’s try slapping a `@_disfavoredOverload` on these and see if that helps. (cherry picked from commit c6bc196)
(cherry picked from commit 1b89293)
Note: The original PR is still in review. I'm submitting this draft early so that I can get a head start on any test failures specific to this branch. |
@swift-ci test |
@swift-ci test source compatibility |
There is a single source compat defect in swift-distributed-actors, and it is the same (unrelated) issue we've seen on main.
This issue isn't related to the changes in this PR. (It appears a fix may have recently landed, as more recent runs have turned green.) |
Uh oh!
There was an error while loading. Please reload this page.