Skip to content

Commit 61d935e

Browse files
committed
Work around a retroactive conformance bug in Swift 6.2.
The Swift 6.2 compiler emits spurious warnings about retroactive conformances to protocols that are inherited through a protocol that is written module qualified in the inheritance clause (the Swift compiler bug is tracked by swiftlang/swift#85153). Suppress the warnings by making the inherited conformances explicit and module qualified.
1 parent ef033f4 commit 61d935e

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntaxbuilder/SyntaxExpressibleByStringInterpolationConformancesFile.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ let syntaxExpressibleByStringInterpolationConformancesFile = SourceFileSyntax(le
3636
"""
3737
#if compiler(>=6)
3838
extension \(type): Swift.ExpressibleByStringInterpolation {}
39+
// Work around https://github.com/swiftlang/swift/issues/85153 by restating the implicit conformances.
40+
extension \(type): Swift.ExpressibleByStringLiteral, Swift.ExpressibleByExtendedGraphemeClusterLiteral, Swift.ExpressibleByUnicodeScalarLiteral {}
3941
#endif
4042
"""
4143
)

Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ extension TokenSyntax: SyntaxExpressibleByStringInterpolation {
467467
// Silence warning that TokenSyntax has a retroactive conformance to `ExpressibleByStringInterpolation` through
468468
// `SyntaxExpressibleByStringInterpolation`.
469469
extension TokenSyntax: Swift.ExpressibleByStringInterpolation {}
470+
// Work around https://github.com/swiftlang/swift/issues/85153 by restating the implicit conformances.
471+
extension TokenSyntax: Swift.ExpressibleByStringLiteral {}
472+
extension TokenSyntax: Swift.ExpressibleByExtendedGraphemeClusterLiteral {}
473+
extension TokenSyntax: Swift.ExpressibleByUnicodeScalarLiteral {}
474+
{}
470475
#endif
471476

472477
// MARK: - Trivia expressible as string
@@ -515,7 +520,14 @@ extension Trivia {
515520
}
516521

517522
#if compiler(>=6)
523+
// Silence warning that Trivia has a retroactive conformance to `ExpressibleByStringInterpolation` through
524+
// `SyntaxExpressibleByStringInterpolation`.
518525
extension Trivia: Swift.ExpressibleByStringInterpolation {}
526+
// Work around https://github.com/swiftlang/swift/issues/85153 by restating the implicit conformances.
527+
extension Trivia: Swift.ExpressibleByStringLiteral {}
528+
extension Trivia: Swift.ExpressibleByExtendedGraphemeClusterLiteral {}
529+
extension Trivia: Swift.ExpressibleByUnicodeScalarLiteral {}
530+
{}
519531
#else
520532
extension Trivia: ExpressibleByStringInterpolation {}
521533
#endif

Sources/SwiftSyntaxBuilder/generated/SyntaxExpressibleByStringInterpolationConformances.swift

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)