// RUN: %target-typecheck-verify-swift struct K {} protocol Q {} struct ConformingType: Q {} struct S1: ExpressibleByArrayLiteral { // expected-note 2{{where 'T' = 'K'}} init(_ x: T) {} init(arrayLiteral: T...) {} } typealias R1 = S1 // 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'}} let _: R1 = [x] // expected-error {{generic type alias 'R1' requires that 'K' conform to 'Q'}} } protocol P2 { associatedtype A } struct S2: P2 {} // expected-note 3{{where 'A' = 'K'}} typealias R2 = S2 // expected-note 3{{where 'A' = 'K'}} // Same as S2, but without the Q requirement. struct S3: P2 {} typealias R3 = S3 // expected-note 2{{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'}} let _: R2 = foo(K.self) // expected-error {{generic type alias 'R2' requires that 'K' conform to 'Q'}} let _: R3 = foo(K.self) // expected-error {{generic type alias 'R3' requires that 'K' conform to 'Q'}} 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'}} func testLocalOuterGeneric(_ x: T) { typealias X = (T, U) // expected-note {{where 'U' = 'String'}} let _: X<_> = (x, "") // expected-error {{generic type alias 'X' requires that 'String' conform to 'Q'}} let _: X<_> = (x, ConformingType()) } struct TestParentGeneric { typealias X = (T, U) // expected-note {{where 'U' = 'String'}} func bar(_ x: T) { let _: X<_> = (x, "") // expected-error {{generic type alias 'X' requires that 'String' conform to 'Q'}} let _: X<_> = (x, ConformingType()) } }