Commit Graph

10 Commits

Author SHA1 Message Date
Saleem Abdulrasool
0c63feb978 Revert "Move out enum tests into a separate CXXInterop/enum directory" 2020-04-15 09:13:19 -07:00
Rosica Dejanovska
396ba4f0e2 Move out enum tests into a separate CXXInterop/enum directory
Currently, tests are scattered throughout multiple directories, making
it difficult to determine what is tested and what is not tested.
With upcoming work on interoperability between Swift and C++
(https://forums.swift.org/t/manifesto-interoperability-between-swift-and-c/33874),
we'd like to rearrange the tests and bring tests covering a single C/C++
feature next to each other.
This PR also adds tests for enabling C++ interop where possible.
2020-03-02 16:32:55 +01:00
Jordan Rose
6e25fd9ca4 Stop hiding '@frozen' from code completion (#26942)
And print it explicitly on imported NS_CLOSED_ENUMs.
2019-08-29 16:42:18 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -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
7405d515be Don't include unavailable cases in switch exhaustivity checking (#15849)
At one point compiler wouldn't let you use them in matches, so people have
had to use catch-all cases instead. SILGen already handles this because of
@_downgrade_exhaustivity_check, as well as non-exhaustive enums in
Swift 4 mode.

rdar://problem/33246586
2018-04-10 14:00:14 -07: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
Jordan Rose
6ea47bd603 [ClangImporter] Prefer later enum_extensibility over earlier ones
Since NS_ENUM has an enum_extensibility(open) in it already, we want
to allow people to undo that by sticking enum_extensibility(closed) on
the end of their enum.
2018-03-20 14:49:11 -07:00
Jordan Rose
52af3f3f65 [ClangImporter] Translate Clang's enum_extensibility to @_frozen
Still to do: test and fix up the use of multiple enum_extensibility
annotations, possibly with API notes. This is important because the
definition of NS/CF_ENUM /includes/ enum_extensibility(open) as of
Xcode 9.0; there should be a convenient out people can use to declare
exhaustive enums in C that's backwards-compatible.
2018-03-20 14:49:10 -07:00