// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures 2>&1 | %FileCheck %s class A {} class B : A Z, Int> {} class C : B {} // ---------------------------------------------- // // Unifying two requirements in the same protocol // // ---------------------------------------------- // // CHECK-LABEL: .Pab@ // CHECK-NEXT: Requirement signature: Self.[Pab]B3, // CHECK-SAME: Self.[Pab]A3 == Int, // CHECK-SAME: Self.[Pab]T : B> protocol Pab { associatedtype T where T : A, T : B associatedtype A1 associatedtype A2 associatedtype A3 associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 } // CHECK-LABEL: .Pba@ // CHECK-NEXT: Requirement signature: Self.[Pba]B3, // CHECK-SAME: Self.[Pba]A3 == Int, // CHECK-SAME: Self.[Pba]T : B> protocol Pba { associatedtype T where T : B, T : A associatedtype A1 associatedtype A2 associatedtype A3 associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 } // CHECK-LABEL: .Pac@ // CHECK-NEXT: Requirement signature: [Self.[Pac]C2.[Sequence]Element], // CHECK-SAME: Self.[Pac]A3 == Int, // CHECK-SAME: Self.[Pac]C2 : Sequence, // CHECK-SAME: Self.[Pac]T : C> protocol Pac { associatedtype T where T : A, T : C associatedtype A1 associatedtype A2 associatedtype A3 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .Pca@ // CHECK-NEXT: Requirement signature: [Self.[Pca]C2.[Sequence]Element], // CHECK-SAME: Self.[Pca]A3 == Int, // CHECK-SAME: Self.[Pca]C2 : Sequence, // CHECK-SAME: Self.[Pca]T : C> protocol Pca { associatedtype T where T : C, T : A associatedtype A1 associatedtype A2 associatedtype A3 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .Pbc@ // CHECK-NEXT: Requirement signature: > protocol Pbc { associatedtype T where T : B, T : C associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .Pcb@ // CHECK-NEXT: Requirement signature: > protocol Pcb { associatedtype T where T : C, T : B associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // ------------------------------------------------ // // Unifying three requirements in the same protocol // // ------------------------------------------------ // // CHECK-LABEL: .Pabc@ // CHECK-NEXT: Requirement signature: [Self.[Pabc]C2.[Sequence]Element], // CHECK-SAME: Self.[Pabc]A3 == Int, // CHECK-SAME: Self.[Pabc]B1 == String, // CHECK-SAME: Self.[Pabc]B2 == Self.[Pabc]C1, // CHECK-SAME: Self.[Pabc]B3 == [Self.[Pabc]C2.[Sequence]Element], // CHECK-SAME: Self.[Pabc]B4 == Self.[Pabc]C3, // CHECK-SAME: Self.[Pabc]C2 : Sequence, // CHECK-SAME: Self.[Pabc]T : C> protocol Pabc { associatedtype T where T : A, T : B, T : C associatedtype A1 associatedtype A2 associatedtype A3 associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .Pacb@ // CHECK-NEXT: Requirement signature: [Self.[Pacb]C2.[Sequence]Element], // CHECK-SAME: Self.[Pacb]A3 == Int, // CHECK-SAME: Self.[Pacb]B1 == String, // CHECK-SAME: Self.[Pacb]B2 == Self.[Pacb]C1, // CHECK-SAME: Self.[Pacb]B3 == [Self.[Pacb]C2.[Sequence]Element], // CHECK-SAME: Self.[Pacb]B4 == Self.[Pacb]C3, // CHECK-SAME: Self.[Pacb]C2 : Sequence, // CHECK-SAME: Self.[Pacb]T : C> protocol Pacb { associatedtype T where T : A, T : C, T : B associatedtype A1 associatedtype A2 associatedtype A3 associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .Pbac@ // CHECK-NEXT: Requirement signature: [Self.[Pbac]C2.[Sequence]Element], // CHECK-SAME: Self.[Pbac]A3 == Int, // CHECK-SAME: Self.[Pbac]B1 == String, // CHECK-SAME: Self.[Pbac]B2 == Self.[Pbac]C1, // CHECK-SAME: Self.[Pbac]B3 == [Self.[Pbac]C2.[Sequence]Element], // CHECK-SAME: Self.[Pbac]B4 == Self.[Pbac]C3, // CHECK-SAME: Self.[Pbac]C2 : Sequence, // CHECK-SAME: Self.[Pbac]T : C> protocol Pbac { associatedtype T where T : B, T : A, T : C associatedtype A1 associatedtype A2 associatedtype A3 associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .Pbca@ // CHECK-NEXT: Requirement signature: [Self.[Pbca]C2.[Sequence]Element], // CHECK-SAME: Self.[Pbca]A3 == Int, // CHECK-SAME: Self.[Pbca]B1 == String, // CHECK-SAME: Self.[Pbca]B2 == Self.[Pbca]C1, // CHECK-SAME: Self.[Pbca]B3 == [Self.[Pbca]C2.[Sequence]Element], // CHECK-SAME: Self.[Pbca]B4 == Self.[Pbca]C3, // CHECK-SAME: Self.[Pbca]C2 : Sequence, // CHECK-SAME: Self.[Pbca]T : C> protocol Pbca { associatedtype T where T : B, T : C, T : A associatedtype A1 associatedtype A2 associatedtype A3 associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .Pcab@ // CHECK-NEXT: Requirement signature: [Self.[Pcab]C2.[Sequence]Element], // CHECK-SAME: Self.[Pcab]A3 == Int, // CHECK-SAME: Self.[Pcab]B1 == String, // CHECK-SAME: Self.[Pcab]B2 == Self.[Pcab]C1, // CHECK-SAME: Self.[Pcab]B3 == [Self.[Pcab]C2.[Sequence]Element], // CHECK-SAME: Self.[Pcab]B4 == Self.[Pcab]C3, // CHECK-SAME: Self.[Pcab]C2 : Sequence, // CHECK-SAME: Self.[Pcab]T : C> protocol Pcab { associatedtype T where T : C, T : A, T : B associatedtype A1 associatedtype A2 associatedtype A3 associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .Pcba@ // CHECK-NEXT: Requirement signature: [Self.[Pcba]C2.[Sequence]Element], // CHECK-SAME: Self.[Pcba]A3 == Int, // CHECK-SAME: Self.[Pcba]B1 == String, // CHECK-SAME: Self.[Pcba]B2 == Self.[Pcba]C1, // CHECK-SAME: Self.[Pcba]B3 == [Self.[Pcba]C2.[Sequence]Element], // CHECK-SAME: Self.[Pcba]B4 == Self.[Pcba]C3, // CHECK-SAME: Self.[Pcba]C2 : Sequence, // CHECK-SAME: Self.[Pcba]T : C> protocol Pcba { associatedtype T where T : C, T : B, T : A associatedtype A1 associatedtype A2 associatedtype A3 associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // --------------------------------------------------------- // // Unifying two requirements in another and current protocol // // --------------------------------------------------------- // protocol Pa { associatedtype T where T : A associatedtype A1 associatedtype A2 associatedtype A3 } protocol Pb { associatedtype T where T : B associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 } protocol Pc { associatedtype T where T : C associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .PaQb@ // CHECK-NEXT: Requirement signature: > protocol PaQb { associatedtype T : Pa where T.T : B associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 } // CHECK-LABEL: .PbQa@ // CHECK-NEXT: Requirement signature: Self.[PbQa]T.[Pb]B3, // CHECK-SAME: Self.[PbQa]A3 == Int, // CHECK-SAME: Self.[PbQa]T : Pb> protocol PbQa { associatedtype T : Pb where T.T : A associatedtype A1 associatedtype A2 associatedtype A3 } // CHECK-LABEL: .PaQc@ // CHECK-NEXT: Requirement signature: > protocol PaQc { associatedtype T : Pa where T.T : C associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .PcQa@ // CHECK-NEXT: Requirement signature: [Self.[PcQa]T.[Pc]C2.[Sequence]Element], // CHECK-SAME: Self.[PcQa]A3 == Int, // CHECK-SAME: Self.[PcQa]T : Pc> protocol PcQa { associatedtype T : Pc where T.T : A associatedtype A1 associatedtype A2 associatedtype A3 } // CHECK-LABEL: .PbQc@ // CHECK-NEXT: Requirement signature: > protocol PbQc { associatedtype T : Pb where T.T : C associatedtype C1 associatedtype C2 : Sequence associatedtype C3 } // CHECK-LABEL: .PcQb@ // CHECK-NEXT: Requirement signature: protocol PcQb { associatedtype T : Pc where T.T : B associatedtype B1 associatedtype B2 associatedtype B3 associatedtype B4 }