Skip to content

Commit 7f2f3ea

Browse files
authored
Merge pull request #85401 from beccadax/mod-squad-relnotes
[SE-0491] Add module selectors to changelog
2 parents 3cfcc90 + 4d78b37 commit 7f2f3ea

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,39 @@
55
66
## Swift (next)
77

8+
* [SE-0491][]:
9+
You can now use a module selector to specify which module Swift should look inside to find a named declaration. A
10+
module selector is written before the name it qualifies and consists of the module name and two colons (`::`):
11+
12+
```swift
13+
// This type conforms to the `View` protocol from `SwiftUI`, even if other
14+
// modules have also declared a type named `View`:
15+
struct MyView: SwiftUI::View { ... }
16+
```
17+
18+
A module selector can also be applied to the name of a member; this is helpful if extensions in other modules have
19+
added an ambiguous overload:
20+
21+
```swift
22+
// Calls the `data(using:)` method added by `Foundation`, even if other
23+
// modules have added identical overloads of `data(using:)`.
24+
let data = "a little bit of text".Foundation::data(using: .utf8)
25+
```
26+
27+
When a module selector is used, Swift skips past any enclosing scopes and starts its search at the top level of the
28+
module; this means that certain declarations, such as local variables and generic parameter types, cannot be found
29+
with a module selector. Constraints in `where` clauses also cannot use a module selector to refer to an associated
30+
type.
31+
32+
Module selectors are primarily intended to be used when working around unavoidable conflicts, such as when two
33+
modules you don't control both use the same name. API designs which force clients to use a module selector are not
34+
recommended; it is usually better to rename a declaration instead. (19481048)
35+
36+
* If you maintain a module built with Library Evolution, you can now configure Swift to use module selectors to improve
37+
the robustness of its module interface file. This is especially helpful if your module declares a type with the same
38+
name as the module itself. To opt in to this behavior, add the `-enable-module-selectors-in-module-interface` flag to
39+
the `OTHER_SWIFT_FLAGS` build setting.
40+
841
* Concurrency-related APIs like `Task` and string-processing-related APIs like `Regex` can now be qualified by the name
942
`Swift`, just like other standard library APIs:
1043

@@ -10925,6 +10958,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1092510958
[SE-0470]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0470-isolated-conformances.md
1092610959
[SE-0471]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0371-isolated-synchronous-deinit.md
1092710960
[SE-0472]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0472-task-start-synchronously-on-caller-context.md
10961+
[SE-0491]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0491-module-selectors.md
1092810962
[#64927]: <https://github.com/apple/swift/issues/64927>
1092910963
[#42697]: <https://github.com/apple/swift/issues/42697>
1093010964
[#42728]: <https://github.com/apple/swift/issues/42728>

0 commit comments

Comments
 (0)