// RUN: %target-parse-verify-swift protocol P { } @objc protocol OP { } protocol CP : class { } @objc protocol SP : OP { static func createNewOne() -> SP } func fP(t: T) { } func fOP(t: T) { } func fOPE(t: OP) { } func fSP(t: T) { } func fAO(t: T) { } func fAOE(t: AnyObject) { } func fT(t: T) { } func testPassExistential(p: P, op: OP, opp: protocol, cp: CP, sp: SP, any: Any, ao: AnyObject) { fP(p) // expected-error{{cannot invoke 'fP' with an argument list of type '(P)'}} // expected-note{{expected an argument list of type '(T)'}} fAO(p) // expected-error{{cannot invoke 'fAO' with an argument list of type '(P)'}} // expected-note{{expected an argument list of type '(T)'}} fAOE(p) // expected-error{{argument type 'P' does not conform to expected type 'AnyObject'}} fT(p) fOP(op) fAO(op) fAOE(op) fT(op) fAO(cp) // expected-error{{cannot invoke 'fAO' with an argument list of type '(CP)'}} // expected-note{{expected an argument list of type '(T)'}} fAOE(cp) fT(cp) fP(opp) // expected-error{{cannot invoke 'fP' with an argument list of type '(protocol)'}} // expected-note{{expected an argument list of type '(T)'}} fOP(opp) // expected-error{{cannot invoke 'fOP' with an argument list of type '(protocol)'}} // expected-note{{expected an argument list of type '(T)'}} fAO(opp) // expected-error{{cannot invoke 'fAO' with an argument list of type '(protocol)'}} // expected-note{{expected an argument list of type '(T)'}} fAOE(opp) fT(opp) fOP(sp) fSP(sp) // expected-error{{cannot invoke 'fSP' with an argument list of type '(SP)'}} // expected-note{{expected an argument list of type '(T)'}} fAO(sp) fAOE(sp) fT(sp) fT(any) fAO(ao) fAOE(ao) } class GP {} class GOP {} class GCP {} class GSP {} class GAO {} func blackHole(t: Any) {} func testBindExistential() { blackHole(GP

()) // expected-error{{using 'P' as a concrete type conforming to protocol 'P' is not supported}} blackHole(GOP()) blackHole(GCP()) // expected-error{{using 'CP' as a concrete type conforming to protocol 'CP' is not supported}} blackHole(GAO

()) // expected-error{{type 'P' does not conform to protocol 'AnyObject'}} blackHole(GAO()) blackHole(GAO()) // expected-error{{using 'CP' as a concrete type conforming to protocol 'AnyObject' is not supported}} blackHole(GSP()) // expected-error{{'SP' cannot be used as a type conforming to protocol 'SP' because 'SP' has static requirements}} blackHole(GAO()) } // rdar://problem/21087341 protocol Mine {} class M1: Mine {} class M2: Mine {} extension Collection where Iterator.Element : Mine { final func takeAll() {} } func foo() { let allMine: [Mine] = [M1(), M2(), M1()] // FIXME: we used to have a better diagnostic here -- the type checker // would admit the conformance Mine : Mine, and later when computing // substitutions, a specific diagnostic was generated. Now the // conformance is rejected because Mine is not @objc, and we hit the // generic no overloads error path. The error should actually talk // about the return type, and this can happen in other contexts as well; // tracks improving QoI here. allMine.takeAll() // expected-error{{using 'Mine' as a concrete type conforming to protocol 'Mine' is not supported}} }