-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
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.triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
I tried to override SwiftUI.View.body and add some test code, so I'd like to try using @_implements to redirect "var body: some View" to a custom protocol, but it looks like @_implements doesn't support get only properties?
I can find @_implements in the Swift source code for functions, and for type alias, but not for get only properties.
Reproduction
@_implements itself doesn't report an error, but the compiler gives me this error.
protocol TestableView {
associatedtype Body: View
var body: Body { get }
}
struct TestView: View, TestableView { // Type 'TestView' does not conform to protocol 'View'
// Type 'TestView' does not conform to protocol 'TestableView'
@_implements(SwiftUI.View, body)
@ViewBuilder
var testBody: some View {
body
}
@_implements(TestableView, body)
@ViewBuilder
var body: some View {
...
}
}
Expected behavior
@_implements
works for "get only property"
Environment
swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0
Additional information
No response
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.triage neededThis issue needs more specific labelsThis issue needs more specific labels