Soundness hole in isolated protocol conformances

Does this count as a soundness hole?

import Testing

protocol P {
  func f()
}

struct S: @MainActor P {
  @MainActor
  func f() {
    MainActor.assertIsolated()
  }
}

@Test @MainActor func main() async throws {
  let s = S()
  await takeP(s)
}

private func takeP(_ p: any P) async {
  _ = p.f()
}

This crashes in Swift 6 language mode and with the newest runtime (iOS 26). We are allowed to turn a @MainActor P into an any P and invoke a main actor bound method on a non-main thread.

I can’t tell if the proposal is allowing for this soundness hole, or if this is expected to be a compiler error.

1 Like