@@ -16,6 +16,13 @@ import SwiftSyntaxBuilder
16
16
struct ColumnMacro : ExpressionMacro {
17
17
static var name : String { " column " }
18
18
19
+ static var genericSignature : GenericParameterClauseSyntax ? =
20
+ """
21
+ <T: ExpressibleByIntegerLiteral>
22
+ """
23
+
24
+ static var signature : TypeSyntax = " T "
25
+
19
26
static func apply(
20
27
_ macro: MacroExpansionExprSyntax , in context: MacroEvaluationContext
21
28
) -> MacroResult < ExprSyntax > {
@@ -29,6 +36,13 @@ struct ColumnMacro: ExpressionMacro {
29
36
struct LineMacro : ExpressionMacro {
30
37
static var name : String { " line " }
31
38
39
+ static var genericSignature : GenericParameterClauseSyntax ? =
40
+ """
41
+ <T: ExpressibleByIntegerLiteral>
42
+ """
43
+
44
+ static var signature : TypeSyntax = " T "
45
+
32
46
static func apply(
33
47
_ macro: MacroExpansionExprSyntax , in context: MacroEvaluationContext
34
48
) -> MacroResult < ExprSyntax > {
@@ -54,6 +68,13 @@ extension PatternBindingSyntax {
54
68
struct FunctionMacro : ExpressionMacro {
55
69
static var name : String { " function " }
56
70
71
+ static var genericSignature : GenericParameterClauseSyntax ? =
72
+ """
73
+ <T: ExpressibleByStringLiteral>
74
+ """
75
+
76
+ static var signature : TypeSyntax = " T "
77
+
57
78
/// Form a function name.
58
79
private static func formFunctionName(
59
80
_ baseName: String , _ parameters: ParameterClauseSyntax ? ,
@@ -159,6 +180,18 @@ struct FunctionMacro: ExpressionMacro {
159
180
struct ColorLiteralMacro : ExpressionMacro {
160
181
static var name : String { " colorLiteral " }
161
182
183
+ static var genericSignature : GenericParameterClauseSyntax ? =
184
+ """
185
+ <T: ExpressibleByColorLiteral>
186
+ """
187
+
188
+ static var signature : TypeSyntax =
189
+ """
190
+ (
191
+ _colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float
192
+ ) -> T
193
+ """
194
+
162
195
static func apply(
163
196
_ macro: MacroExpansionExprSyntax , in context: MacroEvaluationContext
164
197
) -> MacroResult < ExprSyntax > {
@@ -173,6 +206,14 @@ struct ColorLiteralMacro: ExpressionMacro {
173
206
struct FileLiteralMacro : ExpressionMacro {
174
207
static var name : String { " fileLiteral " }
175
208
209
+ static var genericSignature : GenericParameterClauseSyntax ? =
210
+ """
211
+ <T: ExpressibleByFileReferenceLiteral>
212
+ """
213
+
214
+ static var signature : TypeSyntax =
215
+ " (fileReferenceLiteralResourceName path: String) -> T "
216
+
176
217
static func apply(
177
218
_ macro: MacroExpansionExprSyntax , in context: MacroEvaluationContext
178
219
) -> MacroResult < ExprSyntax > {
@@ -187,6 +228,14 @@ struct FileLiteralMacro: ExpressionMacro {
187
228
struct ImageLiteralMacro : ExpressionMacro {
188
229
static var name : String { " imageLiteral " }
189
230
231
+ static var genericSignature : GenericParameterClauseSyntax ? =
232
+ """
233
+ <T: ExpressibleByImageLiteral>
234
+ """
235
+
236
+ static var signature : TypeSyntax =
237
+ " (imageLiteralResourceName path: String) -> T "
238
+
190
239
static func apply(
191
240
_ macro: MacroExpansionExprSyntax , in context: MacroEvaluationContext
192
241
) -> MacroResult < ExprSyntax > {
@@ -201,6 +250,13 @@ struct ImageLiteralMacro: ExpressionMacro {
201
250
struct FilePathMacro : ExpressionMacro {
202
251
static var name : String { " filePath " }
203
252
253
+ static var genericSignature : GenericParameterClauseSyntax ? =
254
+ """
255
+ <T: ExpressibleByStringLiteral>
256
+ """
257
+
258
+ static var signature : TypeSyntax = " T "
259
+
204
260
static func apply(
205
261
_ macro: MacroExpansionExprSyntax , in context: MacroEvaluationContext
206
262
) -> MacroResult < ExprSyntax > {
@@ -218,6 +274,13 @@ struct FilePathMacro: ExpressionMacro {
218
274
struct FileIDMacro : ExpressionMacro {
219
275
static var name : String { " fileID " }
220
276
277
+ static var genericSignature : GenericParameterClauseSyntax ? =
278
+ """
279
+ <T: ExpressibleByStringLiteral>
280
+ """
281
+
282
+ static var signature : TypeSyntax = " T "
283
+
221
284
static func apply(
222
285
_ macro: MacroExpansionExprSyntax , in context: MacroEvaluationContext
223
286
) -> MacroResult < ExprSyntax > {
@@ -241,6 +304,13 @@ struct FileIDMacro: ExpressionMacro {
241
304
struct FileMacro : ExpressionMacro {
242
305
static var name : String { " file " }
243
306
307
+ static var genericSignature : GenericParameterClauseSyntax ? =
308
+ """
309
+ <T: ExpressibleByStringLiteral>
310
+ """
311
+
312
+ static var signature : TypeSyntax = " T "
313
+
244
314
static func apply(
245
315
_ macro: MacroExpansionExprSyntax , in context: MacroEvaluationContext
246
316
) -> MacroResult < ExprSyntax > {
0 commit comments