Commit Graph

2609 Commits

Author SHA1 Message Date
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
Doug Gregor
bbe3e92da3 [SE-0160] Add @objcMembers attribute and infer it on XCTestCase. 2017-03-31 21:54:03 -07:00
swift-ci
95ee3da837 Merge remote-tracking branch 'origin/master' into master-next 2017-03-31 14:28:30 -07:00
Jordan Rose
19a2ad5f17 [ClangImporter] Disable assertion from 4b0255d5 for now.
We can still get into circular import cases that result in us trying
to import the members of a category before we've finished with the
members of the original class. I need to fix that, but for now disable
the assertion to unblock some Apple-internal bots.

rdar://problem/31374687
2017-03-31 13:54:16 -07:00
swift-ci
de7796f32f Merge remote-tracking branch 'origin/master' into master-next 2017-03-30 19:28:32 -07:00
Jordan Rose
1c85094cd2 [ClangImporter] Fix property redeclarations in generic classes.
Previously we were checking if a declaration was a redeclaration by
looking at the contextual type, but it should be looking at the
interface type in order to handle categories of classes using
Objective-C lightweight generics.

This also fixes a mistaken reuse of 'containerTy' after I changed its
meaning in the last commit. Doug's review comment was right: it /is/
bad to use an existing name for a new purpose!

More rdar://problem/30785976.
2017-03-30 17:50:11 -07:00
Jordan Rose
4b0255d5d3 [ClangImporter] Always load a class's members before any categories.
This ensures that any @property redeclarations that appear in class
extensions (a special kind of category in ObjC) do not affect the
primary type of the property as declared in the class itself.

To accomplish this, lookups in importDecl that are checking for
conflicts now no longer pull in new categories/extensions if the
current context is a ClassDecl.

rdar://problem/30785976
2017-03-30 15:21:08 -07:00
Jordan Rose
82d5bb5751 [ClangImporter] Add PrettyStackTrace entries for import-as-member.
No functionality change.
2017-03-30 14:36:07 -07:00
Sean Callanan
548c67bd3f [ClangImporter, IRGen] Fixed the build after 9242f6ab51
Minor changes to adhere to Clang API.

<rdar://problem/31305964>
2017-03-29 14:45:17 -07:00
swift-ci
ba43d5184d Merge remote-tracking branch 'origin/master' into master-next 2017-03-23 23:08:43 -07:00
Slava Pestov
6b11afcb8d ClangImporter: Correctly mark overrides of imported accessors 2017-03-23 22:20:09 -07:00
swift-ci
5b764ae984 Merge remote-tracking branch 'origin/master' into master-next 2017-03-23 13:48:53 -07:00
Jordan Rose
f7562e42b6 [ClangImporter] Add versioned stubs for import-as-member renames. (#8272)
A more general solution to ae458a84ad: import all versions of a name
that are going to show up as members, ignore those that aren't.

Further work on <rdar://problem/29170671> Import APIs under their
Swift 3 names.
2017-03-23 13:46:51 -07:00
swift-ci
5781da54af Merge remote-tracking branch 'origin/master' into master-next 2017-03-22 13:48:54 -07:00
Jordan Rose
0328139a77 [ClangImporter] Don't crash on versioned import-as-member stubs. (#8269)
If a top-level declaration is imported as a member in Swift 4 but not
in Swift 3, it would still show up in the lookup table for the
containing type in Swift 3 mode. We would import it, and then try to
add the top-level declaration to the containing type.

I'm about to redo this anyway so that the versioned stub will show up
(the one for the Swift 4 name) but this is the narrow fix that avoids
the assertion failure we were seeing.

rdar://problem/31161489
2017-03-22 13:48:03 -07:00
Saleem Abdulrasool
15565c116a Adjust for SVN r298393 2017-03-22 07:44:03 -07:00
Jordan Rose
67f29eb470 Remove default from DeclAttributes::isUnavailableInSwiftVersion. (#8208)
If this had a default, it should be the effective language version,
not the compiler language version. That is, in the Swift 4 compiler's
Swift 3 mode, we want to be acting like Swift 3, not Swift 4.
2017-03-20 12:37:56 -07:00
Huon Wilson
ca3a398b4a Merge pull request #8021 from huonw/protocol-where-clause
Parse/typecheck/print where clauses on protocols
2017-03-15 11:00:46 -07:00
Slava Pestov
f0e3459068 AST: Fix compiler_crasher regression from associated type where clause work
New GenericTypeParamDecls should always be created with an
InvalidDepth, to prevent canonicalization before the generic
parameter list has been type checked.
2017-03-14 00:10:43 -07:00
Huon Wilson
54f247693c [AST]/[Parse] parse where clauses on protocol declarations. 2017-03-09 16:08:16 -08:00
Doug Gregor
348c6b8001 Protocol conformance: store conformances needed for the requirement signature.
The protocol conformance checker verifies that all of the requirements
in the protocol's requirement signature are fulfilled. Save the
conformances from that check into the NormalProtocolConformance,
because this is the record of how that concrete type satisfies the
protocol requirements.

Compute, deserialize, and verify this information, but don't use it
for anything just yet. We'll use this to eliminate the "inherited
protocol map" and possibility some redundant type-witness
information.
2017-03-01 15:32:50 -08:00
Doug Gregor
5c2fe3496f Merge pull request #7740 from huonw/parse-assoc-type-where
(Mostly) Type-check where clauses on associated types
2017-02-27 22:06:51 -08:00
Huon Wilson
84e0a109a2 [AST] Explicitly track the validation state of Decls.
Previously some decls (TypeAliasDecl and ExtensionDecl) had bits
explicitly marking whether they've been validated, while other decls
just deduced this from hasInterfaceType. The doing the latter doesn't
work when the interface type can be computed before doing full
validation (such as protocols and associatedtypes, which have trivial
interface types), and so an explicit bit is adopted for all decls.
2017-02-24 19:21:33 -08:00
Jordan Rose
ee0dd49bd7 [ClangImporter] Use the current version to vend enum constant names.
The compiler itself no longer uses this API but the debugger does,
in order to pretty-print option sets.

The normal way to test this would be to add an LLDB-side test that
uses a framework with versioned API notes. Unfortunately I can't
think of a straightforward way to test it Swift-side.
2017-02-24 16:11:33 -08:00
Jordan Rose
c402030877 [ClangImporter] Give compatibility typealiases the correct version.
Unlike values, we can't import multiple copies of types under
different names and get good results. Instead, we make a typealias
that points back to the original type. Make sure this typealias is
flagged with whatever version is appropriate, rather than always using
"Swift 2".
2017-02-24 16:11:33 -08:00
Jordan Rose
79ed26f575 [ClangImporter] Use the correct name for replacement decls.
When a C declaration is marked unavailable with a replacement, we look
for the replacement to see how it would be imported into Swift. Make
sure we do that with respect to the active language version.
2017-02-24 16:11:33 -08:00
Jordan Rose
b9853c209e [ClangImporter] Fix marking of protocols with missing requirements.
This doesn't actually have any effect yet, but if we start importing
both Swift 3 and Swift 4 versions of protocol requirements and the
non-active one is unavailable, we might mistakenly mark the protocol
un-implementable even when the requirements that are needed are all
there. (Hopefully we would never make a protocol /less/ available in a
newer release, of course.) The test case is designed to catch that.
2017-02-24 16:11:33 -08:00
Jordan Rose
c9124d989d [ClangImporter] Import Swift 3 versions of top-level decls in Swift 4.
...and Swift 4 versions in Swift 3, and Swift 2 and "raw" versions in
both. This allows the compiler to produce sensible errors and fix-its
when someone uses the "wrong" name for an API. The diagnostics
certainly have room to improve, but at least the essentials are there.

Note that this commit only addresses /top-level/ decls, i.e. those
found by lookup into a module. We're still limited to producing all
members of a nominal type up front, so that'll require a slightly
different approach.

Part of rdar://problem/29170671
2017-02-24 14:01:10 -08:00