-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensions for subtype of a class marked @Observable generate compile error #66450
Comments
|
@JessyCatterwaul Yes. It's always the same pattern. |
Are there any workarounds for this issue? |
One workaround is to place the extension(s) in a separate file. |
Just ran into this as well; here's a perhaps even more minimal example: @Observable
final class Outer {
struct Inner {}
}
extension Outer.Inner {} |
+1 to this issue being a problem that definitely comes up quite a bit in every day work. Also, regarding this:
This can work most of the time, but sometimes it can be difficult. For example a macro applied to a generic type that needs to conditionally conform to @SomeMacro
struct Wrapper<T> { var value: T }
extension Model: Equatable where T: Equatable {} // 🛑 Circular reference If this extension is moved into a separate file then you lose the automatic synthesis of |
Add a new case: enum Namespace {
@SomeMacro
struct SomeStruct { }
}
extension Namespace.SomeStruct { } // 🛑 Circular reference |
Hello, any progress here? |
We shipped a few macros this week and have had about a dozen folks report this bug to us. Would be nice to have the issue triaged. |
|
Hi @DevYeom, I am not able to confirm this. Both the example provided in this issue still fails to compile: As does a simpler repro of the problem: I am using Xcode 15.1 beta 3 (15C5059c) to test this. Can anyone else confirm that it is fixed? |
I'm so sorry for my misleading. The issue I had was not related to
|
With the amount of macros being utilized now by many libraries, including Apple's, this problem becomes much more prominent, and also very cryptic to even understand that the harmless extension is causing it. Hope it will get addressed. |
It'd be nice to at least have some acknowledgement of the problem from the core team. While we understand that there are plenty of bugs out there that need attention and triage, this one has quite a bit of activity and reach, and was opened pretty promptly the week of WWDC23. |
A class of these circularity issues were fixed by #67689, which is included in Xcode 15.1 Beta 3 where some folks are seeing their specific test cases resolved. However, the |
Would love to see this fixed please!! |
Checked the latest snapshot this morning and sadly this is still a problem! Hopefully this gets fixed before the Xcode 15.3 + Swift 5.10 beta cycle completes. |
NOOOOOOOOOOO!!! Posting this has worked in another open-source project, so maybe it will work here! If we all collectively pray to the patron saint of computer programming, Saint Isidore of Seville, perhaps it will be addressed very soon 🙏 |
Also experiencing this issue on Xcode 15.3, Swift 5.10 |
Still seeing in Xcode 15.3 and Swift 5.10, as well. |
Please give some love to this issue, Swift core team! ❤️🙏 |
Yup this is a pretty bad one especially since it's a huge challenge for macros which make these extensions in the same file. It would be awesome to fix this one. Thank you in advance!! |
This is fixed in #71365 |
@hborla Awesome! Would you know if we planned to patch this on the 5.10 branch? |
@hborla , thank you very much for the fix ! 🙏 |
So seems like the fix will be in upcoming Swift 6, in September |
Description
I cannot add a subtype (class, enum, struct) to a class marked with
@Observable
macro. If I add an extension to this subtype, I get compile error:Steps to reproduce
Expected behavior
It must be compilable because the following version is compilible:
Environment
Xcode 15.0 beta (15A5160n)
Swift 5.9
Target: iOS 17.0
The text was updated successfully, but these errors were encountered: