This @propertyWrapper
definition doesn't compile
@propertyWrapper
struct Precomputed<Wrapped> {
var wrappedValue: () -> Wrapped {
{ projectedValue }
}
var projectedValue: Wrapped
init(wrappedValue: () -> Wrapped) {
self.projectedValue = wrappedValue()
}
}
the error is
'init(wrappedValue:)' parameter type ('() -> Wrapped') must be the same as its 'wrappedValue' property type ('() -> Wrapped') or an @autoclosure thereof
but the error makes no sense because it says A must be the same as A
, which is of course true.
The error is fixed, though, if I change the initializer to init(wrappedValue: @escaping () -> Wrapped)
, but that's not actually escaping, and changing it like this would defeat the purpose.
What's the reason behind this? Is it a bug?