Skip to content

SourceKit: do not print implementation-only imports #35575

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 1 commit into from
Jan 27, 2021

Conversation

egorzhdan
Copy link
Contributor

Implementation-only imports are unnecessary in generated module interfaces, since they don't have an effect on the module's public interface:

  • implementation-only imports aren't exported to the module's dependencies
  • module's public API cannot reference symbols imported as implementation-only.

This change hides @_implementationOnly imports from generated Swift module interfaces.

It allows, for example, to hide import Darwin/import WinSDK/import Glibc statements from SwiftPM's PackageDescription library interface.

Implementation-only imports are unnecessary in generated module interfaces, since they aren't exported to the module's dependencies, and the module's public API cannot refer to symbols imported as implementation-only.
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Jan 27, 2021

This looks quite reasonable, thank you. I would love it if we could have a dedicated test under test/IDE that checks to make sure we print @_implementationOnly, @_exported, and @_private but it can be done in a follow-up PR.

@CodaFi CodaFi requested a review from akyrtzi January 27, 2021 21:39
@egorzhdan
Copy link
Contributor Author

@CodaFi hmm, not sure I understand it correctly – there's already a test checking that @_implementationOnly isn't printed in the generated module interface (test/Serialization/Recovery/implementation-only-override.swift) and a few tests for the @_exported attribute (for example, test/IDE/print_clang_framework_with_overlay.swift).

implementation-only-override.swift uses swift-ide-test, perhaps it could have been placed under test/IDE as well.

Is there an untested part that I'm missing?

@CodaFi
Copy link
Contributor

CodaFi commented Jan 31, 2021

The test under Serialization is trying to make sure that overrides from implementation-only imports can be serialized without issue and show up in the generated interface. I would like a dedicated test for just the expectation that attribute-qualified imports show up in the generated interface - to keep our concerns well separated.

@egorzhdan
Copy link
Contributor Author

Ah, okay, sounds fair to me. I've sent a new PR with a test: #35706

@egorzhdan egorzhdan deleted the sk-impl-only branch February 3, 2021 10:25
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