8000 @_implements doesn't work for "get only property" · Issue #81772 · swiftlang/swift · GitHub
[go: up one dir, main page]

Skip to content
@_implements doesn't work for "get only property" #81772
@miku1958

Description

@miku1958

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

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0