[swift-users] Using ... as a concrete type conforming to protocol ... is not supported

Jason Sadler jason.sadler at gmail.com
Fri Mar 25 16:51:31 CDT 2016


I think Simon was referring to two separate problems in his post - first:

> Using ‘KeyType' as a concrete type conforming to protocol 'Hashable' is not supported

And second:

> type 'Key' constrained to non-protocol type ‘String’

The first error (which is of particular interest to me) you can reproduce with only the first half, leaving out MyProtocol entirely:

public protocol KeyType : Hashable {
    
}

public protocol ValueType {
    
}

struct MyConcrete {
    let values : [KeyType: ValueType]
}

I’m fairly new to Swift, and this is my very first time on the mailing lists, so forgive me if this has been answered before…but this seems to me like an arbitrary shortcoming of the compiler and not an intentional language design decision. (As I understand, this comes out of the fact that protocols don’t conform to themselves…?)

I wonder if anyone knows whether there are any plans to look at this corner of the language and allow this use case.

(My particular use case can be seen here: https://gist.github.com/sadlerjw/2cc16b4375b02fe7f400 … and the best information I’ve been able to find on this so far is here: http://stackoverflow.com/questions/33112559/protocol-doesnt-conform-to-itself/33524927#33524927)

Thanks
Jason


More information about the swift-users mailing list