# How to use @\_implements in a get only property?

**URL:** <https://forums.swift.org/t/how-to-use-implements-in-a-get-only-property/67158>\
**Category:** Using Swift\
**Created:** [September 7, 2023, 1:48am UTC](https://forums.swift.org/t/how-to-use-implements-in-a-get-only-property/67158 "2023-09-07T01:48:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![miku1958](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/miku1958/32/11936_2.png) [@miku1958](https://forums.swift.org/u/miku1958)\
**Post date:** [September 7, 2023, 1:48am UTC](https://forums.swift.org/t/how-to-use-implements-in-a-get-only-property/67158/1 "2023-09-07T01:48:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![miku1958](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/miku1958/32/11936_2.png) [@miku1958](https://forums.swift.org/u/miku1958)\
**Post date:** [September 7, 2023, 1:50am UTC](https://forums.swift.org/t/how-to-use-implements-in-a-get-only-property/67158/2 "2023-09-07T01:50:53Z")

</div>

@\_implements itself doesn't report an error, but the compiler gives me this error.

```swift
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 {
        ...
    }
}

```

---

<div class="post-metadata">

**Author:** ![alexcohen](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/alexcohen/32/35539_2.png) [@alexcohen](https://forums.swift.org/u/alexcohen)\
**Post date:** [May 17, 2025, 10:45pm UTC](https://forums.swift.org/t/how-to-use-implements-in-a-get-only-property/67158/3 "2025-05-17T22:45:13Z")

</div>

Did you ever figure this out? I'm looking to do something very similar and ended up with the exact same errors.

---

<div class="post-metadata">

**Author:** ![atifdev10](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/atifdev10/32/44025_2.png) [@atifdev10](https://forums.swift.org/u/atifdev10)\
**Post date:** [April 6, 2026, 9:02pm UTC](https://forums.swift.org/t/how-to-use-implements-in-a-get-only-property/67158/4 "2026-04-06T21:02:08Z")

</div>

After doing a little bit of digging, I found out that `@_implements` does support get only variables (the name has to be different than the original requirement's name) but doesn't have automatic `associatedtype` resolving. For example, the following also doesn't compile:

```swift
protocol Foo {
    associatedtype T
    var a: T { get }
}

struct Bar: Foo { // 🛑 Type 'Bar' does not conform to protocol 'Foo'
    @_implements(Foo, a)
    var b: Int { 0 }
}

```

Adding a `typealias` for `T` resolves the issue for this case.

For your case, you need to specify the body directly. But, to not have your body type be 2000 characters long, I would suggest you extract the view:

```swift
protocol TestableView {
    associatedtype Body: View
    var body: Body { get }
}

struct TestView: View, TestableView {
    @_implements(View, Body)
    typealias BodyNormal = TestViewInternalNormal

    @_implements(TestableView, Body)
    typealias BodyTest = TestViewInternalTest

    @_implements(View, body)
    var swiftBody: TestViewInternalNormal {
        /* ... */
    }

    @_implements(TestableView, body)
    var testBody: TestViewInternalTest {
        /* ... */
    }
}

struct TestViewInternalNormal: View { /* ... */ }
struct TestViewInternalTest: View { /* ... */ }

```
