// RUN: %target-typecheck-verify-swift struct K {} // expected-note 6{{'U' declared as parameter to type 'K'}} protocol Q {} struct S1: ExpressibleByArrayLiteral { // expected-note 2{{where 'T' = 'K'}} init(_ x: T) {} init(arrayLiteral: T...) {} } typealias R1 = S1 // expected-note {{where 'T' = 'K'}} expected-note 2{{where 'T' = 'K'}} func foo(_ x: K) { let _ = [x] as S1 // expected-error {{generic struct 'S1' requires that 'K' conform to 'Q'}} let _ = [x] as R1 // expected-error {{generic type alias 'R1' requires that 'K' conform to 'Q'}} let _: S1 = [x] // expected-error {{generic struct 'S1' requires that 'K' conform to 'Q'}} // FIXME: We ought to be able to infer 'U' here. let _: R1 = [x] // expected-error 2 {{generic type alias 'R1' requires that 'K' conform to 'Q'}} // expected-error@-1 2 {{generic parameter 'U' could not be inferred}} } protocol P2 { associatedtype A } struct S2: P2 {} // expected-note 3{{where 'A' = 'K'}} typealias R2 = S2 // expected-note 2{{where 'A' = 'K'}} expected-note 2{{where 'A' = 'K'}} // Same as S2, but without the Q requirement. struct S3: P2 {} typealias R3 = S3 // expected-note {{where 'A' = 'K'}} expected-note {{where 'A' = 'K'}} func foo(_ y: T.A.Type) -> T {} let _ = foo(K.self) as S2 // expected-error {{generic struct 'S2' requires that 'K' conform to 'Q'}} let _ = foo(K.self) as R2 // expected-error {{generic type alias 'R2' requires that 'K' conform to 'Q'}} let _ = foo(K.self) as R3 // expected-error {{generic type alias 'R3' requires that 'K' conform to 'Q'}} let _: S2 = foo(K.self) // expected-error {{generic struct 'S2' requires that 'K' conform to 'Q'}} // FIXME: We ought to be able to infer 'U' here. let _: R2 = foo(K.self) // expected-error 2{{generic type alias 'R2' requires that 'K' conform to 'Q'}} // expected-error@-1 2 {{generic parameter 'U' could not be inferred}} let _: R3 = foo(K.self) // expected-error {{generic type alias 'R3' requires that 'K' conform to 'Q'}} // expected-error@-1 2 {{generic parameter 'U' could not be inferred}} func foo(_ x: T.Type, _ y: T.A.Type) {} foo(S2<_>.self, K.self) // expected-error {{generic struct 'S2' requires that 'K' conform to 'Q'}} foo(R2<_>.self, K.self) // expected-error {{generic type alias 'R2' requires that 'K' conform to 'Q'}} struct S4 { // expected-note {{where 'T' = 'Int'}} init(_ x: T) {} } _ = S4<_>(0) // expected-error {{generic struct 'S4' requires that 'Int' conform to 'Q'}}