You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/attr/attr_override.swift
+54Lines changed: 54 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -579,6 +579,60 @@ class SR_4206_DerivedGeneric_6<T>: SR_4206_BaseConcrete_6 {
579
579
overridefunc foo<T:SR_4206_Protocol_1>(arg:T){} // expected-error {{overridden method 'foo' has generic signature <T, T where T : SR_4206_Protocol_1> which is incompatible with base method's generic signature <T where T : SR_4206_Protocol_2>; expected generic signature to be <T, T where T : SR_4206_Protocol_2>}}
580
580
}
581
581
582
+
// Where clauses on contextually generic declarations
583
+
584
+
classSR_4206_Base_7<T>{
585
+
func foo1()where T:SR_4206_Protocol_1{} // expected-note {{overridden declaration is here}}
586
+
func foo2()where T:SR_4206_Protocol_1{}
587
+
}
588
+
589
+
classSR_4206_Derived_7<T>:SR_4206_Base_7<T>{
590
+
overridefunc foo1()where T:SR_4206_Protocol_2{} // expected-error {{overridden method 'foo1' has generic signature <T where T : SR_4206_Protocol_2> which is incompatible with base method's generic signature <T where T : SR_4206_Protocol_1>; expected generic signature to be <T where τ_0_0 : SR_4206_Protocol_1>}}
591
+
592
+
overridefunc foo2(){} // OK
593
+
}
594
+
595
+
// Subclass with new constraint on inherited generic param
overridefunc foo()where T:SR_4206_Protocol_1{} // OK
602
+
}
603
+
604
+
// Same-type to conformance visibility reabstraction
605
+
606
+
classSR_4206_Base_9<T>{
607
+
func foo()where T ==Int{}
608
+
}
609
+
classSR_4206_Derived_9<T>:SR_4206_Base_9<T>{
610
+
overridefunc foo()where T:FixedWidthInteger{} // OK
611
+
}
612
+
613
+
// Override with constraint on a non-inherited generic param
614
+
615
+
classSR_4206_Base_10<T>{
616
+
func foo()where T:SR_4206_Protocol_1{} // expected-note {{overridden declaration is here}}
617
+
}
618
+
classSR_4206_Derived_10<T, U>:SR_4206_Base_10<T>{
619
+
overridefunc foo()where U:SR_4206_Protocol_1{} // expected-error {{overridden method 'foo' has generic signature <T, U where U : SR_4206_Protocol_1> which is incompatible with base method's generic signature <T where T : SR_4206_Protocol_1>; expected generic signature to be <T, U where τ_0_0 : SR_4206_Protocol_1>}}
620
+
}
621
+
622
+
// Override with return type specialization
623
+
624
+
classSR_4206_Base_11<T>{
625
+
// The fact that the return type matches the substitution
0 commit comments