Commit Graph

3 Commits

Author SHA1 Message Date
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Michael Ilseman
88060d580a [_BridgedNSError] Emit dynamic cast witness tables
_BridgedNSError conformances can affect the runtime behavior of
dynamic casts (e.g. 'is'). Unfortunately, the conformance is not
always emitted, in an effort to save space when not used. This change
forces the conformance witness tables to be emitted when we can detect
a dynamic cast to an _BridgedNSError conforming enum.

Test cases included, as well as a note about a potentially erroneous
path that is not currently handled: when the dynamic cast occurs in a
generic function to a generic type (and thus we are unsure which
conformances we need to pull in).
2016-02-08 15:18:48 -08:00
Michael Ilseman
7c9d53a0a0 [Clang Importer] Import ns_error_domain attribute with _BridgedNSError
ns_error_domain can now be used to communicate with the ClangImporter
when an enum has an associated error domain string. In this case, when
we import it as a Swift enum, we can also synthesize a conformance to
_BridgedNSError.

This allows the creation of something like NS_ERROR_ENUM, in which the
developer can declare an enum for the purposes of error handling. Adds
Sema and executable tests demonstrating this funcionality.

In order for the imported ns_error_domain bridging to work, we have to
at some point forcibly pull in a _BridgedNSError conformance, as one
will not be pulled in normally. This is a problem, and is explicitly
signaled in the provided test case
2016-02-04 17:23:28 -08:00