Commit Graph

719 Commits

Author SHA1 Message Date
Ted Kremenek
6f2d4d2859 Add runtime tests to test Equatable, Hashable, Comparable, for a few core types.
Finishes up <rdar://problem/14789786>.

Swift SVN r16257
2014-04-12 16:38:42 +00:00
Ted Kremenek
11ed94d44d Provide a Swift-variant of NSLocalizedString in the Foundation overlay.
The Swift variant uses a function with default arguments.  In
Objective-C NSBundle.h defines a set of macros that simulate default
arguments.

Implements <rdar://problem/15787627>.

Swift SVN r16226
2014-04-11 20:18:18 +00:00
Doug Gregor
c2f0f26ed5 Make Int, Double, and String bridge to Objective-C.
Make these three types conform to the BridgedToObjectiveC
protocol, which is needed for array bridging. This is one part of
<rdar://problem/16533359>.

Because this must happen in the Foundation module, hack
swift_conformsToProtocol to look in the Foundation module for
conformances when it can't find them in the module corresponding to
the type. This is an egregious hack to an egregious hack, but it gets
us closer.


Swift SVN r15997
2014-04-06 04:29:55 +00:00
Joe Groff
f1ee8cf0e1 Add a runtime test that uses C pointer parameters.
Swift SVN r15894
2014-04-03 20:48:04 +00:00
Doug Gregor
aee0cb15cf Add a runtime test for Objective-C class namespacing.
Swift SVN r15589
2014-03-28 23:16:04 +00:00
Joe Groff
d00be8020f Add interpreter test for block calls.
Swift SVN r13942
2014-02-15 17:00:49 +00:00
Jordan Rose
81e13fb60d When autolinking in immediate mode, make sure we're checking private imports...
...since all imports are private by default, and we rely on "import Cocoa"
bringing in AppKit. (If you say "import AppKit" directly, you get an
immediate call to IRGenImportedModules, so everything works.)

Swift SVN r12617
2014-01-20 23:25:05 +00:00
Joe Groff
5e1c0fa65c Remove test/Interpreter/SDK/objc_blocks.swift.
It relies on block shimming infrastructure that's in the process of being disrupted by the NewString transition and that should be superseded in the long term by proper compiler support for blocks.

Swift SVN r11829
2014-01-02 19:38:53 +00:00
Jordan Rose
54b9f8c026 ClangImporter: Make sure Foundation is available when bridging NSString.
If Foundation wasn't ever actually loaded into the ASTContext, type
lowering would fail to find the NSString-to-String conversion functions.
Fix this by only bridging NSString when a module named "Foundation" can
be loaded.

This still isn't very precise, since the bridging functions could still
be missing, but it at least avoids a user-triggerable error.

<rdar://problem/15027448>

Swift SVN r9380
2013-10-15 22:01:04 +00:00
Greg Parker
ec31b01246 Remove incorrect optimization of dynamic casts of non-ObjC objects.
Swift SVN r8907
2013-10-04 04:17:26 +00:00
Doug Gregor
c4a065abce Teach dynamic lookup to find subscript operators.
The name used for name lookup of subscript operators is "__subscript",
but when looking into an Objective-C module we instead need to look
for methods with the subscripting selectors, e.g.,
objectAtIndexedSubscript:/objectForKeyedSubscript:. Do so, and make
sure that deserializing the method first still creates the subscript
declaration.

Fixes the majority of <rdar://problem/14656624>. We can subscript 'id' now.



Swift SVN r8700
2013-09-26 21:42:45 +00:00
Jordan Rose
2ebd4756b6 [ClangImporter] Force load adapter modules whenever a Clang module is named.
Loading Cocoa (Clang) triggers the loading of several other modules,
including Foundation (Clang). We want to make sure we bring in the adapter
module Foundation (Swift), so loading Cocoa currently triggers a walk of
all imported modules to check for an adapter. The problem is that
Foundation (Swift) contains some eagerly-deserialized decls, which refer
to decls in Foundation (Clang). These decls were not importing correctly
because we hadn't finished loading all the adapters -- specifically, we
hadn't yet loaded ObjectiveC (Swift). This meant SEL was loaded as
swift.COpaquePointer instead of ObjectiveC.ObjCSel.

Now, when Foundation (Swift) asks to load Foundation (Clang), we'll walk
all imported modules under Foundation (Clang) to check for an adapter
before returning, even if Foundation (Clang) is already in our system.
This probably still isn't the best way to deal with this (particularly
since the modules in the subtree will get visited twice), but it ensures
that we've loaded all necessary adapter modules before trying to import
any decls.

TLDR: Importing Cocoa now correctly imports the Swift overlay for the
ObjectiveC module, meaning SELs are correctly imported.

<rdar://problem/14759044>

Swift SVN r7293
2013-08-16 21:56:00 +00:00
Jordan Rose
3b35451bbe Add a test for auto-casting 'nil'.
Swift SVN r6137
2013-07-10 23:26:10 +00:00
Joe Groff
814ccd6952 Add Interpreter test using NSString bridging.
Test that string bridging interacts successfully both with native ObjC NSString methods and with Swift subclasses that define String methods end-to-end.

Swift SVN r5367
2013-05-29 00:24:13 +00:00
Joe Groff
7406986487 SILGen: Class constructors need to return modified self.
-[NSMutableArray init] modifies self, causing NSStringDemo to fail when sil-irgenned because SILGen didn't handle constructors changing 'this' correctly.

Swift SVN r4728
2013-04-13 19:21:10 +00:00
Joe Groff
aee590a4b0 IRGen: Enable C function calls from SIL.
Preserve the AbstractCC of a function symbol when emitting a SIL ConstantRefInst by adding a new StaticFunction variant to LoweredValue. This lets us avoid a bunch of bitcasting noise for static functions that aren't used as values, and will lets us emit C-to-Swift-ABI thunks on demand when C functions are used as values.

Swift SVN r4543
2013-03-29 19:47:46 +00:00
Doug Gregor
ddc2b113c9 Check for declaration overrides within extensions as well as within classes.
A Swift method in an extension cannot override a method nor can it be
overridden by a method. Diagnose this. We may remove this limitation
at a later time.

An [objc] method in an extension can override and can be overridden, so
specifically allow this case. It's useful in our Foundation bindings.



Swift SVN r4308
2013-03-06 19:56:56 +00:00
Joe Groff
3f83f18913 Add Interpreter/SDK test blocked on 13319547.
Swift SVN r4245
2013-03-01 00:16:31 +00:00
Joe Groff
a7d1d7e252 Add SDK-dependent Interpreter tests.
In the lit.site.cfg, if a MODULES_SDK is available, add a '%sdk' substitution and enable REQUIRES: sdk tests. Add some tests under test/Interpreter/SDK to test some basic ObjC interop features.

Swift SVN r4243
2013-02-28 23:44:41 +00:00