Skip to content

Conversation

@xymus
Copy link
Contributor

@xymus xymus commented Dec 10, 2025

The new experimental compiler feature CheckImplementationOnly enables type-checking the uses of @_implementationOnly imports when building without library-evolution. I tried enabling this check on the driver project and it reported one potential issue, this PR should address it.

The issue is on a property in a struct with the static type of CSwiftScan.swiftscan_cached_compilation_t where CSwiftScan is @_implementationOnly imported. This means that clients using this struct wouldn't see the right memory layout information unless they import CSwiftScan too. This may not have been an issue in practice if the type was used only within the same module.

I'm suggesting a fix here. Keeping a reference to CachedCompilation should be safe as it's a class that hides the memory layout from the clients.

We should adopt CheckImplementationOnly in the driver once it's completed, some early versions of it were too strict.

The new experimental compiler feature `CheckImplementationOnly` enables
type-checking the use of `@_implementationOnly` imports when
building without library-evolution. I tried enabling this check on the
driver project and it reported one potential issue that I hope to fix
here.

The issue is a property in a struct with the static type of
`CSwiftScan.swiftscan_cached_compilation_t` where `CSwiftScan` is
`@_implementationOnly` imported. This means that clients using this
structs wouldn't see the right memory layout information unless they
import `CSwiftScan` too. This may not have been an issue in practice if
the type was used only within the same module.

I'm suggesting a fix here. Keeping a reference to `CachedCompilation`
should be safe as it's a class that hides the memory layout from the
clients.

We should adopt `CheckImplementationOnly` in the driver once it's
completed, some early versions of it were too strict.
Copy link
Contributor

@cachemeifyoucan cachemeifyoucan left a comment

Choose a reason for hiding this comment

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

LGTM.

@cachemeifyoucan
Copy link
Contributor

@swift-ci please test

@xymus xymus merged commit bfcec90 into swiftlang:main Dec 11, 2025
15 of 16 checks passed
@xymus xymus deleted the safe-ioi-in-nle branch December 11, 2025 22:31
@artemcm
Copy link
Contributor

artemcm commented Dec 11, 2025

Nice!

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.

3 participants