-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
Labels
ObservationArea → standard library: The `Observation` module under the standard library umbrellaArea → standard library: The `Observation` module under the standard library umbrellaaccess controlFeature → modifiers: Access control and access levelsFeature → modifiers: Access control and access levelsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
If a property with package access modifier exists in a class with @Observable Macro, the build will fail.
Reproduction
✅ OK
import Observation
@Observable
class MyObservable1 {
var value = 0
}❌ Build failed
import Observation
@Observable
class MyObservable2 {
package var value = 0
}% swift build
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/var/folders/78/4hltfk2n2fz2f88371bhlp_h0000gn/T/swift-generated-sources/@__swiftmacro_20ObservablePlayground13MyObservable2C5value18ObservationTrackedfMp_.swift:2:5: error: duplicate modifier
package var _value = 0
^~~~~~~
/Users/treastrain/Developer/github.com/treastrain/ObservablePlayground/Sources/main.swift:11:17: note: in expansion of macro 'ObservationTracked' here
package var value = 0
^~~~~
/var/folders/78/4hltfk2n2fz2f88371bhlp_h0000gn/T/swift-generated-sources/@__swiftmacro_20ObservablePlayground13MyObservable2C5value18ObservationTrackedfMp_.swift:1:21: note: modifier already specified here
@ObservationIgnored private
^~~~~~~
/Users/treastrain/Developer/github.com/treastrain/ObservablePlayground/Sources/main.swift:11:17: note: in expansion of macro 'ObservationTracked' here
package var value = 0
^~~~~
/var/folders/78/4hltfk2n2fz2f88371bhlp_h0000gn/T/swift-generated-sources/@__swiftmacro_20ObservablePlayground13MyObservable2C5value18ObservationTrackedfMp_.swift:2:5: error: duplicate modifier
package var _value = 0
^~~~~~~
/Users/treastrain/Developer/github.com/treastrain/ObservablePlayground/Sources/main.swift:11:17: note: in expansion of macro 'ObservationTracked' here
package var value = 0
^~~~~
/var/folders/78/4hltfk2n2fz2f88371bhlp_h0000gn/T/swift-generated-sources/@__swiftmacro_20ObservablePlayground13MyObservable2C5value18ObservationTrackedfMp_.swift:1:21: note: modifier already specified here
@ObservationIgnored private
^~~~~~~
/Users/treastrain/Developer/github.com/treastrain/ObservablePlayground/Sources/main.swift:11:17: note: in expansion of macro 'ObservationTracked' here
package var value = 0
^~~~~
error: fatalErrorExpected behavior
Expect the access modifier for properties with @ObservationIgnored generated by that macro to be private rather than the syntactically incorrect package private.
Environment
% swiftc -version
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0Additional information
p-x9 and Brett-Best
Metadata
Metadata
Assignees
Labels
ObservationArea → standard library: The `Observation` module under the standard library umbrellaArea → standard library: The `Observation` module under the standard library umbrellaaccess controlFeature → modifiers: Access control and access levelsFeature → modifiers: Access control and access levelsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labelsThis issue needs more specific labels

