Skip to content

Commit 81071c0

Browse files
authored
Merge pull request #28627 from CodaFi/existential-dread
2 parents 84e23cc + 0063b8e commit 81071c0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/decl/protocol/protocols.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,17 @@ class C3 : P1 {} // expected-error{{type 'C3' does not conform to protocol 'P1'}
489489
func h<T : C3>(_ x : T) {
490490
_ = x as P1 // expected-error{{protocol 'P1' can only be used as a generic constraint because it has Self or associated type requirements}}
491491
}
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}}
502+
}
493503

494504

495505
protocol P4 {

0 commit comments

Comments
 (0)