How to make Class.Type or Protocol.Type Hashable?

public protocol ProtocolName {}
public class ClassName {}

private var setOfClassTypes: Set<ProtocolName.Type> = []
private var setOfProtocolsTypes: Set<ClassName.Type> = []

Type ‘ProtocolName.Type’ does not conform to protocol ‘Hashable’
Type ‘ClassName.Type’ does not conform to protocol ‘Hashable’

Maybe someone know how to make this types are Hashable? Is it even possible?

Class ClassName has few subclasses.

Hi @afterfriday,
this is now resolved with Swift 4.1 where Hashable and Equtable are part and thereby would not throw errors as you have been facing in the past.

cheers,

Jayant

1 Like