This required a few changes in places where we synthesize functions to
make sure these properties hold. That's good because we don't know where
we might already be depending on them. (On the other hand, we could also
decide not to care about TuplePattern labels, in which case I wonder if
we could eventually discard them altogether in functions.)
Still untested: that the function type is also in sync.
This is functional for arbitrary Objective-C properties and methods
(the subject of rdar://problem/22214302), as well as for changing the
argument labels of C functions. However, it does not work when the
name of a global is changed because name lookup initiated from
Swift goes through the Swift lookup table. Fixes
rdar://problem/22214302 but is only a step toward
rdar://problem/17184411.
Swift SVN r32670
This is all effectively NFC, but lays out the shape of the iterative
type checker: requests are packaged up in TypeCheckRequest, we can
check whether the request has been satisfied already (isSatisfied),
enumerate its dependencies (enumerateDependenciesOf) in terms of other
TypeCheckRequests, and satisfy a request (satisfy).
Lazily-computed semantic information is captured directly in the
AST, but has been set aside in its own structure to allow us to
experiment with moving it into a lookaside table.
The only request that exists now is to type-check the superclass of
the given class. It currently performs unhealthy recursion into the
existing type checker. As we detangle dependencies, this recursion
between the IterativeTypeChecker and the TypeChecker can go away.
Swift SVN r32558
...or rather, typealiases of AnyObject. They should be typealiases of
CFTypeRef. (The problem is that everywhere else CFFooRef becomes a typealias
for CFFoo, but we don't do the same with 'CFType'.)
Fixes a PrintAsObjC problem where we'd try to mark such typealiases as
'strong' if they show up in the generated ObjC header.
rdar://problem/22827172
Swift SVN r32230
Instead, when mapping a Clang type to its name for omission purposes,
map CF types to their appropriate names. This more directly mirrors
what will happen on the Swift side, but is otherwise NFC.
Swift SVN r32140
This covers this case:
struct foo {
struct {
int x;
int y;
} bar;
union {
void *ptr;
float num;
} baz;
};
Based on the original patch by Graham Batty.
Progress on <rdar://problem/21683348> -- anonymous unnamed unions
are still not supported (struct foo { union { int x, y }; };).
Swift SVN r31924
Bitfields are imported as computed properties with Clang-generated
accessors.
While we cannot represent them directly in SIL, we can still
synthesize a memberwise initializer, so also decouple that notion
from "has unreferenceable storage".
Fixes <rdar://problem/21702107>.
Swift SVN r31779
- Extract makeFieldGetterDecl() and makeFieldSetterDecl()
- Remove makeUnionConstructorDecl(), the ordinary struct constructor logic
works just fine
Swift SVN r31709
Some GCD APIs rely on the pointer identity of blocks, so avoid bridging
when possible. The easiest way to do this was to use our existing rules
for special-casing typedefs.
The summary text for dispatch_block_t comes from the actual GCD headers.
rdar://problem/22432170
Swift SVN r31634
We were memcopying a std::function into the the AST context memory,
which leaks memory incidentally used by the std::function
implementation. Fix by using a std::unique_ptr and registering a
destructor cleanup. Incidentally, I turned the array of functions into
a single function, since we never have more than one anyway.
rdar://problem/22387897
Swift SVN r31600
marker isn't actually setting the implicit bit, it was setting the "trailing
closure" bit, for something that isn't of function type. The effect of this
was to cause sema to eat the rawValue: parameter without requiring the label.
Instead of generating this code that happened to work out most of the time,
build the proper TupleExpr with the right parameter label. NFC.
Swift SVN r31597
This provides the == operator as well as ~=, which allows for
less encumbered pattern matching for these imported types.
rdar://problem/17287720
Swift SVN r31469
Create getters and setters for, and initializers taking, fields in
C unions. This doesn't yet fold anonymous unions' fields nested into
a struct, but it does open up APIs that were previously unavailable.
rdar://problem/19660119
Swift SVN r31396
Now that we have the inheritance lists hanging around, use them: it
makes the conformance lookup table use the same code whether we're
deserializing the conformances or parsing them.
Swift SVN r31383
The conformance lookup table is responsible for answering queries
about the protocols to which a particular nominal type conforms, so
stop storing (redundant and incorrect) protocol lists on the ASTs for
nominal types. Protocol types still store the list of protocols that
they inherit, however.
As a drive-by, stop lying about the number of bits that ProtocolDecl
uses on top of NominalTypeDecl, and move the overflow bits down into
ProtocolDecl itself so we don't bloat Decl unnecessarily.
Swift SVN r31381
This provides better AST fidelity through module files and further
reduces our dependencies on storing a list of protocols on nominal
type declarations.
Swift SVN r31345
This improves the fidelity of the AST printed from a loaded module, as
well as consistency in the AST. Also teach the Clang importer to add
"inherited" clauses, providing better fidelity for the mapping from
Objective-C to Swift.
With trivial update to SDKAnalyzer test.
Swift SVN r31344
This improves the fidelity of the AST printed from a loaded module, as
well as consistency in the AST. Also teach the Clang importer to add
"inherited" clauses, providing better fidelity for the mapping from
Objective-C to Swift.
Swift SVN r31337
This way they can be used from other projects, like LLDB. The downside
is we now have to make sure the header is included consistently in all
the places we care about, but I think in practice that won't be a problem,
especially not with tests.
rdar://problem/22240127
Swift SVN r31173
Update the importer and name lookup to prefer a factory initializer that is more available
over a convenience initializer that is less available even though we generally prefer
convenience initializers over convenience factory initializers. The motivation for this
change is CIColor, which has added a new convenience initializer:
- (instancetype)initWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b NS_AVAILABLE(10_11, 9_0);
but already has existing convenience factory initializer:
+ (instancetype)colorWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b;
Without this change we prefer -initWithRed:green:blue, so instantiating CIColor with:
let colorChannelValue: CGFloat = …
let ciColor = CIColor(red: colorChannelValue, green: colorChannelValue, blue: colorChannelValue)
results in an availability error even though there is a perfectly available convenience
factory initializer. With this change, we choose the convenience factory initializer
when importing, so there is no availability error.
rdar://problem/20617581
Swift SVN r30946
The old code predates NumberLiteralExpr having a "negative" field.
Fixing this avoids creating a temporary signed integer with a value of
INT_MAX+1 when trying to compute INT_MIN.
rdar://problem/21680700
Swift SVN r30814
Block types can't be used in structs (because they're managed by ARC),
are rarely referred to by pointers, and would pretty much never be
globals. Additionally, their syntax is complicated enough that people
tend to make typedefs for them fairly frequently. We'd like to preserve
that sugar, but we don't really need to preserve the representation
when the most likely use of the block is in a bridged context (e.g. a
method parameter). In the rare case where the representation /is/
important, fall back to re-importing the underlying type.
rdar://problem/22013912
Swift SVN r30738
This changes the behavior to match NominalTypeDecls, which don't have a type
until everything is set up either. In a few places we construct TypeAliasDecls
from known types directly, and we have to call computeType().
Fixes <rdar://problem/19534837>.
Swift SVN r30386
Otherwise, people subclassing NSView will accidentally call NSView.print
when they're trying to call Swift.print.
rdar://problem/18309853
Swift SVN r30334
When adding mirror declaration members to a class, if the protocol has an annotated
availability then apply that availability to the mirror declaration member unless the
protocol member already has its own availability.
rdar://problem/21825141
Swift SVN r30251
The importer conjures up "mirrored" member declarations for imported
Obj-C classes that conform to a protocol with members that aren't exposed
in public headers. This commit extends our existing inference of availability
for members of unannotated Obj-C protocols to cover mirrored declarations
as well. For these mirrored declarations, we additionally constrain the
inferred availability with the availability of the class itself.
Swift SVN r30244
Based on feedback from Jordan, update r30060 to synthesize availability
attributes on unannotated Obj-C protocols in the importer. This has a
user-visible effect: calls to protocol requirements with these synthesized
attributes will now cause an availability error if the requirement is not
available in the calling type refinement context.
Swift SVN r30096
These are contexts where we have enough information to bridge /back/
properly; that is, where we can distinguish CBool, ObjCBool, and
DarwinBoolean. In cases where we can't, we keep the three separate;
only CBool is really the same type as Bool.
This also affects current import behavior for ObjCBool, which was previously
incorrectly conflated with CBool in certain cases.
More rdar://problem/19013551
Swift SVN r30051
Per discussion, there are certain times where our APIs really want you to use
the performSelector family of methods (e.g. when the framework hands you a selector
and expects you to call it upon completion).
Although the methods still aren't type-safe, we are at least making the result
Unmanaged so that you're forced to think about whether it's +1 or +0 before you
use it, and so that the compiler doesn't accidentally try to retain a non-object
pointer.
This commit also removes the blocks on the makeObjectsPerformSelector... methods,
but Foundation plans to add NS_SWIFT_UNAVAILABLE there (see rdar://problem/21150180).
rdar://problem/21150277
Swift SVN r30044
If there is a method -foo: that's unavailable (for whatever reason), and we now
have a method -foo:error: that we'd like to import, it's okay to drop the error
parameter there. Overload resolution can handle filtering out the unavailable
method.
rdar://problem/21497221
Swift SVN r29746
This is the counterpart of the previous commit---if a class or protocol
is renamed with @objc, we should not be looking for it in Swift under
its Objective-C name.
Finishes rdar://problem/17469485
Swift SVN r29744
If the common prefix of the enum /elements/ had an underscore in the /middle/,
we previously had cases where we'd end up leaving that underscore in place.
rdar://problem/20800204
Swift SVN r29673
We wouldn't care except that its constants are named TRUE and FALSE and
that shows up in the global namespace.
rdar://problem/20943410
Swift SVN r29651