Skip to content

Conversation

@beccadax
Copy link
Contributor

@beccadax beccadax commented Oct 21, 2025

Adds a new frontend and legacy driver flag, -{enable,disable}-module-selectors-in-module-interface, to control whether decl references in module interfaces are qualified using member syntax (the previous behavior) or module selectors:

// Using `-disable-module-selectors-in-module-interface`
extension XCTest.XCTestCase {}

// Using `-enable-module-selectors-in-module-interface`
extension XCTest::XCTestCase {}

Currently, disable is the default; in the future, it will become enable. Also includes support for disabling using the blocklist action DisableModuleSelectorsInModuleInterface.

Continuation of #34556.

if (M->isBuiltinModule())
return true;

// Don't module-qualify a local type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not?

Copy link
Contributor Author

@beccadax beccadax Oct 21, 2025

Choose a reason for hiding this comment

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

Module selectors skip directly to module-scope lookup, so a reference qualified by a module selector won't find a local type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that makes sense. Worth updating the comment then, since it would have avoided my question? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment now reads:

// Module selectors skip over local types, so don't add one.

@beccadax beccadax force-pushed the mod-squad-interface branch from 8e2c663 to a3e74fe Compare October 28, 2025 17:49
@beccadax beccadax force-pushed the mod-squad-interface branch from a3e74fe to ba3cdd9 Compare October 29, 2025 22:22
@beccadax beccadax marked this pull request as ready for review October 29, 2025 22:22
Copy link
Contributor

@tshortli tshortli left a comment

Choose a reason for hiding this comment

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

🎉

def module_interface_qualification :
Separate<["-"], "module-interface-qualification">,
Flags<[FrontendOption, NoInteractiveOption]>,
MetaVarName<"<none|alias|selector|conditional>">,
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: I'd expect conditional to be something like selector-conditional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, all of these names are a little weird; I might workshop them a bit before I commit to them.

ModuleDecl *M) {
PrettyStackTraceDecl stackTrace("emitting swiftinterface for", M);

assert(M);
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 not to use ASSERT here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original code didn't, but I might as well upgrade it.

This support is currently opt-in and can be disabled by a blocklist.
@beccadax beccadax force-pushed the mod-squad-interface branch from ba3cdd9 to 9454c0a Compare October 31, 2025 23:49
@beccadax beccadax requested a review from DougGregor as a code owner October 31, 2025 23:49
@beccadax
Copy link
Contributor Author

beccadax commented Nov 1, 2025

@swift-ci please test

@beccadax beccadax enabled auto-merge November 1, 2025 00:17
@beccadax
Copy link
Contributor Author

beccadax commented Nov 3, 2025

@swift-ci please test

@beccadax beccadax merged commit 2504bee into swiftlang:main Nov 4, 2025
4 of 5 checks passed
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