Xcode-beta (7A152u): Protocol extensions need to be able to provide default stores too.

Number:rdar://21844730 Date Originated:15-Jul-2015 03:57 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A152u)
Classification:Enhancement Reproducible:Always
Default implementations can be coded against the protocol, however, this still produces a bunch of potential copy/paste boiler plate for implementors of a protocol when dealing with properties. Extensions should be able to provide default implementations for those as well.

See Key Value Coding for a full example: http://owensd.io/2015/07/14/key-value-coding-in-swift.html

But basically, this code needs to be copied for every single implementor of KeyValueCodable:

struct Person : KeyValueCodable {
    var _kvcstore: Dictionary<String, Any> = [:]

In the general case, **every** implementation will use the exact same thing. This is bad for code maintenance and is just bad code duplication.

I would expect to be able to do this:

extension KeyValueCodable {
    var _kvcstore: Dictionary<String, Any> = [:]


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!