swiftlang/swift-format

Convert `@MainActor` `XCTestCase` subclasses to have `@MainActor` on each test method?

Opened this issue · 1 comments

This is probably a bit much, but...

Xcode 15.3 / Swift 5.10 introduces a new concurrency check in complete mode that ensures subclasses have the same isolation as their superclasses. This is triggered on the following simple case:

@MainActor
final class Test: XCTestCase {}

which prints Main actor-isolated class 'Test' has different actor isolation from nonisolated superclass 'XCTestCase'; this is an error in Swift 6. The solution is to move the annotation to each of the test methods. This is tedious so I wonder if SwiftFormat could help?

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