You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-11288 Property wrappers aren't inherited as type aliases
relates to:
SR-11120 [5.1] [property wrapper] attribute lookup does not include typealiases
Issue Description:
A @propertyWrapper declared nested within any generic type can't be accessed from a typealias of it's parent type. See example below:
protocolDynamicObject{}enumValueContainer<O:DynamicObject>{@propertyWrapperstructRequired<V>{letkey:StringvarwrappedValue:Vinit(_ key:String, initial:()->V){self.key = key
self.wrappedValue =initial()}}}extensionDynamicObject{typealiasValue=ValueContainer<Self>}openclassMyObject:DynamicObject{/* Works, but not ideal */@ValueContainer<MyObject>.Required("name", initial:{""})varname:String/* Does NOT work: */// @Value.Required("age", initial: { 0 })// var age: Int/* Note, this had always worked */letbirthday=Value.Required<Date>("birthday", initial:{Date()})}
Note that it works if we don't use the @propertyWrapper mechanism and use the type directly as a value (as in birthday above).
The Self constraint on ValueContainer does not seem to be relevant as it still has the same problem if we assign any arbitrary protocol, for example:
I understand this was marked "Resolved" due to https://bugs.swift.org/browse/SR-11120 being fixed, but there is still the error where generic typealiases that involve Self could not be resolved
typealiasValue=ValueContainer<Self>
/* Unknown attribute 'Value.Required' */// @Value.Required("age", initial: { 0 })// var age: Int/* This works */letbirthday=Value.Required<Date>("birthday", initial:{Date()})
Since the direct use of Value.Required in stored properties work, it doesn't make much sense for it to NOT be allowed in propertyWrappers.
The example in the bug report works as expected on master. This fix was not cherry-picked into Swift 5.1, so it won't work on Xcode 11 or on a 5.1 toolchain. It may be cherry-picked later and available in a point release.
@theblixguy Is there any target Swift version for this patch?
It had been quite a while but it doesn't look like Swift 5.2 contains this commit yet so I'm curious if there is anything keeping it from being cherry-picked.
Environment
Swift 5.1, Xcode 11 release
Additional Detail from JIRA
md5: 4fdc99fc5b539614f8e04a4b134d7537
duplicates:
relates to:
Issue Description:
A
@propertyWrapper
declared nested within any generic type can't be accessed from atypealias
of it's parent type. See example below:Note that it works if we don't use the
@propertyWrapper
mechanism and use the type directly as a value (as inbirthday
above).The
Self
constraint onValueContainer
does not seem to be relevant as it still has the same problem if we assign any arbitrary protocol, for example:The text was updated successfully, but these errors were encountered: