// RUN: %target-parse-verify-swift //===----------------------------------------------------------------------===// // Generic function declarations //===----------------------------------------------------------------------===// func f0(x: Int, y: Int, t: T) { } func f1(x: Int, y: Int, t: T) { } func f2>(x: Int, y: Int, t: T) { } func f3 ()>(x: Int, y: Int, t: T) { } // expected-error{{expected a type name or protocol composition restricting 'T'}} func f4(x: T, y: T) { } // Name lookup within local classes. func f5(x: T, y: U) { struct Local { // expected-error {{type 'Local' nested in generic function 'f5' is not allowed}} func f() { _ = 17 as T // expected-error{{'Int' is not convertible to 'T'}} {{14-16=as!}} _ = 17 as U // okay: refers to 'U' declared within the local class } typealias U = Int } } // Non-protocol type constraints. func f6(x: T) {} // expected-error{{use of undeclared type 'Wonka'}} // FIXME: The term 'inherit' is unfortunate here. func f7(x: T) {} // expected-error{{inheritance from non-protocol, non-class type 'Int'}} func f8 (x: Int) {} //expected-error{{generic parameter 'T' is not used in function signature}} public class A { init(){} //expected-error{{generic parameter 'T' is not used in function signature}} public func f9(x:T, y:X) {} //expected-error{{generic parameter 'U' is not used in function signature}} public func f10(x:Int) {} public func f11(x:X, y:T) {} //expected-error{{generic parameter 'U' is not used in function signature}} } protocol P { associatedtype A } func f12(x: T) -> T.A {} //expected-error{{cannot specialize non-generic type 'T.A'}}{{29-34=}}