Commit Graph

19 Commits

Author SHA1 Message Date
Becca Royal-Gordon
e6d8b02626 Make module selectors non-experimental
Approved by SE-0491.
2025-10-24 16:23:50 -07:00
Becca Royal-Gordon
e3495f5fe7 Forbid module selectors on dependent member types
In code like the following:

```
protocol P { associatedtype A: Hashable }
protocol Q { associatedtype A: Comparable }

func fn<T: P & Q>(_: T) where T.A == Int { … }
```

`T.A` is actually the union of `P.A` and `Q.A`—it satisfies both associated types and has both of their constraints. This means it doesn’t actually make sense to apply a module selector to `A`—even if `P` and `Q` are in different modules, `T.A` always represents both of the declarations, not one or the other. We therefore now ban module selectors in this position, since they don’t actually jibe with the nature of a generic signature.

This justification technically doesn’t hold for *every* member type of a generic parameter—a member type can refer to a concrete typealias in a protocol extension, for instance—but in those situations, you can disambiguate (and add module selectors) by writing `P.A` or `Q.A` instead of `T.A`, so we’re not really worried about this limitation.
2025-10-24 16:23:50 -07:00
Becca Royal-Gordon
ec92be4955 Support module selectors for cross-import overlays 2025-10-24 16:23:50 -07:00
Becca Royal-Gordon
42fdd1d30c Improve module selector macro diagnostics 2025-10-24 16:23:49 -07:00
Becca Royal-Gordon
b65e3c9c15 Improve module selector @_dynamicReplacement diagnostics 2025-10-24 16:23:49 -07:00
Becca Royal-Gordon
60cc537f70 Improve module selector constraint solver diagnostics 2025-10-24 16:23:49 -07:00
Becca Royal-Gordon
d1e391094d Improve module selector expr lookup diagnostics 2025-10-24 16:23:49 -07:00
Becca Royal-Gordon
7949224b69 Improve module selector type lookup diagnostics 2025-10-24 16:23:48 -07:00
Becca Royal-Gordon
ffaa35810c Handle lookup into Builtin with module selector
Lookups like Builtin::Int64 were failing because BuiltinUnit rejected all unqualified lookups. Make it allow unqualified lookups with a module selector.
2025-10-24 16:23:48 -07:00
Becca Royal-Gordon
7bf14de2e6 Handle module selectors with local vars right 2025-10-24 16:23:34 -07:00
Becca Royal-Gordon
b35aaef526 Handle module selectors in macro lookups 2025-10-24 16:23:34 -07:00
Becca Royal-Gordon
f43bd72207 Handle module selectors in UDRE lookups 2025-10-24 16:23:34 -07:00
Becca Royal-Gordon
2869b334ee Handle module selectors in unqualified lookup 2025-10-24 16:23:34 -07:00
Becca Royal-Gordon
d30b46efcd Root unqualified lookups with module selectors at file scope 2025-10-24 16:23:33 -07:00
Becca Royal-Gordon
1dfc0bff86 Handle module selectors in qualified lookup 2025-10-24 16:23:33 -07:00
Becca Royal-Gordon
64d8b70942 Make DeclNameRef able to store a module selector
In this commit, this change affects certain diagnostics but doesn’t actually alter name lookup behavior yet.
2025-10-24 16:23:33 -07:00
Becca Royal-Gordon
1ecabaf4c7 [NFC] Add skeleton of module selector lookup test
The diagnostics in this test will evolve as we implement pieces of the feature.
2025-10-22 13:05:19 -07:00
Becca Royal-Gordon
f1db5d3a6a [NFC] Add tok::colon_colon to parser 2025-10-16 13:30:29 -07:00
Becca Royal-Gordon
c3a61bee0e Add experimental feature for module selector 2025-05-14 11:16:02 -07:00