Marcus Rossel
Marcus Rossel

Reputation: 3258

Protocol reported as having 'Self or associated type requirements', when it doesn't have any

I have the following code:

protocol LanguageType: Hashable {
    var description: String { get }
}

extension LanguageType {
    var description: String { return "(Self.self)" }
    var hashValue: Int { return "(Self.self)".hashValue }
}

func ==<T: LanguageType, U: LanguageType>(left: T, right: U) -> Bool {
    return left.hashValue == right.hashValue
}

struct English: LanguageType { }

When I do the following:

let english: LanguageType = English()

I get the following error:

Error

Where is the associated type supposed to come from?
(Even if I remove the "\(Self.self)" it still complains.)

Upvotes: 1

Views: 116

Answers (1)

Daniel T.
Daniel T.

Reputation: 33967

Equatable has Self as an associated type requirement and LanguageType is indirectly derived from Equatable, therefore LanguageType has Self as an associated type requirement.

Upvotes: 2

Related Questions