Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Oct 16, 2025

This PR ensures that Attachment conforms to CustomStringConvertible even if the value it wraps is non-copyable. We accomplish this by creating a new helper function that is able to box an arbitrary ~Copyable value in Any if its type is actually Copyable. (This requires a newer runtime on Apple platforms, so we fall back to a generic (~Copyable) implementation on older macOS/iOS/etc.) We then call this helper function in Attachment.description and if it returns a value, we can stringify it.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR ensures that `Attachment` conforms to `CustomStringConvertible` even if
the value it wraps is non-copyable. We accomplish this by creating a new helper
function that is able to box an arbitrary `~Copyable` value in `Any` if its type
is actually `Copyable`. (This requires a newer runtime on Apple platforms, so we
fall back to a generic (`~Copyable`) implementation on older macOS/iOS/etc.) We
then call this helper function in `Attachment.description` and if it returns a
value, we can stringify it.
@grynspan grynspan added this to the Swift 6.x (main) milestone Oct 16, 2025
@grynspan grynspan self-assigned this Oct 16, 2025
@grynspan grynspan added the enhancement New feature or request label Oct 16, 2025
@grynspan grynspan added the command-line experience ⌨️ enhancements to the command line interface label Oct 16, 2025
@grynspan grynspan added the attachments/activities 🖇️ Work related to attachments and/or activities label Oct 16, 2025
@grynspan grynspan requested a review from jerryjrchen as a code owner October 16, 2025 16:18
Copy link
Contributor

@jerryjrchen jerryjrchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Are there already existing test cases that test the Attachment description behaviours? If not, would it be feasible to include as part of this PR?

@grynspan
Copy link
Contributor Author

We already have test coverage, yes.

@grynspan
Copy link
Contributor Author

Holding for @stmontgomery to look at.

@grynspan grynspan merged commit e037023 into main Oct 20, 2025
24 checks passed
@grynspan grynspan deleted the jgrynspan/attachment-always-conform-to-customstringconvertible branch October 20, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attachments/activities 🖇️ Work related to attachments and/or activities command-line experience ⌨️ enhancements to the command line interface enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants