Skip to content

Commit 8ae4577

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 8ae4577

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,10 @@ 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 {}
470474
#endif
471475

472476
// MARK: - Trivia expressible as string
@@ -515,7 +519,13 @@ extension Trivia {
515519
}
516520

517521
#if compiler(>=6)
522+
// Silence warning that Trivia has a retroactive conformance to `ExpressibleByStringInterpolation` through
523+
// `SyntaxExpressibleByStringInterpolation`.
518524
extension Trivia: Swift.ExpressibleByStringInterpolation {}
525+
// Work around https://github.com/swiftlang/swift/issues/85153 by restating the implicit conformances.
526+
extension Trivia: Swift.ExpressibleByStringLiteral {}
527+
extension Trivia: Swift.ExpressibleByExtendedGraphemeClusterLiteral {}
528+
extension Trivia: Swift.ExpressibleByUnicodeScalarLiteral {}
519529
#else
520530
extension Trivia: ExpressibleByStringInterpolation {}
521531
#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)