Commit Graph

794 Commits

Author SHA1 Message Date
Jordan Rose
bfa7566aec [ClangImporter] Put implicit properties into the list of all class members.
This allows "obj.description!" to work on iOS when 'obj' is an AnyObject,
even though 'description' is an implicit property created by the importer.

Swift SVN r18149
2014-05-16 00:30:55 +00:00
Doug Gregor
01f3f7777e Make _convertNSArrayToArray work for non-verbatim bridged types.
The runtime diagnostics here are awful, but the monkey dances
<rdar://problem/16899681>.



Swift SVN r18121
2014-05-15 19:25:58 +00:00
Doug Gregor
87904b8228 Make ImplicitlyUnwrappedOptional conform to _ConditionallyBridgedToObjectiveC.
This is a better solution to <rdar://problem/16899681> because the
runtime magic is limited to implementing the witnesses of this
conformance.

The type checker fixes are because we can end up using unchecked
optionals in more places, via bridging, than we could before.


Swift SVN r18120
2014-05-15 19:00:52 +00:00
Joe Pamer
a74c44a6e4 Fix two crashing bugs related to checked downcasts - rdar://problem/16093456 and rdar://problem/16892211.
Swift SVN r18118
2014-05-15 18:36:44 +00:00
Joe Groff
f1fa77e140 IRGen: Fix heap array destructor for types where size != stride.
Use TypeInfo::indexArray to get the bounds of the array instead of duplicating its logic incorrectly. Fixes <rdar://problem/16916422>.

Swift SVN r18115
2014-05-15 18:15:04 +00:00
Dmitri Hrybenko
d50a8b476d stdlib/Foundation overlay: add Printable conformance to Selector
rdar://16897592


Swift SVN r18109
2014-05-15 17:25:43 +00:00
Dmitri Hrybenko
8ee468e974 stdlib/Foundation overlay: add Printable conformance to ObjCBool
rdar://16897579


Swift SVN r18108
2014-05-15 17:02:40 +00:00
Doug Gregor
bf8fbfc32e Teach isBridgedToObjectiveC and bridgeToObjectiveC to unwrap implicitly unwrapped optionals.
This allows us to, for example, convert an array of unchecked
optionals of some bridged type T to NSArray. It's a runtime failure if
the unchecked optional contains nil.

This is most of <rdar://problem/16899681>, but I want to improve the
testing and look into the various FIXMEs.


Swift SVN r18106
2014-05-15 16:16:35 +00:00
Ted Kremenek
9eea282719 Switch range operators ".." and "...".
- 1..3 now means 1,2
- 1...3 now means 1,2,3

Implements <rdar://problem/16839891>

Swift SVN r18066
2014-05-14 07:36:00 +00:00
Fariborz Jahanian
f914b05873 Fix typo in test.
Swift SVN r18021
2014-05-13 20:28:14 +00:00
Joe Pamer
5d95457efc Disallow operator overloads that require implicit conversions for all arguments (rdar://problem/16785445)
Swift SVN r18019
2014-05-13 20:09:50 +00:00
Fariborz Jahanian
2fb6e3f8f1 Test for // rdar://16726444
Swift SVN r18017
2014-05-13 19:40:11 +00:00
Doug Gregor
d5a9c2ab94 Only supersede initializers with other imported initializers when the types match.
This fixes a case where the Swift-variadic and C-varargs versions of
various initializers were superseding each other
<rdar://problem/16801456>.

It also uncovered some more cases where we weren't getting quite the
right semantics for factory-methods-as-initializers, which are also
fixed here.

Swift SVN r18010
2014-05-13 16:49:39 +00:00
Dmitri Hrybenko
2cc8fe40d4 stdlib/printing: replace four printing systems with one new one
The old ones were:

- print/println
- printAny
- printf
- Console

The new printing story is just print/println.  Every object can be printed.
You can customize the way it is printed by adopting Printable protocol.  Full
details in comments inside stdlib/core/OutputStream.swift.

Printing is not completely finished yet.  We still have ReplPrintable, which
should be removed, string interpolation still uses String constructors, and
printing objects that don't conform to Printable will result in printing
mangled names.


Swift SVN r18001
2014-05-13 13:07:59 +00:00
Doug Gregor
73528dc0e0 Enable importing factory methods as initializers by default.
Finishes <rdar://problem/16509024>.

Swift SVN r17972
2014-05-12 23:01:20 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Joe Groff
9598880928 Forward SwiftObject's -description to use reflect(x).summary.
On the swift side, add an asmname'd "getSummary" function to make it easier for the runtime to access 'reflect(x).summary' (and to make it easy to change this when we get a real printing solution). On the C++ side, implement -description by trying to find convertStringToNSString if Foundation is loaded, and falling back to just returning @"SwiftObject" if not. It's unlikely SwiftObject's methods will be exercised if Foundation isn't loaded.

Swift SVN r17954
2014-05-12 19:54:40 +00:00
Joe Groff
4ddcc41c49 Add an interpreter test that we can witness Swift protocols with objc methods.
Swift SVN r17744
2014-05-09 00:26:30 +00:00
Fariborz Jahanian
b56392e643 Overlay for -[NSPredicate predicateWithFormat:] and
-[NSExpression expressionWithFormat:]
// rdar://16726530


Swift SVN r17186
2014-05-01 21:44:00 +00:00
Joe Groff
164870c0c3 SILGen: Reenable partial application of ObjC methods.
Make ObjC method partial applications go through a native-to-foreign thunk so that we properly handle bridging conversions in the resulting function value. Partial applications through dynamic lookup are still broken because they apparently go through a different path.

Swift SVN r17108
2014-04-30 19:57:44 +00:00
Joe Groff
01c5eeab94 Foundation overlay: Provide an "NSLog" replacement.
Use NSLogv, which we can import and call using DaveA's withVaList hacks, to implement NSLog.

Swift SVN r16664
2014-04-22 21:51:31 +00:00
Joe Groff
fbf0a1529c Add an interpreter test that uses an inner-pointer method.
Swift SVN r16636
2014-04-22 00:25:17 +00:00
Doug Gregor
82a7f1f87b Improve de-duplication logic for imported Objective-C class initializers.
Before we create a new initializer, check whether it would collide
with existing initializers. If it's better than the existing
initializer, mark the existing one as unavailable; if it's not better,
don't build it.

In support of this, we tweak a few things w.r.t. unavailble
declarations:
  - An unavailable declaration is shadowed by an available one,
  - Don't emit SIL unavailable, imported initializers

This fixes the last problem with <rdar://problem/16509024>.



Swift SVN r16611
2014-04-21 06:26:52 +00:00
John McCall
4d16346b4e Split out the autorelease test and XFAIL it on i386,
which does not support the autorelease optimization.

Swift SVN r16377
2014-04-15 21:26:17 +00:00
Joe Groff
75e5ae9e9b Sema: Type-check the conformances of imported structs.
This makes it so that we actually register the RawOptionSet conformance of imported structs and emit it into executables, fixing <rdar://problem/16295991>.

Swift SVN r16323
2014-04-14 17:33:07 +00:00
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