Commit Graph

3 Commits

Author SHA1 Message Date
Robert Widmann
b6c3ad3ddc Augment Test for Confusing ExpressibleByNilLiteral Case
Add a test for an extremely confusing behavior of switches for
ExpressibleByNilLiteral-conforming types. From the looks of the expression
tree, one would hope that `case nil` would match such types. Instead, the
subject value is up-converted to an optional and compared to `nil` directly
with ~=.
2022-03-22 15:36:00 -07:00
Robert Widmann
fe6cefc63c Downgrade To A Warning 2022-03-15 15:22:46 -07:00
Robert Widmann
0a9a5c61c8 Diagnose 'case nil' in Non-Optional Switches
This is an anti-pattern since the resulting value will never compare equal to `nil`, and the entire switch-case is dead. This appears to be a misfeature as the subject value is simply type-checked against an optional which produces an injection which matches the global ~= for Optionals.

Effectively, `case nil:` becomes `case $match ~= nil`.

rdar://89742267
2022-03-14 20:16:31 -07:00