Hi. Is it possible in Swift 5.7 to use property wrapper with opaque result type?
@propertyWrapper ParamsStorage {
private var storage = Array< Param >()
var wrappedValue: some Collection<Param> { storage }
func addParam(_ param: Param) { storage.append(param) }
}
...
final class Event {
@ParamsStorage params: some Collection<Param>
// compiler error: Property type 'some Collection' (type of 'Event.params') does not match 'wrappedValue' type 'some Collection' (type of 'ParamsStorage.wrappedValue')
}
At the same time, the following code compiles:
final class Event {
private var _params: StatisticsParamsStorage = .init()
var params: some Collection<StatisticsEventParam> { _params.wrappedValue }
}
Seems like a bug in type inference. Is it expected behavior?