Description
It would be nice to be able to use canImport(Observation)
to sprinkle in bits of observation code when supported, but unfortunately it doesn't seem to play nicely with some of the accessor macros.
Steps to reproduce
Past the following code into a Swift project:
#if canImport(Observation)
@Observable
#endif
class Feature {
#if canImport(Observation)
@ObservationIgnored
#endif
var unobservedValue: Int = 0
}
However, the @ObservationIgnored
macro generates the following invalid Swift code:
#if canImport(Observation)
@ObservationIgnored
#endif @ObservationIgnored private var _unobservedValue: Int = 0
Expected behavior
I would hope the macro would generate the following valid Swift code:
#if canImport(Observation)
@ObservationIgnored
#endif
private var _unobservedValue: Int = 0
Environment
- swift-driver version: 1.82.2 Apple Swift version 5.9 (swiftlang-5.9.0.114.6 clang-1500.0.27.1)
- Xcode 15.0
- Build version 15A5160n