@@ -185,6 +185,7 @@ public func expandAttachedMacroWithoutCollapsing<Context: MacroExpansionContext>
185
185
declarationNode: DeclSyntax ,
186
186
parentDeclNode: DeclSyntax ? ,
187
187
extendedType: TypeSyntax ? ,
188
+ conformanceList: InheritedTypeListSyntax ? ,
188
189
in context: Context
189
190
) -> [ String ] ? {
190
191
do {
@@ -266,42 +267,6 @@ public func expandAttachedMacroWithoutCollapsing<Context: MacroExpansionContext>
266
267
$0. formattedExpansion ( definition. formatMode)
267
268
}
268
269
269
- case ( let attachedMacro as ConformanceMacro . Type , . conformance) :
270
- guard let declGroup = declarationNode. asProtocol ( DeclGroupSyntax . self) else {
271
- // Compiler error: type mismatch.
272
- throw MacroExpansionError . declarationNotDeclGroup
273
- }
274
- guard let identified = declarationNode. asProtocol ( IdentifiedDeclSyntax . self)
275
- else {
276
- // Compiler error: type mismatch.
277
- throw MacroExpansionError . declarationNotIdentified
278
- }
279
-
280
- // Local function to expand a conformance macro once we've opened up
281
- // the existential.
282
- func expandConformanceMacro(
283
- _ node: some DeclGroupSyntax
284
- ) throws -> [ ( TypeSyntax , GenericWhereClauseSyntax ? ) ] {
285
- return try attachedMacro. expansion (
286
- of: attributeNode,
287
- providingConformancesOf: node,
288
- in: context
289
- )
290
- }
291
-
292
- let conformances = try _openExistential (
293
- declGroup,
294
- do: expandConformanceMacro
295
- )
296
-
297
- // Form a buffer of extension declarations to return to the caller.
298
- return conformances. map { typeSyntax, whereClause in
299
- let typeName = identified. identifier. trimmedDescription
300
- let protocolName = typeSyntax. trimmedDescription
301
- let whereClause = whereClause? . trimmedDescription ?? " "
302
- return " extension \( typeName) : \( protocolName) \( whereClause) {} "
303
- }
304
-
305
270
case ( let attachedMacro as ExtensionMacro . Type , . extension) :
306
271
guard let declGroup = declarationNode. asProtocol ( DeclGroupSyntax . self) else {
307
272
// Compiler error: type mismatch.
@@ -312,6 +277,8 @@ public func expandAttachedMacroWithoutCollapsing<Context: MacroExpansionContext>
312
277
throw MacroExpansionError . noExtendedTypeSyntax
313
278
}
314
279
280
+ let protocols = conformanceList? . map ( \. typeName) ?? [ ]
281
+
315
282
// Local function to expand an extension macro once we've opened up
316
283
// the existential.
317
284
func expandExtensionMacro(
@@ -321,6 +288,7 @@ public func expandAttachedMacroWithoutCollapsing<Context: MacroExpansionContext>
321
288
of: attributeNode,
322
289
attachedTo: node,
323
290
providingExtensionsOf: extendedType,
291
+ conformingTo: protocols,
324
292
in: context
325
293
)
326
294
}
@@ -364,6 +332,7 @@ public func expandAttachedMacro<Context: MacroExpansionContext>(
364
332
declarationNode: DeclSyntax ,
365
333
parentDeclNode: DeclSyntax ? ,
366
334
extendedType: TypeSyntax ? ,
335
+ conformanceList: InheritedTypeListSyntax ? ,
367
336
in context: Context
368
337
) -> String ? {
369
338
let expandedSources = expandAttachedMacroWithoutCollapsing (
@@ -373,6 +342,7 @@ public func expandAttachedMacro<Context: MacroExpansionContext>(
373
342
declarationNode: declarationNode,
374
343
parentDeclNode: parentDeclNode,
375
344
extendedType: extendedType,
345
+ conformanceList: conformanceList,
376
346
in: context
377
347
)
378
348
return expandedSources. map {
0 commit comments