-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Closed
Copy link
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.circular referenceBug → internal error: Circular referenceBug → internal error: Circular referencecompilerThe Swift compiler itselfThe Swift compiler itselfinternal errorBug: Internal errorBug: Internal errornested typesFeature: nested typesFeature: nested typesswift 5.9swift macroFeature → declarations: Swift `macro` declarationsFeature → declarations: Swift `macro` declarationstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error
Description
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:
Circular reference resolving attached macro 'Observable'
Steps to reproduce
@Observable
class MyObservableClass {
var property1 = ""
var property2 = MyClass()
}
extension MyObservableClass {
class MyClass {
var property = ""
}
}
extension MyObservableClass.MyClass {
var test: String { "test \(property)" }
}
Expected behavior
It must be compilable because the following version is compilible:
@Observable
class MyObservableClass {
var property1 = ""
var property2 = MyClass()
}
extension MyObservableClass {
class MyClass {
var property = ""
var test: String { "test \(property)" }
}
}
Environment
Xcode 15.0 beta (15A5160n)
Swift 5.9
Target: iOS 17.0
JessyCatterwaul, lukaskubanek, mt-hodaka, panchenks, juliand665 and 32 more
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.circular referenceBug → internal error: Circular referenceBug → internal error: Circular referencecompilerThe Swift compiler itselfThe Swift compiler itselfinternal errorBug: Internal errorBug: Internal errornested typesFeature: nested typesFeature: nested typesswift 5.9swift macroFeature → declarations: Swift `macro` declarationsFeature → declarations: Swift `macro` declarationstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error