Skip to content
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

[SR-11901] extensions on directly depended on types are polluted from transitive dependencies #54318

Closed
keith opened this issue Dec 5, 2019 · 2 comments
Assignees

Comments

@keith
Copy link
Collaborator

keith commented Dec 5, 2019

Previous ID SR-11901
Radar rdar://problem/16154294
Original Reporter @keith
Type Improvement

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s
Labels Improvement
Assignee None
Priority Medium

md5: 1d53b710921ee26cf7a64bfe9dee53f4

Issue Description:

See the attached sample project and run `swift build` it should fail but it doesn't, see below for details.

Currently there is a case with transitive modules where you do not have to import a module to get extensions from it if you import the module containing the type its extending, and a module that depends on the module adding the extension. This is fixed if you add `@_implementationOnly` to the import of the module that adds the extension, but ideally it would be required to import any module you use an extension from (unless it's explicitly `@_exported`

In the sample project you can see that `import transitive` pollutes the `funcFromExtension` into the main `import-pollution` target. By changing the import to `@_implementationOnly import extender` you fix this issue.

I know this has been an issue for a long time since this also applies to extensions on types defined in system modules, and because of that it may never be "fixed" since it would be a source incompatible change, but I wanted to have an issue about this since I couldn't find any others.

In projects with many modules this makes it hard to keep your dependency graph actually explicit and introduces surprises when you remove a dependency on a module and end up losing transitive dependencies you were implicitly depending on.

@beccadax
Copy link
Contributor

beccadax commented Dec 6, 2019

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@tshortli tshortli self-assigned this Sep 22, 2023
@tshortli
Copy link
Contributor

Duplicate of #46493.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants