Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Feb 19, 2025

This PR replaces calls to unsafeBitCast(_:to:) (where the value being cast is a C function pointer) with calls to an internal function that checks that the value being cast is actually a C function pointer. This is intended to make the code in question more self-documenting (by making it clear what kind of cast is being performed.)

The function does then call unsafeBitCast(_:to:), but it's in one place only instead of many places—the call sites are all now self-documenting.

Also fixed one place we're using unsafeBitCast(_:to:) to cast a metatype where, as of Swift 6.1, we don't need to anymore.

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 replaces calls to `unsafeBitCast(_:to:)` (where the value being cast is
a C function pointer) with calls to an internal function that checks that the
value being cast is actually a C function pointer. This is intended to make the
code in question more self-documenting (by making it clear what kind of cast is
being performed.)

Also fixed one place we're using `unsafeBitCast(_:to:)` to cast a metatype
where, as of Swift 6.1, we don't need to anymore.
@grynspan grynspan added the enhancement New feature or request label Feb 19, 2025
@grynspan grynspan added this to the Swift 6.x milestone Feb 19, 2025
@grynspan grynspan self-assigned this Feb 19, 2025
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan merged commit eaae48c into main Feb 20, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/fewer-unsafebitcast-calls branch February 20, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants