Something I noticed today was that I cannot access the type of a property wrapper if its in another scope.
Here's an example:
@propertyWrapper struct MyWrapper<Value> {
var wrappedValue: Value
var projectedValue: String {
"Projected: \(wrappedValue)"
}
init(wrappedValue: Value) {
self.wrappedValue = wrappedValue
}
}
class MyClass {
@MyWrapper var wrapper = "Test"
func foo() {
print(wrapper) // prints test
print($wrapper) // prints Projected: test
print(_wrapper) // prints MyWrapper<Value>
}
}
class MyOtherClass {
var myClass = MyClass()
func foo() {
print(myClass.wrapper) // prints test
print(myClass.$wrapper) // prints Projected: test
print(myClass._wrapper) // '_wrapper' is inaccessible due to 'private' protection level
}
}
Is this intended behaviour?
Is there any way to expose _wrapper
?