@DependencyClient generates invalid code for computed property with explicit get
StefanCosminR opened this issue · 0 comments
StefanCosminR commented
Description
DependencyClient macro tries to handle a computed property with an explicit get as a stored property. This impacts especially computed properties that can throw or are async.
Checklist
- I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
- If possible, I've reproduced the issue using the
main
branch of this package. - This issue hasn't been addressed in an existing GitHub issue or discussion.
Expected behavior
@DependencyClient should ignore the property in init as it does for simple computed properties
Actual behavior
@DependencyClient ads the explicit computed property and its body to init signature
Steps to reproduce
Try to compile the following code
@DependencyClient
struct DemoDependency {
var getProp: () -> String = { "" }
var prop: String {
getProp()
}
var anotherProp: String {
get {
getProp()
}
}
var asyncProp: String {
get async throws {
getProp()
}
}
}
Dependencies version information
1.1.4
Destination operating system
iOS 17
Xcode version information
Version 15.1 (15C65)
Swift Compiler version information
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.0