Skip to content

Commit c3ee2fa

Browse files
Add @retroactive to conformances that need it. (#714)
SE-0364 requires that retroactive conformance be marked with `@retroactive` to suppress warnings about the dangers of conforming types you don't own to protocols you don't own. The `RegexBuilder` module declares conformances to `RegexComponent` (from the `Regex` module) on several types from the standard library, like `String`. Since `RegexBuilder` declares neither the protocol nor the conforming type, these conformances are technically retroactive even though the modules involved are all developed and distributed together and can be trusted to organize the conformances this way safely. The compiler warnings about these conformances are quite spammy; they get emitted every time someone builds the Swift compiler, so I'd like to suppress them. Co-authored-by: Allan Shortlidge <[email protected]>
1 parent b0cd8f1 commit c3ee2fa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/RegexBuilder/DSL.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ internal protocol _BuiltinRegexComponent: RegexComponent {
3232
// MARK: - Primitive regex components
3333

3434
@available(SwiftStdlib 5.7, *)
35-
extension String: RegexComponent {
35+
extension String: @retroactive RegexComponent {
3636
public typealias Output = Substring
3737

3838
public var regex: Regex<Output> { .init(verbatim: self) }
3939
}
4040

4141
@available(SwiftStdlib 5.7, *)
42-
extension Substring: RegexComponent {
42+
extension Substring: @retroactive RegexComponent {
4343
public typealias Output = Substring
4444

4545
public var regex: Regex<Output> { String(self).regex }
4646
}
4747

4848
@available(SwiftStdlib 5.7, *)
49-
extension Character: RegexComponent {
49+
extension Character: @retroactive RegexComponent {
5050
public typealias Output = Substring
5151

5252
public var regex: Regex<Output> {
@@ -55,7 +55,7 @@ extension Character: RegexComponent {
5555
}
5656

5757
@available(SwiftStdlib 5.7, *)
58-
extension UnicodeScalar: RegexComponent {
58+
extension UnicodeScalar: @retroactive RegexComponent {
5959
public typealias Output = Substring
6060

6161
public var regex: Regex<Output> {

0 commit comments

Comments
 (0)