Commit Graph

1242 Commits

Author SHA1 Message Date
swift-ci
058c33f8be Merge remote-tracking branch 'origin/master' into master-next 2017-07-05 16:08:51 -07:00
swift-ci
7763bade6f Merge pull request #10768 from CodaFi/lets-not-get-into-specifics 2017-07-05 16:03:56 -07:00
swift-ci
2dc84ee365 Merge remote-tracking branch 'origin/master' into master-next 2017-07-05 15:28:50 -07:00
Robert Widmann
b19bae4ac4 Import the value of a subscript setter as owned
The translation from a bit to the specifiers exposed this instance
in the Clang importer where we hooked up a parameter as mutable
but never reflected that in the interface type.

A future patch requires that this parameter be immutable.
2017-07-05 14:16:54 -07:00
Robert Widmann
4da853e7cb Rename Specifier::None to Specifier::Owned 2017-07-05 14:02:26 -07:00
Arnold Schwaighofer
a72b685927 Merge remote-tracking branch 'origin/master' into master-next 2017-06-30 12:21:33 -07:00
swift-ci
3e31e8c2cd Merge pull request #10721 from CodaFi/parampa-tha-rappa 2017-06-30 10:50:08 -07:00
Robert Widmann
4411223156 [NFC] Switch some more of the frontend to params 2017-06-30 10:24:52 -07:00
swift-ci
5707eaf699 Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 20:09:34 -07:00
Robert Widmann
679584d8d8 Merge pull request #10695 from CodaFi/all-specd-out
[NFC] Use a meaningful representation of parameter specifiers
2017-06-29 20:00:14 -07:00
swift-ci
fe5e31012d Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 18:08:56 -07:00
Robert Widmann
ac5594dabe Use a meaningful representation of parameter specifiers
In anticipation of future attributes, and perhaps the ability to
declare lvalues with specifiers other than 'let' and 'var', expand
the "isLet" bit into a more general "specifier" field.
2017-06-29 16:03:49 -07:00
Jordan Rose
a8bc132565 [ClangImporter] Make conformance loading lazier.
Previously, the importer queued up conformances to complete once it
was done importing the current batch of declarations. However, if
there was a serialized Swift module that extended an imported type to
add a conformance in exactly the wrong way, the importer could end up
asking for that conformance later---even before the reference to the
imported type was resolved. This led to a crash in the deserializer
"while reading conformance for type X".

Instead of this "pending actions" queue, we can just use the
mechanisms already in place for lazily loading conformances. That way
they'll get filled out on demand, which is better all around anyway.
This does mean putting the requirement signature into the "lazy" part
of the conformance, though.

This does as a side effect mean that /all/ of the witnesses for the
imported conformance may be opaque---that is, they will never be
devirtualized to a particular implementation. However, they previously
would have referred to methods implemented in Objective-C anyway,
which are always dispatched with objc_msgSend. So this should have no
practical effect.

rdar://problem/32346184
2017-06-29 15:50:09 -07:00
swift-ci
b28a1093da Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 15:09:18 -07:00
Doug Gregor
623d72db3c [AST] Make the "requirement signature" of a protocol a flat array.
Rather than pretend that the requirement signature of a protocol is a
full, well-formed generic signature that one can meaningfully query,
treat it as a flat set of requirements. Nearly all clients already did
this, but make it official. NFC
2017-06-29 14:01:49 -07:00
Doug Gregor
75f3c99382 [Clang importer] Compute requirement signature before setting environment.
Match what the type checker is doing.
2017-06-29 14:01:49 -07:00
Greg Parker
7b009eccde Merge remote-tracking branch 'origin/master' into master-next 2017-06-28 15:25:17 -07:00
Doug Gregor
6a26f5f044 [Clang importer/module printing] Correctly print NS_ERROR_ENUMs.
Ever since we stopped associating the top-level struct of an imported
NS_ERROR_ENUM with the Clang enum declaration, we've been unable to
print imported NS_ERROR_ENUMs. The module-printing infrastructure
would drop them thinking they aren't imported declarations.

This also affected NS_ERROR_ENUMs that were imported as members of
another type, as well as other types imported as members.

Fixes rdar://problem/32497693.
2017-06-27 17:01:29 -07:00
Jordan Rose
701a70d257 [ClangImporter] Filter import-as-member decls by preferred submodule. (#10612)
That is, if a member is redeclarable, use the module of the definition
if possible, and the canonical declaration otherwise. This is
consistent with what we do when we actually import the declaration.
Without this, we can end up dropping declarations.

rdar://problem/32816381
2017-06-27 09:00:47 -07:00
Doug Gregor
f855d2f87e [Clang importer] Infer @_downgrade_exhaustivity_check for new-to-2017 enum elements in Swift 3.
In Swift 3 mode, infer @_downgrade_exhaustivity_check for any enum
elements that were introduced in the 2017 SDKs (macOS 10.13, iOS 11.0,
tvOS 11.0, watchOS 4.0). This is a stop-gap until we get "open" enums,
but serves an important source-compatibility use case.

Fixes rdar://problem/32824207.
2017-06-26 13:13:50 -07:00
Michael Ilseman
db70b76a88 Merge pull request #10254 from milseman/new_type_old_abi
[ClangImporter] Fix indirection mismatch surrounding swift_newtype
2017-06-23 06:15:30 -07:00
Pavel Yaskevich
42246cae8a [ClangImporter] Fix importType to return interface types for generic parameters
`ClangImporter`'s `importType` should always return interface types
for everything it imports, which helps to avoid tracking of declaration
contexts and remapping returned types in/out of them.

Resolves: rdar://problem/32298667
2017-06-22 16:38:09 -07:00
Michael Ilseman
c7d9404e4a [Clang Importer] Account for indirection when importing swift_newtypes
Previously, we did not properly handle levels of indirection for
swift_newtype-ed typedefs of pointer types. We imported them in a way
that tried to present the value semantics of the pointee rather than
of the pointer. We then tried (sometimes incorrectly) to detect and
fix this up during SILGen.

Instead, model with the value semantics of the pointer itself. SILGen
can then be simplified to just pass swift_newtypes the same as any
other struct: directly for non-mutating and indirectly for mutating
(i.e. inout self). Tests added.
2017-06-22 13:14:55 -07:00
swift-ci
08a536f2d4 Merge remote-tracking branch 'origin/master' into master-next 2017-06-13 18:48:41 -07:00
Huon Wilson
b60aef8536 [ClangImporter] Correct curried method types for SE-110.
Method types are now required to be `(Self) -> (Args...) -> Return`, not
`Self -> (Args...) -> Return`.

See also https://github.com/apple/swift/pull/9454 .

Fixes rdar://problem/32588152 .
2017-06-13 17:53:21 -07:00
swift-ci
40337d7d98 Merge remote-tracking branch 'origin/master' into master-next 2017-05-31 09:28:34 -07:00
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