Skip to content

Commit 1b224bd

Browse files
committed
Add a test that verifyies comparing to a .none case that isn't Optional.none still works
1 parent 2e76562 commit 1b224bd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/expr/cast/nil_value_to_optional.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,14 @@ _ = d! // expected-error {{cannot force unwrap value of non-optional type 'D'}}
3434
_ = dopt == nil
3535
_ = diuopt == nil
3636
_ = diuopt is ExpressibleByNilLiteral // expected-warning {{'is' test is always true}}
37-
_ = produceD() is ExpressibleByNilLiteral // expected-warning {{'is' test is always true}}
37+
_ = produceD() is ExpressibleByNilLiteral // expected-warning {{'is' test is always true}}
38+
39+
enum E {
40+
case none
41+
}
42+
func test(_ e: E) {
43+
_ = e == .none
44+
_ = e == E.none
45+
_ = e == Optional.none // expected-warning {{comparing non-optional value of type 'E' to 'nil' or 'Optional.none' always returns false}}
46+
_ = e == E?.none // expected-warning {{comparing non-optional value of type 'E' to 'nil' or 'Optional.none' always returns false}}
47+
}

0 commit comments

Comments
 (0)