Skip to content

🍒 [Swiftify] don't unwrap pointers for UP! when not needed#89733

Merged
hnrklssn merged 2 commits into
swiftlang:release/6.4.xfrom
hnrklssn:swiftify-implicitly-not-unwrapped-6.4
Jun 6, 2026
Merged

🍒 [Swiftify] don't unwrap pointers for UP! when not needed#89733
hnrklssn merged 2 commits into
swiftlang:release/6.4.xfrom
hnrklssn:swiftify-implicitly-not-unwrapped-6.4

Conversation

@hnrklssn
Copy link
Copy Markdown
Member

@hnrklssn hnrklssn commented Jun 6, 2026

  • Explanation:
    When passing an empty Span to the safe wrapper of a function annotated with counted_by without _Nullable the wrapper would unwrap a nil base pointer, even though the function accepts a nil pointer (and counted_by promises not to dereference it, since the length is 0). This updates the generated wrapper to not unwrap when not necessary.
  • Scope:
    Can now pass empty Span to counted_by without explicit nullability (but still not _Nonnull, since that signature explicitly bans null) without trapping. No signature change.
  • Issues:
    rdar://177555277
  • Original PRs:
    [Swiftify] don't unwrap pointers for UP! when not needed #89455
  • Risk:
    Low, should strictly allow more cases before (at runtime)
  • Testing:
    Lit testing
  • Reviewers:
    @j-hui

hnrklssn added 2 commits June 5, 2026 17:53
[Swiftify] implement counted_by_or_null, and remove Optional from counted_by

(cherry picked from commit ca0dc75)
…not-unwrapped

[Swiftify] don't unwrap pointers for UP! when not needed

(cherry picked from commit dd08137)
@hnrklssn hnrklssn requested a review from j-hui June 6, 2026 03:17
@hnrklssn hnrklssn requested a review from a team as a code owner June 6, 2026 03:17
@hnrklssn
Copy link
Copy Markdown
Member Author

hnrklssn commented Jun 6, 2026

stacked on top of #89732

@hnrklssn
Copy link
Copy Markdown
Member Author

hnrklssn commented Jun 6, 2026

@swift-ci please test

@hnrklssn hnrklssn changed the title Swiftify implicitly not unwrapped 6.4 🍒 [Swiftify] don't unwrap pointers for UP! when not needed Jun 6, 2026
@hnrklssn hnrklssn merged commit 4bf56d2 into swiftlang:release/6.4.x Jun 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants