Skip to content

Commit 3fe6997

Browse files
committed
Improve compatibility shims for throws clause refactoring
1 parent 7eaee71 commit 3fe6997

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,32 @@ public extension DeclGroupSyntax {
5050
}
5151
}
5252

53+
54+
public extension EffectSpecifiersSyntax {
55+
@available(*, deprecated, message: "use throwsClause.throwsSpecifier")
56+
var throwsSpecifier: TokenSyntax? {
57+
throwsClause?.throwsSpecifier
58+
}
59+
}
60+
61+
62+
public extension FunctionEffectSpecifiersSyntax {
63+
@available(*, deprecated, message: "use throwsClause instead of throwsSpecifier")
64+
init(
65+
leadingTrivia: Trivia? = nil,
66+
asyncSpecifier: TokenSyntax? = nil,
67+
throwsSpecifier: TokenSyntax? = nil,
68+
trailingTrivia: Trivia? = nil
69+
) {
70+
self.init(
71+
leadingTrivia: leadingTrivia,
72+
asyncSpecifier: asyncSpecifier,
73+
throwsClause: throwsSpecifier.map { ThrowsClauseSyntax(throwsSpecifier: $0) },
74+
trailingTrivia: trailingTrivia
75+
)
76+
}
77+
}
78+
5379
public extension FreestandingMacroExpansionSyntax {
5480
@available(*, deprecated, renamed: "pound")
5581
var poundToken: TokenSyntax {

Sources/SwiftSyntax/SyntaxProtocol.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -735,10 +735,3 @@ public extension SyntaxChildChoices {
735735
return self.as(S.self)!
736736
}
737737
}
738-
739-
public extension EffectSpecifiersSyntax {
740-
/// Retrieve the throws specifier, ignoring any thrown error type.
741-
var throwsSpecifier: TokenSyntax? {
742-
throwsClause?.throwsSpecifier
743-
}
744-
}

0 commit comments

Comments
 (0)