// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -target %target-swift-5.9-abi-triple 2>&1 | %FileCheck %s protocol P { associatedtype A: P } // CHECK-LABEL: inferSameShape(ts:us:) // CHECK-NEXT: Generic signature: func inferSameShape(ts t: repeat each T, us u: repeat each U) where (repeat (each T, each U)): Any { } // CHECK-LABEL: desugarSameShape(ts:us:) // CHECK-NEXT: Generic signature: func desugarSameShape(ts t: repeat each T, us u: repeat each U) where repeat each T: P, repeat each U: P, (repeat ((each T).A, (each U).A)): Any {} // CHECK-LABEL: multipleSameShape1(ts:us:vs:) // CHECK-NEXT: Generic signature: func multipleSameShape1(ts t: repeat each T, us u: repeat each U, vs v: repeat each V) where (repeat (each T, each U, each V)): Any { } // CHECK-LABEL: multipleSameShape2(ts:us:vs:) // CHECK-NEXT: Generic signature: func multipleSameShape2(ts t: repeat each T, us u: repeat each U, vs v: repeat each V) where (repeat (each V, each T, each U)): Any { } // CHECK-LABEL: multipleSameShape3(ts:us:vs:) // CHECK-NEXT: Generic signature: func multipleSameShape3(ts t: repeat each T, us u: repeat each U, vs v: repeat each V) where (repeat (each U, each V, each T)): Any { } // CHECK-LABEL: multipleSameShape4(ts:us:vs:) // CHECK-NEXT: Generic signature: func multipleSameShape4(ts t: repeat each T, us u: repeat each U, vs v: repeat each V) where (repeat (each U, each T, each V)): Any { } // CHECK-LABEL: multipleSameShape5(ts:us:vs:) // CHECK-NEXT: Generic signature: func multipleSameShape5(ts t: repeat each T, us u: repeat each U, vs v: repeat each V) where (repeat (each T, each V, each U)): Any { } // CHECK-LABEL: multipleSameShape6(ts:us:vs:) // CHECK-NEXT: Generic signature: func multipleSameShape6(ts t: repeat each T, us u: repeat each U, vs v: repeat each V) where (repeat (each V, each U, each T)): Any { } struct Ts { struct Us { // CHECK-LABEL: Ts.Us.packEquality() // CHECK-NEXT: Generic signature: func packEquality() where repeat each T == each U, (repeat (each T, each U)): Any { } struct Vs { // CHECK-LABEL: Ts.Us.Vs.packEquality() // CHECK-NEXT: Generic signature: func packEquality() where repeat each T == each U, (repeat (each U, each V)): Any { } } } } // CHECK-LABEL: expandedParameters(_:transform:) // CHECK-NEXT: Generic signature: func expandedParameters(_ t: repeat each T, transform: repeat (each T) -> each Result) -> (repeat each Result) { fatalError() } ////// /// /// Same-type requirements should imply same-shape requirements. /// ////// // CHECK-LABEL: sameType1 // CHECK-NEXT: Generic signature: func sameType1(_: repeat (each T, each U)) where repeat each T: P, repeat each U: P, repeat (each T).A == (each U).A {} // Make sure inherited associated types are handled protocol Q: P where A: Q {} // CHECK-LABEL: sameType2 // CHECK-NEXT: Generic signature: func sameType2(_: repeat (each T, each U)) where repeat each T: Q, repeat each U: Q, repeat (each T).A.A == (each U).A.A {} ////// /// /// A same-type requirement between two pack expansion types /// should desugar to a same-shape requirement between their /// count types and a same-type requirement between their /// element types. /// ////// typealias First = T typealias Shape = (repeat First<(), each T>) // CHECK-LABEL: sameTypeDesugar1 // CHECK-NEXT: Generic signature: func sameTypeDesugar1(t: repeat each T, u: repeat each U) where Shape == Shape {} // CHECK-LABEL: sameTypeDesugar2 // CHECK-NEXT: Generic signature: func sameTypeDesugar2(t: repeat each T, u: repeat each U) where Shape == Shape {} /// More complex example involving concrete type matching in /// property map construction protocol PP { associatedtype A } struct G {} // CHECK-LABEL: sameTypeMatch1 // CHECK-NEXT: , repeat (each U).[PP]A == (each V).[PP]A> func sameTypeMatch1(t: T, u: repeat each U, v: repeat each V) where T.A == G, T.A == G, (repeat (each U, each V)) : Any {} // CHECK-LABEL: sameTypeMatch2 // CHECK-NEXT: func sameTypeMatch2(t: T, u: repeat each U, v: repeat each V) where T.A == Shape, T.A == Shape {}