// RUN: %target-typecheck-verify-swift // RUN: %target-typecheck-verify-swift -typecheck -debug-generic-signatures %s > %t.dump 2>&1 // RUN: %FileCheck %s < %t.dump class A { func foo() { } } class B : A { func bar() { } } class Other { } func f1(_: T) where T : Other {} // expected-error{{generic parameter 'T' cannot be a subclass of both 'A' and 'Other'}} func f2(_: T) where T : B {} class GA {} class GB : GA {} protocol P {} func f3(_: T, _: U) where U : GA {} func f4(_: T, _: U) where U : GA {} func f5>(_: T, _: U) {} func f6, T : P>(_: T, _: U) {} func f7(_: T, _: U) where U : GA, T : P {} func f8>(_: T) where T : GA {} // expected-error{{generic parameter 'T' cannot be a subclass of both 'GA' and 'GA'}} func f9>(_: T) where T : GB {} func f10>(_: T) where T : GA {} // FIXME: Extra diagnostics because we're re-building the archetype builder. func f11>(_: T) { } // expected-error 2{{superclass constraint 'T' : 'GA' is recursive}} func f12, U : GB>(_: T, _: U) { } // expected-error 2{{superclass constraint 'U' : 'GB' is recursive}} // expected-error 2{{superclass constraint 'T' : 'GA' is recursive}} func f13>(_: T, _: U) { } // expected-error{{inheritance from non-protocol, non-class type 'U'}} // rdar://problem/24730536 // Superclass constraints can be used to resolve nested types to concrete types. protocol P3 { associatedtype T } protocol P2 { associatedtype T : P3 } class C : P3 { typealias T = Int } class S : P2 { typealias T = C } extension P2 where Self.T : C { // CHECK: superclass_constraint.(file).P2.concreteTypeWitnessViaSuperclass1 // CHECK: Generic signature: // CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : P2, τ_0_0.T : C> func concreteTypeWitnessViaSuperclass1(x: Self.T.T) {} } // CHECK: superclassConformance1 // CHECK: Requirements: // CHECK-NEXT: τ_0_0 : C [explicit @ // CHECK-NEXT: τ_0_0 : P3 [inherited @ // CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : C> func superclassConformance1(t: T) where T : C, T : P3 {} // CHECK: superclassConformance2 // CHECK: Requirements: // CHECK-NEXT: τ_0_0 : C [explicit @ // CHECK-NEXT: τ_0_0 : P3 [inherited @ // CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : C> func superclassConformance2(t: T) where T : C, T : P3 {} protocol P4 { } class C2 : C, P4 { } // CHECK: superclassConformance3 // CHECK: Requirements: // CHECK-NEXT: τ_0_0 : C2 [explicit @ // CHECK-NEXT: τ_0_0 : P4 [inherited @ // CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : C2> func superclassConformance3(t: T) where T : C, T : P4, T : C2 {}