Commit Graph

1086 Commits

Author SHA1 Message Date
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
Doug Gregor
2f167ab5a1 Merge pull request #8758 from DougGregor/synthesized-type-witnesses
[Clang importer] Resolve synthesized type witnesses without the type checker
2017-04-13 16:55:04 -07:00
swift-ci
531cd847cd Merge remote-tracking branch 'origin/master' into master-next 2017-04-13 16:28:30 -07:00
Jordan Rose
979bced4de Merge pull request #8751 from jrose-apple/unbind-the-typealiases-and-set-them-free
[ClangImporter] Use UnboundGenericTypes in compatibility typealiases.
2017-04-13 16:27:38 -07:00
Doug Gregor
e013226ee4 [Clang importer] Synthesize _ObjectiveCType typealias for bridged, wrapped types.
Rather than requiring associated type witness inference to go and
figure out the _ObjectiveCType type from the other witnesses for imported
swift_wrapper/swift_newtype'd types, synthesize the typealias directly in the
importer. This is a simplification and a performance optimization.
2017-04-13 15:49:34 -07:00
Doug Gregor
940af98e4a [Clang importer] Synthesize Element typealias for OptionSet types.
Rather than requiring associated type witness inference to go and
figure out the Element type from the other witnesses for imported
OptionSet types, synthesize the typealias directly in the
importer. This is a simplification and a performance optimization.
2017-04-13 15:49:34 -07:00
Doug Gregor
3e5b191ad9 [Clang importer] Synthesize RawValue typealias for RawRepresentable.
Rather than requiring associated type witness inference to go and
figure out the RawValue type from the rawValue witnesses for imported,
RawRepresentable types, synthesize the typealias directly in the
importer. This is a simplification and a performance optimization.
2017-04-13 15:49:34 -07:00
Jordan Rose
cf50257ce8 [ClangImporter] Use UnboundGenericTypes in compatibility typealiases.
When a type is renamed, we leave behind a "compatibility typealias"
whose underlying type uses the new name. For generic types, though, we
were using the generic parameters and environment of the original
type, which is completely bogus. "Fix" this by just dropping the
generic part entirely and making a typealias that refers to the
/unbound/ generic type, as if written as `typealias OldName = NewName`
instead of `typealias OldName<Element> = NewName<Element>`. The rest
of the compiler can handle that fine.
2017-04-13 14:13:50 -07:00
swift-ci
c523ca44ad Merge remote-tracking branch 'origin/master' into master-next 2017-04-12 01:08:31 -07:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00
Erik Eckstein
d7cf2a483f ClangImporter: Adjust call to BinaryOperator constructor after clang change r298877.
Thanks @anemet for the fix.
2017-04-06 14:47:25 -07:00
swift-ci
34cb269d23 Merge remote-tracking branch 'origin/master' into master-next 2017-04-04 23:08:31 -07:00
swift-ci
23989db8b4 Merge pull request #8550 from DougGregor/repeal-conformance-death-tax 2017-04-04 22:55:25 -07:00
Doug Gregor
30ef37cb83 [AST] Eliminate "inherited conformances" from NormalProtocolConformance.
All of this information is recoverable from the more-general,
more-sane signature conformances, so stop
recording/serializing/deserializing all of this extra stuff.
2017-04-04 22:20:50 -07:00
swift-ci
1875c9c69d Merge remote-tracking branch 'origin/master' into master-next 2017-04-04 15:28:31 -07:00
Jordan Rose
bd1920ba67 [ClangImporter] Fix versioned stubs for functions-as-members. (#8539)
That is, the stubs we generate when you rename a C global function
imported as a type member using the SwiftName API note. (See the
test case changes.) Previously we hit an assertion.

For good measure, also fix versioned stubs for types-as-members,
which were always added to their original context rather than the
new context.

rdar://problem/31435658
2017-04-04 15:20:30 -07:00
swift-ci
ee9a8a4f41 Merge remote-tracking branch 'origin/master' into master-next 2017-04-04 11:08:31 -07:00
Jordan Rose
1821430902 [ClangImporter] Update d1f0a245df for API changes in 37491e63a.
Slava even mentioned he was going to make these changes; I just forgot.
2017-04-04 10:13:00 -07:00
swift-ci
8abbef95a0 Merge remote-tracking branch 'origin/master' into master-next 2017-04-04 10:08:50 -07:00
Jordan Rose
b84603da46 Merge pull request #8515 from jrose-apple/check-conformances-more-carefully-for-swift_wrapper
[ClangImporter] Don't do a full conformance check for swift_wrapper types.
2017-04-04 09:59:58 -07:00
swift-ci
5bfb1067ad Merge remote-tracking branch 'origin/master' into master-next 2017-04-03 19:48:44 -07:00
Jordan Rose
aded485ddc [ClangImporter] Infer SwiftImportAsNonGeneric for Foundation for now.
There are Apple-internal buildbots that test without the compiler API
notes present, so 08b6c5f wasn't good enough. For now, keep inferring
that subclasses of NSArray et al /within Foundation/ should be
imported as non-generic even in Swift 4 mode.

rdar://problem/31418165
2017-04-03 18:07:01 -07:00
Jordan Rose
f422612a74 [ClangImporter] Re-enable "class members before categories" assertion.
Reverts PR #8468 to re-add an assertion I had temporarily removed.
I think we can actually enforce this condition now.

This reverts commit 131513e31f, reversing
changes made to ae6268155a.
2017-04-03 17:10:58 -07:00
Jordan Rose
d1f0a245df [ClangImporter] Avoid full conformance checks for swift_wrapper types.
Avoids yet another circular import issue: conformance on type X ->
associated types -> members -> members of superclass type (for naming
conflicts) -> SwiftWrapper type -> conformances on underlying type X.
Normally this circularity is fine, but I still want to put back the
assertion I reverted in 19a2ad5f17.

I unfortunately don't have a test for the actual failure here; it came
up on some Apple-internal code and heavily depended on both Foundation
and the standard library. I did confirm that this fixes it, and it
looks like it does so without causing any issues for swift_wrapper
types.

More rdar://problem/30785976
2017-04-03 17:09:32 -07:00
swift-ci
34daa4ac15 Merge remote-tracking branch 'origin/master' into master-next 2017-04-03 15:48:42 -07:00
Jordan Rose
08b6c5f0c9 [ClangImporter] Add support for 'SwiftImportAsNonGeneric' in API notes (#6962)
Generic Objective-C classes with this annotation will be imported as
non-generic in Swift. The Swift 3 behavior hardcoded a certain set of
class /hierarchies/ as permanently non-generic, and this is preserved
in Swift 3 mode.

Actually using this API note in a versioned way (as opposed to just
marking the class non-generic in all language versions) will cause
horrible source compatibility problems in the mix-and-match cases,
where Swift 3 code presents a non-generic type that Swift 4 expects to
be generic or vice versa.  Fixes for this will come later; right now
it's more important to add support for the feature at all.

To avoid unwanted changes in Swift 4, this commit also adds API notes
to make any existing classes in the previously-hardcoded set continue
to import as non-generic even in Swift 4. The difference is that
/subclasses/ of these classes may come in as generic. (If we want to
make a change here, that can be a separate commit.)

rdar://problem/31226414 (Swift side of rdar://problem/28455962)
2017-04-03 15:39:19 -07:00
swift-ci
e465cb51d0 Merge remote-tracking branch 'origin/master' into master-next 2017-04-03 13:48:30 -07:00
Doug Gregor
57c607e339 [SE-0160] Map Clang's swift_objc_members attribute to @objcMembers.
This finishes the implementation of SE-0160, tracked by SR-4481 /
rdar://problem/28497874.
2017-04-03 11:48:55 -07:00
swift-ci
5c5ec5641e Merge remote-tracking branch 'origin/master' into master-next 2017-04-03 01:08:30 -07:00
practicalswift
3a652a3939 [gardening] Remove unused variables 2017-04-02 16:02:44 +02:00
swift-ci
9607aa1829 Merge remote-tracking branch 'origin/master' into master-next 2017-03-31 22:48:31 -07:00