Skip to content

[Sema] Warn on @_spi imports of modules built from their public interface #34912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 2, 2020

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Dec 1, 2020

This warning should help understand missing SPI diagnostics when the
compiler loads a public module when a private one is expected.

rdar://71859081

…face

This warning should help understand missing SPI diagnostics when the
compiler loads a public module when a private one is expected.

rdar://71859081
@xymus xymus requested review from beccadax and nkcsgexi December 1, 2020 19:33
@xymus
Copy link
Contributor Author

xymus commented Dec 1, 2020

@swift-ci Please smoke test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

Makes sense to me!

// RUN: rm %t/SPIHelper.private.swiftinterface
// RUN: %target-typecheck-verify-swift -I %t

@_spi(SPIHelper) import SPIHelper // expected-warning {{importation of 'SPIHelper' has an ineffective '@_spi' attribute; it was built from the public interface at}}
Copy link
Contributor

Choose a reason for hiding this comment

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

This message is a bit confusing -- can it say something along the lines of import of 'SPIHelper' will not include SPI symbols, since it was built from the public interface at ...

And could you add a note with a Fix-It to remove the @_spi attribute?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion, I updated the diagnostic message.

For now I prefer to avoid having a fix-it here because removing the attribute is not the solution to where I expect to see this error. The likely solution is probably to change the framework search paths or something like that.

@xymus
Copy link
Contributor Author

xymus commented Dec 1, 2020

@swift-ci Please smoke test

@xymus xymus merged commit 6328fe3 into swiftlang:main Dec 2, 2020
@xymus xymus deleted the warn-ineffective-spi-import branch December 2, 2020 00:04
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