Skip to content

Conversation

@atrick
Copy link
Contributor

@atrick atrick commented Jun 16, 2025

(cherry picked from commit 125a086)

--- CCC ---

Explanation: This fixes a small oversight in the type checker's LifetimeDependence inference. Allow inference on _read accessors even when 'self' is a trivial type. This is needed because the compiler synthesizes a _read accessor even when the user defines a getter (this is probably a mistake, but it's easire to just fix inference at this point). There is no workaround because it defining both a getter and '_read' is illegal! Allows:

    extension UnsafeMutableRawBufferPointer {
      var mutableBytes: MutableRawSpan {
        @_lifetime(borrow self)
        get {
          unsafe MutableRawSpan(_unsafeBytes: self)
        }
      }

Scope: Only affects users of the supported experiment Lifetimes feature.

Radar/SR Issue: rdar://153346478 (Can't compile the UnsafeMutableRawBufferPointer.mutableBytes property)

main PR: #82268

Risk: Low

Testing: Added unit tests

Reviewer: Meghana Gupta

This fixes a small oversight in the type checker's LifetimeDependence
inference. Allow inference on _read accessors even when 'self' is a trivial
type. This is needed because the compiler synthesizes a _read accessor even when
the user defines a getter (this is probably a mistake, but it's easire to just
fix inference at this point). There is no workaround because it defining both a
getter and '_read' is illegal!

    extension UnsafeMutableRawBufferPointer {
      var mutableBytes: MutableRawSpan {
        @_lifetime(borrow self)
        get {
          unsafe MutableRawSpan(_unsafeBytes: self)
        }
      }
    }

Fixes rdar://153346478 (Can't compile the
UnsafeMutableRawBufferPointer.mutableBytes property)

(cherry picked from commit 125a086)
@atrick atrick requested a review from a team as a code owner June 16, 2025 17:52
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jun 16, 2025
@atrick
Copy link
Contributor Author

atrick commented Jun 16, 2025

@swift-ci test

@atrick atrick requested a review from meg-gupta June 16, 2025 17:56
@atrick
Copy link
Contributor Author

atrick commented Jun 16, 2025

@swift-ci test macOS platform

@atrick
Copy link
Contributor Author

atrick commented Jun 17, 2025

Timed Out Tests (1):
lldb-api :: lang/swift/embedded/frame_variable/TestSwiftEmbeddedFrameVariable.py

@atrick
Copy link
Contributor Author

atrick commented Jun 17, 2025

@swift-ci test macOS

@atrick atrick merged commit d242750 into swiftlang:release/6.2 Jun 17, 2025
5 checks passed
@atrick atrick deleted the 62-infer-implicit-read branch June 17, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 release cherry pick Flag: Release branch cherry picks swift 6.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants