I love the new @Observable macro! However, I just hit a small inconvenience with it. When you apply it to a class that's defined inside an extension, the code doesn't compile anymore:
@Observable class Foo {} // Compiles fine
extension Foo {
@Observable class Bar {} // Does not compile
}
In fact, the compiler doesn't even give you a proper error message, it just fails with a generic "Command SwiftCompile failed with a nonzero exit code" in Xcode 15 Beta 1.
I guess this happens because the macro adds the Observable conformance via an extension, which needs to be in top-level code, right?
// ... (Other synthesized code)
extension Bar : Observable {}
Is there a way around this problem? Nesting types is the only real way of "namespacing" things in Swift.