@@ -2957,19 +2957,24 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
29572957 if let attributes = attributes {
29582958 let behavior : NewlineBehavior = separateByLineBreaks ? . hard : . elective
29592959 before ( attributes. firstToken ( viewMode: . sourceAccurate) , tokens: . open)
2960- for element in attributes. dropLast ( ) {
2961- if let ifConfig = element. as ( IfConfigDeclSyntax . self) {
2960+ if attributes. dropLast ( ) . isEmpty,
2961+ let ifConfig = attributes. first? . as ( IfConfigDeclSyntax . self) {
2962+ for clause in ifConfig. clauses {
2963+ if let nestedAttributes = AttributeListSyntax ( clause. elements) {
2964+ arrangeAttributeList ( nestedAttributes, suppressFinalBreak: true , separateByLineBreaks: separateByLineBreaks)
2965+ }
2966+ }
2967+ } else {
2968+ for element in attributes. dropLast ( ) {
2969+ if let ifConfig = element. as ( IfConfigDeclSyntax . self) {
29622970 for clause in ifConfig. clauses {
2963- if let nestedAttributes = AttributeListSyntax ( clause. elements) {
2964- arrangeAttributeList (
2965- nestedAttributes,
2966- suppressFinalBreak: true ,
2967- separateByLineBreaks: separateByLineBreaks
2968- )
2969- }
2971+ if let nestedAttributes = AttributeListSyntax ( clause. elements) {
2972+ arrangeAttributeList ( nestedAttributes, suppressFinalBreak: true , separateByLineBreaks: separateByLineBreaks)
2973+ }
29702974 }
2971- } else {
2975+ } else {
29722976 after ( element. lastToken ( viewMode: . sourceAccurate) , tokens: . break( . same, newlines: behavior) )
2977+ }
29732978 }
29742979 }
29752980 var afterAttributeTokens = [ Token . close]
0 commit comments