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/decl/protocol/protocols.swift
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -489,7 +489,17 @@ class C3 : P1 {} // expected-error{{type 'C3' does not conform to protocol 'P1'}
489
489
func h<T :C3>(_ x :T){
490
490
_ = x asP1 // expected-error{{protocol 'P1' can only be used as a generic constraint because it has Self or associated type requirements}}
491
491
}
492
-
492
+
func i<T :C3>(_ x :T?)->Bool{
493
+
return x is P1 // expected-error{{protocol 'P1' can only be used as a generic constraint because it has Self or associated type requirements}}
494
+
// FIXME: Bogus diagnostic. See SR-11920.
495
+
// expected-warning@-2 {{checking a value with optional type 'T?' against dynamic type 'P1' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}
496
+
}
497
+
func j(_ x :C1)->Bool{
498
+
return x is P1 // expected-error{{protocol 'P1' can only be used as a generic constraint because it has Self or associated type requirements}}
499
+
}
500
+
func k(_ x :C1?)->Bool{
501
+
return x is P1 // expected-error{{protocol 'P1' can only be used as a generic constraint because it has Self or associated type requirements}}
0 commit comments