// RUN: %target-typecheck-verify-swift // RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s 2>&1 | %FileCheck %s protocol P1 { associatedtype T } protocol P2 { associatedtype T : P1 } struct S1 : P2 where A : P1, C : P2, B == A.T.T, C.T == A.T { typealias T = C.T } struct S2 : P2 { typealias T = D } // Make sure that we can resolve the nested type A.T // in the same-type requirement 'A.T == B.T'. // // A is concrete, and S1>.T resolves to // S2.T, which is D. The typealias S1.T has a // structural type 'C.T'; since C is concrete, we // have to handle the case of an unresolved member // type with a concrete base. struct UnresolvedWithConcreteBase { // CHECK-LABEL: Generic signature: >, B : P2, C : P1, D == B.[P2]T, E == D.[P1]T, B.[P2]T == C.[P1]T> init(_: C) where A == S1>, B : P2, A.T == B.T, C : P1, D == C.T, E == D.T { } } // Make sure that we drop the conformance requirement // 'A : P2' and rebuild the generic signature with the // correct same-type requirements. struct OriginalExampleWithRedundancy where A : P2, B : P2, A.T == B.T { // CHECK-LABEL: Generic signature: >, B : P2, C : P1, D == B.[P2]T, E == D.[P1]T, B.[P2]T == C.[P1]T> init(_: C) where C : P1, D : P1, C.T : P1, A == S1>, C.T == D, E == D.T { } } struct OriginalExampleWithoutRedundancy where A : P2, B : P2, A.T == B.T { // CHECK-LABEL: Generic signature: >, B : P2, C : P1, D == B.[P2]T, E == D.[P1]T, B.[P2]T == C.[P1]T> init(_: C) where C : P1, A == S1>, C.T == D, E == D.T { } } // Same as above but without unnecessary generic parameters. struct WithoutBogusGenericParametersWithRedundancy where A : P2, B : P2, A.T == B.T { // CHECK-LABEL: Generic signature: >, B : P2, C : P1, B.[P2]T == C.[P1]T> init(_: C) where C : P1, C.T : P1, A == S1> {} } struct WithoutBogusGenericParametersWithoutRedundancy where A : P2, B : P2, A.T == B.T { // CHECK-LABEL: Generic signature: >, B : P2, C : P1, B.[P2]T == C.[P1]T> init(_: C) where C : P1, A == S1> {} }