Skip to content

Conversation

@beccadax
Copy link
Contributor

Previously, if a declaration belonged to a module with an export_as attribute, Swift always used the exported module name in the public module interface and the real module name in the private module interface. However, this is only a rough approximation of the behavior we really want, which is to use the real name in module interfaces that might be imported by dependencies of the exported name.

Change this logic so that public interfaces always use the exported name, and private interfaces use the exported name only if a module with that name has been loaded. This should make it so that if you’re building the export_as module or anything that imports it, you use the exported name; otherwise you use the real name.

Fixes rdar://167874630.

Duplicated set of commands, FileCheck use pattern that produces suboptimal diagnostics.
Previously, if a declaration belonged to a module with an `export_as` attribute, Swift always used the exported module name in the public module interface and the real module name in the private module interface. However, this is only a rough approximation of the behavior we really want, which is to use the real name in module interfaces that might be imported by dependencies of the exported name.

Change this logic so that public interfaces always use the exported name, and private interfaces use the exported name *only* if a module with that name has been loaded. This should make it so that if you’re building the `export_as` module or anything that imports it, you use the exported name; otherwise you use the real name.

Fixes rdar://167874630.
@beccadax
Copy link
Contributor Author

@swift-ci please test

@beccadax beccadax merged commit fce99b3 into swiftlang:main Jan 29, 2026
5 checks passed
beccadax added a commit to beccadax/swift that referenced this pull request Jan 30, 2026
In swiftlang#86859, I modified the way `export_as` names are used in private module interfaces so that the `export_as` name is used when that module has been imported. This turns out to be slightly too aggressive in a specific scenario where a submodule of the export_as module imports a submodule of the real module—the compiler ends up using the export name even though the resulting lookup won’t actually work.

Modify the logic for deciding whether to use an exported module name so that it not only checks whether the export_as module has been loaded, but also whether the specific module or submodule the declaration belongs to is (possibly transitively) imported by that module.

Fixes rdar://167874630 (harder).
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