I have a question about property wrappers and protocols, also related to the hiding of the wrapper as an implementation detail. In beta 2, it looks like the following is disallowed:
protocol Foo {
@Published var bar: Int { get } // error: Property 'bar' declared inside a protocol cannot have a delegate
}
If we are always considering the wrapper type to be an implementation detail, it makes sense that this would be disallowed. But this is also disallowed:
protocol Foo {
var bar: Int { get }
var $bar: Published<Int> { get } // error: Cannot declare entity '$bar' with a '$' prefix
}
This would have the nice advantage that any wrapper type which supplies the proper projection could be substituted in for Published, even though it makes the protocol definition a bit more verbose.
Is there any plan to support this? If projections are "equal in importance to the wrapped value," it seems like there should be some way to specify in a protocol that there must be a certain projection available. The workaround of adding a var publishedBar: Published<Bar> requirement dilutes the intent of the protocol and makes conforming to it cumbersome. Is there a different way to achieve this that I'm not seeing?