@@ -185,6 +185,7 @@ public func expandAttachedMacroWithoutCollapsing<Context: MacroExpansionContext>
185185 declarationNode: DeclSyntax ,
186186 parentDeclNode: DeclSyntax ? ,
187187 extendedType: TypeSyntax ? ,
188+ conformanceList: InheritedTypeListSyntax ? ,
188189 in context: Context
189190) -> [ String ] ? {
190191 do {
@@ -266,42 +267,6 @@ public func expandAttachedMacroWithoutCollapsing<Context: MacroExpansionContext>
266267 $0. formattedExpansion ( definition. formatMode)
267268 }
268269
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-
305270 case ( let attachedMacro as ExtensionMacro . Type , . extension) :
306271 guard let declGroup = declarationNode. asProtocol ( DeclGroupSyntax . self) else {
307272 // Compiler error: type mismatch.
@@ -312,6 +277,8 @@ public func expandAttachedMacroWithoutCollapsing<Context: MacroExpansionContext>
312277 throw MacroExpansionError . noExtendedTypeSyntax
313278 }
314279
280+ let protocols = conformanceList? . map ( \. typeName) ?? [ ]
281+
315282 // Local function to expand an extension macro once we've opened up
316283 // the existential.
317284 func expandExtensionMacro(
@@ -321,6 +288,7 @@ public func expandAttachedMacroWithoutCollapsing<Context: MacroExpansionContext>
321288 of: attributeNode,
322289 attachedTo: node,
323290 providingExtensionsOf: extendedType,
291+ conformingTo: protocols,
324292 in: context
325293 )
326294 }
@@ -364,6 +332,7 @@ public func expandAttachedMacro<Context: MacroExpansionContext>(
364332 declarationNode: DeclSyntax ,
365333 parentDeclNode: DeclSyntax ? ,
366334 extendedType: TypeSyntax ? ,
335+ conformanceList: InheritedTypeListSyntax ? ,
367336 in context: Context
368337) -> String ? {
369338 let expandedSources = expandAttachedMacroWithoutCollapsing (
@@ -373,6 +342,7 @@ public func expandAttachedMacro<Context: MacroExpansionContext>(
373342 declarationNode: declarationNode,
374343 parentDeclNode: parentDeclNode,
375344 extendedType: extendedType,
345+ conformanceList: conformanceList,
376346 in: context
377347 )
378348 return expandedSources. map {
0 commit comments