// RUN: %target-typecheck-verify-swift infix operator • protocol Runcible { func runce() } protocol Fungible { func funge() } protocol Ansible { func anse() } protocol NeedsGenericMethods { func oneArgNoConstraints(x : T) // expected-note {{protocol requires function 'oneArgNoConstraints(x:)' with type ' (x: T) -> ()'}} func oneArgWithConstraint(x: T) // expected-note {{protocol requires function 'oneArgWithConstraint(x:)' with type ' (x: T) -> ()'}} func oneArgWithConstraints(x: T) // expected-note {{protocol requires function 'oneArgWithConstraints(x:)' with type ' (x: T) -> ()'}} func twoArgsOneVar(x: T, y: T) // expected-note {{protocol requires function 'twoArgsOneVar(x:y:)' with type ' (x: T, y: T) -> ()'}} func twoArgsTwoVars(x: T, y: U) // expected-note {{protocol requires function 'twoArgsTwoVars(x:y:)' with type ' (x: T, y: U) -> ()'}} static func •(x: Self, y: T) // expected-note {{protocol requires function '•' with type ' (TooTightConstraints, T) -> ()'}} } class EqualConstraints : NeedsGenericMethods { func oneArgNoConstraints(x: U) {} func oneArgWithConstraint(x: U) {} func oneArgWithConstraints(x: U) {} func twoArgsOneVar(x: U, y: U) {} func twoArgsTwoVars(x: U, y: V) {} } func •(x: EqualConstraints, y: T) {} // expected-note {{candidate has non-matching type ' (EqualConstraints, T) -> ()'}} class LooseConstraints : NeedsGenericMethods { func oneArgNoConstraints(x: U) {} func oneArgWithConstraint(x: U) {} func oneArgWithConstraints(x: U) {} func twoArgsOneVar(x: U, y: V) {} func twoArgsTwoVars(x: U, y: V) {} } func •(_ x: LooseConstraints, y: T) {} // expected-note {{candidate has non-matching type ' (LooseConstraints, T) -> ()'}} class TooTightConstraints : NeedsGenericMethods { // expected-error{{type 'TooTightConstraints' does not conform to protocol 'NeedsGenericMethods'}} func oneArgNoConstraints(x: U) {} // expected-note{{candidate has non-matching type ' (x: U) -> ()'}} func oneArgWithConstraint(x: U) {} // expected-note{{candidate has non-matching type ' (x: U) -> ()'}} func oneArgWithConstraints(x: U) {} // expected-note{{candidate has non-matching type ' (x: U) -> ()'}} func twoArgsOneVar(x: U) {} // expected-note{{candidate has non-matching type ' (x: U) -> ()'}} func twoArgsTwoVars(x: U, y: U) {} // expected-note{{candidate has non-matching type ' (x: U, y: U) -> ()'}} } func •(_ x: TooTightConstraints, y: Int) {} // expected-note {{candidate has non-matching type '(TooTightConstraints, Int) -> ()'}} // Regression test for a crash when resolving a reference to a generic method // in a protocol. protocol NeedsAGenericMethod { func method(_ x: T) } func usesAGenericMethod(_ x: U) { x.method(5) } struct L: Sequence {} // expected-error {{type 'L' does not conform to protocol 'Sequence'}} func z(_ x: L) { for xx in x {} }