swiftlang / swift-format

Formatting technology for Swift source code
Apache License 2.0
2.47k stars 227 forks source link

`NoAccessLevelOnExtensionDeclaration` should move `@_spi` attribute with access level attribute #714

Open Matejkob opened 5 months ago

Matejkob commented 5 months ago

If an extension is marked with an access level attribute and has the @_spi attribute, the NoAccessLevelOnExtensionDeclaration rule should move both attributes to each declaration in the extension.

func testExtensionWithSpiAttribute() {
  assertFormatting(
    NoAccessLevelOnExtensionDeclaration.self,
    input: """
      @_spi(Something) public extension Foo {
        var bar: String { "" }
      }
      """,
    expected: """
      extension Foo {
        @_spi(Something) public var bar: String { "" }
      }
      """,
    findings: [
      // TODO: Add findings
    ]
  )
}

Originated from: https://github.com/apple/swift-syntax/pull/2602#discussion_r1563091753

ahoppen commented 5 months ago

Tracked in Apple’s issue tracker as rdar://126948454