// RUN: %target-typecheck-verify-swift func bet() where A : B {} // expected-error {{'where' clause cannot be attached to a non-generic declaration}} typealias gimel where A : B // expected-error {{'where' clause cannot be attached to a non-generic declaration}} // expected-error@-1 {{expected '=' in type alias declaration}} class dalet where A : B {} // expected-error {{'where' clause cannot be attached to a non-generic declaration}} protocol he where A : B { // expected-error 2 {{use of undeclared type 'A'}} // expected-error@-1 {{use of undeclared type 'B'}} associatedtype vav where A : B // expected-error{{use of undeclared type 'A'}} // expected-error@-1 {{use of undeclared type 'B'}} } struct Lunch { struct Dinner { var leftovers: T var transformation: (T) -> U } } class Deli { class Pepperoni {} struct Sausage {} } struct Pizzas { class NewYork { } class DeepDish { } } class HotDog { } struct Pepper {} struct ChiliFlakes {} func eatDinnerConcrete(d: Pizzas.NewYork, t: Deli.Pepperoni) { } func eatDinnerConcrete(d: Pizzas.DeepDish, t: Deli.Pepperoni) { } func badDiagnostic1() { _ = Lunch.NewYork>.Dinner( // expected-error {{expression type 'Lunch.NewYork>.Dinner' is ambiguous without more context}} leftovers: Pizzas.NewYork(), transformation: { _ in HotDog() }) } func badDiagnostic2() { let firstCourse = Pizzas.NewYork() var dinner = Lunch.NewYork>.Dinner( leftovers: firstCourse, transformation: { _ in HotDog() }) let topping = Deli.Pepperoni() eatDinnerConcrete(d: firstCourse, t: topping) // expected-error@-1 {{cannot invoke 'eatDinnerConcrete' with an argument list of type '(d: Pizzas.NewYork, t: Deli.Pepperoni)'}} // expected-note@-2 {{overloads for 'eatDinnerConcrete' exist with these partially matching parameter lists: (d: Pizzas.NewYork, t: Deli.Pepperoni), (d: Pizzas.DeepDish, t: Deli.Pepperoni)}} } // Real error is that we cannot infer the generic parameter from context func takesAny(_ a: Any) {} func badDiagnostic3() { takesAny(Deli.self) // expected-error {{argument type 'Deli<_>.Type' does not conform to expected type 'Any'}} } // Crash with missing nested type inside concrete type class OuterGeneric { class InnerGeneric where U:OuterGeneric { // expected-error@-1 {{'NoSuchType' is not a member type of 'T'}} func method() { _ = method } } } // Crash with missing types in requirements. protocol P1 { associatedtype A where A == ThisTypeDoesNotExist // expected-error@-1{{use of undeclared type 'ThisTypeDoesNotExist'}} associatedtype B where ThisTypeDoesNotExist == B // expected-error@-1{{use of undeclared type 'ThisTypeDoesNotExist'}} associatedtype C where ThisTypeDoesNotExist == ThisTypeDoesNotExist // expected-error@-1 2{{use of undeclared type 'ThisTypeDoesNotExist'}} }