@@ -113,23 +113,54 @@ extension Function {
113113 switch effect {
114114 case . none:
115115 return nil
116- case . throws( let isRethrows) :
117- return FunctionEffectSpecifiersSyntax (
118- asyncSpecifier: nil ,
119- throwsSpecifier: . keyword(
120- isRethrows ? . rethrows : . throws, leadingTrivia: . space, trailingTrivia: . space)
121- )
116+ case . throws( let isRethrows, let errorType) :
117+ let throwsSpecifier : TokenSyntax
118+ if let errorType = errorType {
119+ throwsSpecifier = . keyword(
120+ isRethrows ? . rethrows : . throws, leadingTrivia: . space)
121+ return FunctionEffectSpecifiersSyntax (
122+ asyncSpecifier: nil ,
123+ throwsClause: ThrowsClauseSyntax (
124+ throwsSpecifier: throwsSpecifier,
125+ leftParen: . leftParenToken( ) ,
126+ type: IdentifierTypeSyntax ( name: . identifier( errorType) ) ,
127+ rightParen: . rightParenToken( )
128+ )
129+ )
130+ } else {
131+ throwsSpecifier = . keyword(
132+ isRethrows ? . rethrows : . throws, leadingTrivia: . space)
133+ return FunctionEffectSpecifiersSyntax (
134+ asyncSpecifier: nil ,
135+ throwsSpecifier: throwsSpecifier
136+ )
137+ }
122138 case . async :
123139 return FunctionEffectSpecifiersSyntax (
124140 asyncSpecifier: . keyword( . async, leadingTrivia: . space, trailingTrivia: . space) ,
125141 throwsSpecifier: nil
126142 )
127- case . asyncThrows( let isRethrows) :
128- return FunctionEffectSpecifiersSyntax (
129- asyncSpecifier: . keyword( . async, leadingTrivia: . space, trailingTrivia: . space) ,
130- throwsSpecifier: . keyword(
131- isRethrows ? . rethrows : . throws, leadingTrivia: . space, trailingTrivia: . space)
132- )
143+ case . asyncThrows( let isRethrows, let errorType) :
144+ let throwsSpecifier : TokenSyntax
145+ if let errorType = errorType {
146+ throwsSpecifier = . keyword( . throws, leadingTrivia: . space)
147+ return FunctionEffectSpecifiersSyntax (
148+ asyncSpecifier: . keyword( . async, leadingTrivia: . space, trailingTrivia: . space) ,
149+ throwsClause: ThrowsClauseSyntax (
150+ throwsSpecifier: throwsSpecifier,
151+ leftParen: . leftParenToken( ) ,
152+ type: IdentifierTypeSyntax ( name: . identifier( errorType) ) ,
153+ rightParen: . rightParenToken( )
154+ )
155+ )
156+ } else {
157+ throwsSpecifier = . keyword(
158+ isRethrows ? . rethrows : . throws, leadingTrivia: . space)
159+ return FunctionEffectSpecifiersSyntax (
160+ asyncSpecifier: . keyword( . async, leadingTrivia: . space, trailingTrivia: . space) ,
161+ throwsSpecifier: throwsSpecifier
162+ )
163+ }
133164 }
134165 } ( )
135166
0 commit comments