Commit Graph

8 Commits

Author SHA1 Message Date
Nishith Shah
8e2e625543 [Diagnostics] Use imperative msg for protocol conformance & switch-case fixits
This commit changes fixit messages from a question/suggestion to an
imperative message for protocol conformances and switch-case. Addresses
https://github.com/apple/swift/issues/67510.
2023-08-13 22:34:26 -07:00
Jordan Rose
4a8f81db2b Special-case diagnostic for when you just need @unknown default (#21695)
This is a new feature of Swift 5 mode, so it deserves at least a
little bit of explanation right in the diagnostic. If you have an
otherwise-fully-covered switch but can't assume the enum is frozen,
you'll now get this message:

    switch covers known cases, but 'MusicGenre' may have additional
    unknown values

Furthermore, if the enum comes from a system header, it looks like
this:

    switch covers known cases, but 'NSMusicGenre' may have additional
    unknown values, possibly added in future versions

...to further suggest the idea that even though your switch is covered
/now/, it might not handle everything in the /future/. This extra bit
is limited to system headers to avoid showing up on C enums defined in
your own project, for which it sounds silly. (The main message is
still valid though, since you can cram whatever you want into a C
enum, and people use this pattern to implement "private cases".)

rdar://problem/39367045
2019-01-08 08:45:23 -08:00
Jordan Rose
7c689c322e Prefer @unknown default over @unknown case _ in diagnostics
(and fix-its)
2018-04-05 17:54:49 -07:00
Jordan Rose
3e2411acd4 Diagnose when switching on a non-frozen enum without a catch-all case
The first half of Sema support for '@unknown'. The other part is
handling when the user /does/ write '@unknown', which results in
/other/ things being downgraded to warnings.

The diagnostics here are still pretty minimal; they should explain
what's going on with '@unknown' to someone who hasn't read the Swift 5
release notes.
2018-04-05 16:35:14 -07:00
Xi Ge
fb0985bf06 update test. 2017-05-02 13:28:38 -07:00
Robert Widmann
39494b2ba2 Rearrange test code for exhaustiveness 2017-04-28 02:06:39 -04:00
Xi Ge
b4cf37bf7d Sema: several improvements on missing switch cases diagnostics. (#8026)
1. Make sure the actions taken by fixits are reflected in diagnostics messages.
2. Issue missing cases diagnostics at the start of the switch statement instead of its end.
3. Use <#code#> instead of <#Code#> in the stub.
2017-03-10 19:32:37 -08:00
Jordan Rose
61798ff6ec [test] Rename test/ClangModules to test/ClangImporter. (#5618)
...to match the component in include/ and lib/. No content change.
2016-11-02 18:00:53 -07:00