Circular reference in enums

Hi, folks. I have a small Swift project where I define two enums, in two different files, like so:

a.swift

indirect enum A {
  case A1
  case A2(A, A)
}

b.swift

enum B {
  case B1(A, A)
}

And this fails to compile:

$ swift --version
swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0
$
$ swift build
Building for debugging...
<unknown>:0: error: circular reference
[...]/a.swift:1:15: note: through reference here
indirect enum A {
              ^
<unknown>:0: note: through reference here

However, things work fine if I put both enums in the same file:

indirect enum A {
  case A1
  case A2(A, A)
}

enum B {
  case B1(A, A)
}

This used to work in previous versions of Swift, but I'm not sure which because this is a project that I don't update that often.

Is it a bug in the compiler as here? Is there any other workaround other than putting the enums in the same file?

Thanks!

Yes, this looks like a bug to me.

The other bug linked is due to Sendable-checking. Does passing -strict-concurrency=minimal to the compiler help in your case?

Thank you. Passing that option to swiftc doesn't seem to help with the problem.