Commit Graph

1616 Commits

Author SHA1 Message Date
Jordan Rose
fbf5a5162a [ClangImporter] Test for not being in a module correctly. (#9992)
For the Optional<Module *> returned by getClangSubmoduleForDecl, the
outside Optional specifies whether there's an answer at all. That
answer can still be null if the declaration comes from a bridging
header.  In this particular case, we're guaranteed to get an answer,
but that answer may be null.

rdar://problem/32463543
2017-05-31 09:24:51 -07:00
swift-ci
336787e622 Merge remote-tracking branch 'origin/master' into master-next 2017-05-28 19:48:35 -07:00
Alex Hoppen
6871a76965 [ClangImporter] Preparations for removal of getName on ValueDecl
With the introduction of special decl names, `Identifier getName()` on
`ValueDecl` will be removed and pushed down to nominal declarations
whose name is guaranteed not to be special. Prepare for this by calling
to `DeclBaseName getBaseName()` instead where appropriate.
2017-05-28 19:13:24 -07:00
swift-ci
3ccbd4bae8 Merge remote-tracking branch 'origin/master' into master-next 2017-05-28 18:08:53 -07:00
Jordan Rose
c0ccdb1626 Change getBaseName to return DeclBaseName instead of Identifier (#9968)
This changes `getBaseName()` on `DeclName` to return a `DeclBaseName`
instead of an `Identifier`. All places that will continue to be
expecting an `Identifier` are changed to call `getBaseIdentifier` which
will later assert that the `DeclName` is actually backed by an
identifier and not a special name.

For transitional purposes, a conversion operator from `DeclBaseName` to
`Identifier` has been added that will be removed again once migration
to DeclBaseName has been completed in other parts of the compiler.

Unify approach to printing declaration names

Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:55:03 -07:00
swift-ci
27424b37b0 Merge remote-tracking branch 'origin/master' into master-next 2017-05-17 13:08:40 -07:00
John McCall
7725e38d96 Don't mirror-import a protocol method if there's another method in
the class's protocol hierarchy that overrides it.

rdar://31471034
2017-05-17 00:06:58 -04:00
swift-ci
55c0615080 Merge remote-tracking branch 'origin/master' into master-next 2017-05-16 12:08:39 -07:00
Jordan Rose
837a180f0a [ClangImporter] Import-as-member support for anonymous enum constants. (#9633)
Previously this (1) did not work (the constant just disappeared), and
(2) would actually crash if the destination context was a class.

rdar://problem/32208235
2017-05-16 11:57:49 -07:00
swift-ci
d55ac42101 Merge remote-tracking branch 'origin/master' into master-next 2017-05-16 10:28:39 -07:00
Jordan Rose
5886bc1953 Merge pull request #9579 from jrose-apple/members-through-the-ages
[ClangImporter] Import ObjC members under Swift 3 and 4 names.
2017-05-16 10:16:52 -07:00
swift-ci
96736f749d Merge remote-tracking branch 'origin/master' into master-next 2017-05-15 23:08:37 -07:00
Doug Gregor
fef69478f6 [GSB] Introduce computeGenericSignature() for generic signature creation.
The GenericSignatureBuilder requires `finalize()` to be called before a
generic signature can be retrieved with `getGenericSignature()`. Most of the former isn’t strictly needed unless you want a generic signature, and the 
latter is potentially expensive. `computeGenericSignature()` combines the two
operations together, since they are conceptually related. Update most of the
callers to the former two functions to use `computeGenericSignature()`.
2017-05-15 17:16:50 -07:00
Jordan Rose
ec23dcaaac [ClangImporter] Find Swift 3 / 4 names via dynamic lookup too.
Finishes rdar://problem/29170671
2017-05-13 14:53:18 -07:00
Jordan Rose
280dacea4c [ClangImporter] Import ObjC members under Swift 3 and 4 names.
...so that developers get proper diagnostics when they use the wrong
name.

rdar://problem/29170671
2017-05-13 14:53:18 -07:00
Jordan Rose
478fdd7716 [ClangImporter] Remove remaining references to "Swift 2 variants".
We use the "variant" or "compatibility stub" code for Swift 3 / 4
renames as well.

No functionality change.
2017-05-13 14:53:18 -07:00
swift-ci
dec3920830 Merge remote-tracking branch 'origin/master' into master-next 2017-05-12 15:08:51 -07:00
Jordan Rose
9a9d139320 [ClangImporter] Import Swift 3 and 4 names for enumerators. (#9523)
Also lays the groundwork for rdar://problem/16513537, which is about
being able to find an enum by its original top-level name so that we
can show a diagnostic for that. I'll file a public bug about that
later.

rdar://problem/31893305
2017-05-12 14:51:40 -07:00
swift-ci
43e44510a5 Merge remote-tracking branch 'origin/master' into master-next 2017-05-11 13:28:31 -07:00
Slava Pestov
d663ee94df ClangImporter: Fix bug where members of renamed types were dropped
When "Always import types under their Swift 4 name." was
introduced, we still import members under their Swift 3 names;
this means the member's DeclContext imports as a compatibility
alias.

However, we did not look through the compatibility alias when
mapping the member's Clang DeclContext to a Swift DeclContext,
and as a result, the member was dropped on the floor.

Fixes <rdar://problem/31911531>, <rdar://problem/32042522>,
and probably <rdar://problem/31976966>.
2017-05-11 01:37:57 -07:00
swift-ci
4ebe4afe2a Merge remote-tracking branch 'origin/master' into master-next 2017-05-09 13:28:49 -07:00
practicalswift
437a186032 [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar) 2017-05-09 11:26:07 +02:00
Michael Gottesman
28df98f971 Merge remote-tracking branch 'origin/master' into master-next 2017-05-08 14:57:21 -07:00
Jordan Rose
01cb554387 Re-apply "Make all CF types Equatable and Hashable." (#4568)
Like NSObject, CFType has primitive operations CFEqual and CFHash,
so Swift should allow those types to show up in Hashable positions
(like dictionaries). The most general way to do this was to
introduce a new protocol, _CFObject, and then have the importer
automatically make all CF types conform to it.

This did require one additional change: the == implementation that
calls through to CFEqual is in a new CoreFoundation overlay, but the
conformance is in the underlying Clang module. Therefore, operator
lookup for conformances has been changed to look in the overlay for
an imported declaration (if there is one).

This re-applies 361ab62454, reverted in
f50b1e73dc, after a /very/ long interval
where we decided if it was worth breaking people who've added these
conformances on their own. Since the workaround isn't too difficult---
use `#if swift(>=3.2)` to guard the extension introducing the
conformance---it was deemed acceptable.

https://bugs.swift.org/browse/SR-2388
2017-05-08 14:05:11 -07:00
swift-ci
fb0de23ac1 Merge remote-tracking branch 'origin/master' into master-next 2017-05-04 21:28:34 -07:00
Doug Gregor
5934a86566 [Clang importer] Look through typealiases when importing members of swift_wrappers.
When a swift_wrapper'd type is renamed from Swift 3 -> 4, we create a
typealias for it. We need to look through that typealias when
deserializing members of that type, e.g., global variables of the
swift_wrapper'd type.
2017-05-04 16:41:01 -07:00
swift-ci
ab998376d5 Merge remote-tracking branch 'origin/master' into master-next 2017-05-03 15:28:32 -07:00
Jordan Rose
97110db66c [ClangImporter] Break infinite recursion when failing to import. (#9246)
Fixes a bug in cb9b9ea7 where a compatibility typealias for a type
that's been import-as-member'd can't resolve the member, because we're
already in the middle of importing members of the enclosing type.

No tests at the moment because I want to get this in quickly, but also
because the real issue is still there: this should import
successfully.

rdar://problem/31921746
2017-05-03 15:28:10 -07:00
swift-ci
7b686ac403 Merge remote-tracking branch 'origin/master' into master-next 2017-05-02 11:48:31 -07:00
Jordan Rose
de969c66c6 [ClangImporter] Don't infer 'Comparable' for swift_wrapper. (#9120)
The underlying type's ordering may not be appropriate for the wrapped
type (think an ordered list whose underlying type is NSString).
Frameworks can always add a Comparable conformance explicitly.

We squeak out of this being a source-breaking change by virtue of
never having released a working version of it. Rintaro fixed the
ambiguity problems back in f11b74176b, but that was after the last
rebranch for Swift 3.1.

rdar://problem/30166538
2017-05-02 11:41:03 -07:00
swift-ci
e0d9eeb4bb Merge remote-tracking branch 'origin/master' into master-next 2017-04-28 17:08:36 -07:00
Graydon Hoare
b5292f04f8 Add an assortment of new "always-on" metrics. 2017-04-28 13:56:13 -07:00
swift-ci
cdde06ac25 Merge remote-tracking branch 'origin/master' into master-next 2017-04-27 15:56:02 -07:00
Jordan Rose
dbc148bfb3 [ClangImporter] Tag compatibility aliases as such...
...so we can avoid showing an 'aka' for them...unless they are
themselves typealiases.
2017-04-26 13:07:03 -07:00
Jordan Rose
cb9b9ea734 [ClangImporter] Always import types under their Swift 4 name.
This means all cross-module references and all mangled names will
consistently use the Swift 4 name (the canonical type), no special
handling required.

The main thing we lose here is that the Swift 4 names of imported
types become usable in Swift 3 mode without any diagnostics, similar
to how most language features introduced in Swift 4 are available in
Swift 3 mode. It also implies that the Swift 4 name will show up in
demangled names.

rdar://problem/31616162
2017-04-26 13:07:03 -07:00
swift-ci
b0ff277c2a Merge remote-tracking branch 'origin/master' into master-next 2017-04-24 11:48:41 -07:00
Jordan Rose
7397340ca8 Don't inherit convenience inits if a designated init is missing. (#8708)
(which can happen if an imported class has un-importable initializers)

Our initializer model guarantees that it's safe to inherit convenience
initializers when a subclass has implemented all designated
initializers, since each convenience initializer will be implemented
by calling one of the designated initializers. If one of the
designated initializers /can't/ be implemented in Swift, however,
then inheriting the convenience initializer would not be safe.

This is potentially a source-breaking change, so the importer will
only actually record that it failed to import something in when
compiling in Swift 4 mode.

rdar://problem/31563662
2017-04-24 11:47:54 -07:00
swift-ci
771cdb8a82 Merge remote-tracking branch 'origin/master' into master-next 2017-04-24 11:08:52 -07:00
Jordan Rose
e575d2d5ba [ClangImporter] Error structs from enums are not imported decls.
Enums with the ns_error_domain attribute represent codes for NSError,
which means Swift developers will expect to interact with them in
terms of Error. SE-0112 improved bridging for these enums to generate
a struct with the following form:

    struct MyError: Error {
      @objc enum Code: RawRepresentable {
        case outOfMemory
        case fileNotFound
      }
      var userInfo: [NSObject: AnyObject] { get }
      static var outOfMemory: Code { get }
      static var fileNotFound: Code { get }
    }

where MyError.Code corresponds to the original MyError enum defined in
Objective-C. Until recently, both the enum and the synthesized struct
were marked as having the original enum as their "Clang node", but
that leads to problems: the struct isn't really ObjC-compatible, and
the two decls have the same USR. (The latter had already been worked
around.)

This commit changes the struct to be merely considered a synthesized
"external definition", with no associated Clang node. This meant
auditing everywhere that's looking for a Clang node and seeing which
ones applied to external definitions in general.

There is one regression in quality here: the generated struct is no
longer printed as part of the Swift interface for a header file, since
it's not actually a decl with a corresponding Clang node. The previous
change to AST printing mitigates this a little by at least indicating
that the enum has become a nested "Code" type.
2017-04-24 09:57:41 -07:00
swift-ci
f9243286d1 Merge remote-tracking branch 'origin/master' into master-next 2017-04-22 22:48:29 -07:00
Doug Gregor
facf1996b1 [Clang importer] Don't transfer IBAction attributes that don't make sense.
Fixes an error emitted on declarations imported from Objective-C,
rdar://problem/31776315.
2017-04-22 21:38:23 -07:00
swift-ci
8932679fa1 Merge remote-tracking branch 'origin/master' into master-next 2017-04-20 13:08:31 -07:00
practicalswift
a596961187 [gardening] Make parameter name comments match actual parameter names 2017-04-20 13:47:10 +02:00
swift-ci
faa74d7167 Merge remote-tracking branch 'origin/master' into master-next 2017-04-20 01:48:41 -07:00
Slava Pestov
f4b91cd118 AST: Remove unused 'resolver' argument from TypeBase::getSuperclass() 2017-04-20 00:37:38 -07:00
swift-ci
05599208ee Merge remote-tracking branch 'origin/master' into master-next 2017-04-17 17:08:32 -07:00
Slava Pestov
ea015822c8 ClangImporter: Remove a usage of getExistentialTypeProtocols() 2017-04-17 17:22:30 -06:00
swift-ci
49e3cfb16f Merge remote-tracking branch 'origin/master' into master-next 2017-04-13 23:48:31 -07:00
Slava Pestov
d58f049608 AST: Introduce ASTContext::getAnyObjectType()
This replaces a number of usages of KnownProtocolKind::AnyObject,
which is soon going away.
2017-04-13 21:17:05 -07:00
swift-ci
58efffc27a Merge remote-tracking branch 'origin/master' into master-next 2017-04-13 17:08:31 -07:00