I am trying to use a ReferenceWritableKeyPath to a non-copyable value.
The compiler does not allow it. I produced this minimal example:
enum Link : ~Copyable {
case last
}
public protocol Linkage {
associatedtype Element : AnyObject
static var link: ReferenceWritableKeyPath<Element, Link> { get }
}
The compiler surprised me by complaining:
ncwkp.swift:7:19: error: type 'Link' does not conform to protocol
'Copyable'
5 | public protocol Linkage {
6 | associatedtype Element : AnyObject
7 | static var link: ReferenceWritableKeyPath<Element, Link> { get }
> `- error: type 'Link' does not conform to
protocol 'Copyable'
8 | }
9 |
The only thing I can think of is that the KeyPath family of types may
need to encompass borrowing/consuming semantics before a keypath to a
noncopyable value can work.
David