Hi all,
I was trying to do something like below in Xcode 7.2.1-
public protocol KeyType : Hashable {
}
public protocol ValueType {
}
struct MyConcrete : MyProtocol {
let values : [KeyType: ValueType]
}
extension Dictionary where Key: KeyType, Value: ValueType {
public var theThing : MyProtocol {
get {
return MyConcrete(self)
}
}
}
The problem I get with the code above is -
Using ‘KeyType' as a concrete type conforming to protocol 'Hashable' is not supported
Alternatively, changing KeyType to be a concrete type (such as String) results in the error on the extension-
type 'Key' constrained to non-protocol type ‘String'
The ideal situation would use Conditional conformance so a [KeyType: ValueType] could itself conform to MyProtocol. This looks like it will come with Swift 3. Is doing something like the above possible pre-Swift 3?
Thanks
Simon