Skip to content

Conversation

@xymus
Copy link
Contributor

@xymus xymus commented Sep 12, 2022

Check that an @_spiOnly attribute isn't used with @_implementationOnly or @_exported on the same import statement or in the same source file. This check is partially integrated with the existing check for @_implementationOnly consistency. This could be integrated further once we have a per-file implementation-only import alternative, for now the differences between @_implementationOnly and @_spiOnly makes it a bit messy.

For clarification, here's what we check:

  • (updated) Raise an error if incompatible import modifiers are used on the same import statement. Only one or none of the following can be used at a time: @_spiOnly, @_implementationOnly and @_exported.
  • (new) Raise an error on inconsistent @_spiOnly imports of the same target within one source file.
  • (old, for reference) Report as a warning inconsistent @_implementationOnly imports of the same target within a module.

Follows the integration with API checks from #61023. This should complete the main feature, but of course, further tweaks will likely be needed.

@xymus xymus requested review from elsh and tshortli September 12, 2022 21:51
@xymus
Copy link
Contributor Author

xymus commented Sep 12, 2022

@swift-ci Please smoke test

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this is based off of a hardcoded string instead of being a %select{...} in the diagnostic? I don't know if this is an eventual goal, but it seems like it would be easier to localize a diagnostic that uses select.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was an oversight. The last commit should update it to the usual pattern. The ImportFlags enum is sparse as it's a kind of option set, so it required more logic than usual.

Break findInconsistentImportsAcrossFile into two services, one finding
inconsistencies across a whole module and a new one finding them across
a single file.
@xymus xymus force-pushed the spi-only-consistent branch from a557f93 to 99d9beb Compare September 13, 2022 00:32
@xymus
Copy link
Contributor Author

xymus commented Sep 13, 2022

@swift-ci Please smoke test

@xymus xymus merged commit 2cb6d72 into swiftlang:main Sep 13, 2022
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