@@ -11,7 +11,7 @@ enum OptionSetMacroDiagnostic {
11
11
}
12
12
13
13
extension OptionSetMacroDiagnostic : DiagnosticMessage {
14
- func diagnose( at node: some SyntaxProtocol ) -> Diagnostic {
14
+ func diagnose< Node : SyntaxProtocol > ( at node: Node ) -> Diagnostic {
15
15
Diagnostic ( node: Syntax ( node) , message: self )
16
16
}
17
17
@@ -65,10 +65,13 @@ public struct OptionSetMacro {
65
65
///
66
66
/// - Returns: the important arguments used by the various roles of this
67
67
/// macro inhabits, or nil if an error occurred.
68
- static func decodeExpansion(
68
+ static func decodeExpansion<
69
+ Decl: DeclGroupSyntax ,
70
+ Context: MacroExpansionContext
71
+ > (
69
72
of attribute: AttributeSyntax ,
70
- attachedTo decl: some DeclGroupSyntax ,
71
- in context: some MacroExpansionContext
73
+ attachedTo decl: Decl ,
74
+ in context: Context
72
75
) -> ( StructDeclSyntax , EnumDeclSyntax , TypeSyntax ) ? {
73
76
// Determine the name of the options enum.
74
77
let optionsEnumName : String
@@ -119,10 +122,13 @@ public struct OptionSetMacro {
119
122
}
120
123
121
124
extension OptionSetMacro : ConformanceMacro {
122
- public static func expansion(
125
+ public static func expansion<
126
+ Decl: DeclGroupSyntax ,
127
+ Context: MacroExpansionContext
128
+ > (
123
129
of attribute: AttributeSyntax ,
124
- providingConformancesOf decl: some DeclGroupSyntax ,
125
- in context: some MacroExpansionContext
130
+ providingConformancesOf decl: Decl ,
131
+ in context: Context
126
132
) throws -> [ ( TypeSyntax , GenericWhereClauseSyntax ? ) ] {
127
133
// Decode the expansion arguments.
128
134
guard let ( structDecl, _, _) = decodeExpansion ( of: attribute, attachedTo: decl, in: context) else {
@@ -140,10 +146,13 @@ extension OptionSetMacro: ConformanceMacro {
140
146
}
141
147
142
148
extension OptionSetMacro : MemberMacro {
143
- public static func expansion(
149
+ public static func expansion<
150
+ Decl: DeclGroupSyntax ,
151
+ Context: MacroExpansionContext
152
+ > (
144
153
of attribute: AttributeSyntax ,
145
- providingMembersOf decl: some DeclGroupSyntax ,
146
- in context: some MacroExpansionContext
154
+ providingMembersOf decl: Decl ,
155
+ in context: Context
147
156
) throws -> [ DeclSyntax ] {
148
157
// Decode the expansion arguments.
149
158
guard let ( _, optionsEnum, rawType) = decodeExpansion ( of: attribute, attachedTo: decl, in: context) else {
@@ -190,7 +199,7 @@ extension DeclModifierSyntax {
190
199
extension SyntaxStringInterpolation {
191
200
// It would be nice for SwiftSyntaxBuilder to provide this out-of-the-box.
192
201
mutating func appendInterpolation< Node: SyntaxProtocol > ( _ node: Node ? ) {
193
- if let node {
202
+ if let node = node {
194
203
appendInterpolation ( node)
195
204
}
196
205
}
0 commit comments