Skip to content

Commit

Permalink
Propagate @ViewAction macro availability (#2785)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis authored Feb 8, 2024
1 parent d9a3cfb commit e10f42e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/ComposableArchitectureMacros/ViewActionMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public struct ViewActionMacro: ExtensionMacro {

let ext: DeclSyntax =
"""
extension \(type.trimmed): ComposableArchitecture.ViewActionSending {}
\(declaration.attributes.availability)extension \(type.trimmed): \
ComposableArchitecture.ViewActionSending {}
"""
return [ext.cast(ExtensionDeclSyntax.self)]
}
Expand Down
28 changes: 28 additions & 0 deletions Tests/ComposableArchitectureMacrosTests/ViewActionMacroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -438,5 +438,33 @@
"""
}
}

func testAvailability() {
assertMacro {
"""
@available(iOS 17, macOS 14, tvOS 17, visionOS 1, watchOS 10, *)
@ViewAction(for: Feature.self)
struct FeatureView: View {
@State var store: StoreOf<Feature>
var body: some View {
EmptyView()
}
}
"""
} expansion: {
"""
@available(iOS 17, macOS 14, tvOS 17, visionOS 1, watchOS 10, *)
struct FeatureView: View {
@State var store: StoreOf<Feature>
var body: some View {
EmptyView()
}
}
@available(iOS 17, macOS 14, tvOS 17, visionOS 1, watchOS 10, *) extension FeatureView: ComposableArchitecture.ViewActionSending {
}
"""
}
}
}
#endif

0 comments on commit e10f42e

Please sign in to comment.