Commit Graph

431 Commits

Author SHA1 Message Date
Chris Hanson
91069e1647 Get XCTAssertEqual working with [T] and [T:U]
XCTest's equality assertions need overrides in order to work with Array<T> and
Dictionary<T,U>.

Addresses <rdar://problem/17257148>.

Swift SVN r20993
2014-08-04 02:10:03 +00:00
Dmitri Hrybenko
56473c34cd stdlib: change out-of-bounds subscripting traps on mirrors to be
_preconditionFailure()s.  Some of these checks are clearly redundant (for
example, the check of array subscript), but since we have no tests for
these traps (and reflection is not fast in general), I prefer to keep this
transformation as straightforward as possible.


Swift SVN r20971
2014-08-03 18:42:53 +00:00
Dmitri Hrybenko
5746e4e9ca stdlib: rename _fatalError to _sanityCheckFailure. Name similarity between
fatalError and _fatalError has caused some damage already, as some
memory-safety checks in Mirrors are _fatalErrors.


Swift SVN r20969
2014-08-03 15:20:37 +00:00
Doug Gregor
c593d49b08 Rework the _ObjectiveCBridgeable to use inout parameters rather than returns.
The _forceBridgeFromObjectiveC and _conditionallyBridgeFromObjectiveC
requirements of the _ObjectiveCBridgeable protocol previously returned
Self and Self?, respectively, where 'Self' is the value type that is
bridged. This use of returns is fairly hostile to the idea of calling
the witnesses for these requirements from the C++ part of the runtime,
leading to "interesting" tricks with OpaqueExistentialContainer that
made it hard to use these witnesses within the dynamic casting
infrastructure.

Replace the returns with inout Self? parameters, which are far easier
to deal with in the C++ part of the runtime. Despite the churn because
we're changing the _ObjectiveCBridgeable protocol, this is NFC.

Swift SVN r20934
2014-08-02 01:03:41 +00:00
Chris Hanson
63a37b29a5 XCTest assertions will eventually EXC_BAD_ACCESS
The SPI that XCTest exposes to the overlay has Objective-C semantics,
while anything exposed to Swift code via @asmname needs Swift semantics.

Add a bridge to the overlay that handles this adaptation.

Addresses <rdar://problem/17408423>.

Swift SVN r20932
2014-08-02 00:17:28 +00:00
Chris Hanson
666e4ee2f3 Further work on handling exceptions in XCTest
Rather than use a header file and -import-objc-header, use @asmname and
@objc_block to tell the overlay about the Objective-C function used to
capture exceptions.

Further addresses <rdar://problem/16453199>.

Swift SVN r20929
2014-08-01 23:36:48 +00:00
Dave Abrahams
bcc7bd3560 [stdlib] Construct String from NSString, publicly!
Yes, we do need a straightforward way to do this.

Swift SVN r20897
2014-08-01 17:27:28 +00:00
Chris Hanson
76631d14bd Catch exceptions thrown during assertions.
Since Swift itself has no exception support, use an Objective-C helper function
to evaluate a block and return an NSDictionary indicating whether an exception
was thrown out of that block (and if so, which exception).

Addresses <rdar://problem/16453199>.

Swift SVN r20880
2014-08-01 02:45:39 +00:00
Jordan Rose
a627411b43 [ClangImporter] Imported NS_OPTIONS structs should not conform to BooleanType.
In general, RawOptionSetType no longer inherits from BooleanType.

Swift SVN r20846
2014-07-31 19:23:08 +00:00
Dave Abrahams
104da6740b [stdlib] Make && and || generic
...instead of using Existentials, which don't specialize well.

Swift SVN r20837
2014-07-31 18:22:56 +00:00
Greg Parker
1167c1722d Fix XCTest build.
Swift SVN r20813
2014-07-31 05:37:24 +00:00
Chris Hanson
867429b0f4 Make XCTAssertEqualWithAccuracy work with CGFloat
Now that CGFloat is a peer of Float and Double, we need to add appropriate handling
to it for XCTAssertEqualWithAccuracy.

Addresses <rdar://problem/17762421>.

Swift SVN r20800
2014-07-31 01:36:32 +00:00
Dmitri Hrybenko
cbdefd719b Unbreak iOS builds: there is no NSRectEdge on iOS
Swift SVN r20755
2014-07-30 13:08:11 +00:00
Dmitri Hrybenko
fc05064131 Foundation overlay: introduce correctly-typed NS{Min,Max}{X,Y}Edge constants
that correspond to macros in the SDK

... and revert the previous attempt at fixing this, r20269.

rdar://16593744


Swift SVN r20752
2014-07-30 11:33:25 +00:00
Dmitri Hrybenko
ac0d9b8175 stdlib/CGFloat: GYB'ify initializers that convert between CGFloat and
integer types.  Never miss an integer type again.

rdar://17853313

Swift SVN r20751
2014-07-30 11:24:11 +00:00
Dave Abrahams
6e7f83fe98 Internalize old array casting entry-points
The core compiler now uses just two entry points for array casting

Swift SVN r20725
2014-07-29 23:56:51 +00:00
Joe Pamer
1fec0afbd0 Disallow value-to-optional conversions between argument and parameter types when resolving overloads for operators applied to nil literal operands.
This is a targeted fix to address rdar://problem/16848110 ("Disallow non-optionals to be compared to nil") and its associated dupes.

Swift SVN r20716
2014-07-29 23:24:36 +00:00
Dave Abrahams
ebcaab1e52 [stdlib/core] add Array init from _CocoaArrayType
Swift SVN r20698
2014-07-29 21:41:09 +00:00
Dave Abrahams
0320ef85ab [stdlib] Consolidate array casting entry points
Swift SVN r20689
2014-07-29 20:54:24 +00:00
Dave Abrahams
c91e0f98a0 [stdlib] bugfix: Copy bridged NSMutableArray's
When NSArrays are bridged into Array<T>, they weren't being .copy()'d.
As a result, changes to an NSMutableArray (cast to NSArray), could cause
"unrelated" Swift Arrays to mutate.  Found by inspection while
bottlenecking unsafeBitCast's in Array implementation, which also
happens in this commit.

Swift SVN r20678
2014-07-29 17:59:41 +00:00
Dmitri Hrybenko
3e32ff188f stdlib/String: change String.stringByAbbreviatingWithTildeInPath into a
property, to match recent Foundation headers


Swift SVN r20674
2014-07-29 16:08:39 +00:00
Dave Abrahams
9a13a7148b [stdlib] Consolidate bridging protocols
Squash _[Conditionally]BridgedToObjectiveC into one protocol.  This
change results in simpler bridging code with fewer dynamic protocol
conformance checks, and solves the nasty naming/semantics problem that
resulted from having _ConditionallyBridgedToObjectiveC refining
_BridgedToObjectiveC.

Also, rename things so they're more symmetrical and less confusing.

Swift SVN r20664
2014-07-29 01:30:27 +00:00
Joe Pamer
f55c751958 Add a fixit for optional-typed expressions used in conditional expression positions.
Swift SVN r20639
2014-07-28 19:20:42 +00:00
Joe Pamer
94dac129d4 Remove the BooleanType conformance from optional types (rdar://problem/17110911)
To limit user confusion when using conditional expressions of type Bool?, we've decided to remove the BooleanType (aka "LogicValue") conformance from optional types. (If users would like to use an expression of type Bool? as a conditional, they'll need to check against nil.)

Note: This change effectively regresses the "case is" pattern over types, since it currently demands a BooleanType conformance. I've filed rdar://problem/17791533 to track reinstating it if necessary.

Swift SVN r20637
2014-07-28 19:20:39 +00:00
Doug Gregor
bd75425b0e Remove the notion of non-inheritable conformances entirely <rdar://problem/16880016>.
Swift SVN r20627
2014-07-28 16:29:05 +00:00
Doug Gregor
3cb58e833a Restrict non-final class protocol conformance when Self is part of the requirement signature.
When a non-final class satisfies a method requirement that returns
Self, it must do so with a method that also returns (dynamic)
Self. This ensures conformance will be inheritable, closing off an
awful type-safety hole <rdar://problem/16880016>. Other
non-contravariant uses of Self in the signatures of requirements cause
the protocol to be unusable by non-final classes.

I had to leave a tiny little gaping hole for the ~> operator, whose
removal is covered by <rdar://problem/17828741>. We can possibly put
this on firm footing with clever handling of generic witnesses, but
it's not important right now.



Swift SVN r20626
2014-07-28 16:15:16 +00:00
Dmitri Hrybenko
ca07053adc stdlib: rename fatalError() to debugTrap()
Part of rdar://17792445


Swift SVN r20619
2014-07-28 11:14:52 +00:00
Dmitri Hrybenko
729266205d stdlib: mark Float.value as private
Swift SVN r20590
2014-07-26 19:48:03 +00:00
Dmitri Hrybenko
ed855afb68 stdlib/String: use the Unicode collation algorithm in String's and Character's conformance to Comparable
rdar://17498444


Swift SVN r20554
2014-07-25 18:32:36 +00:00
Doug Gregor
681059a089 Make CGFloat conform to Strideable but not RandomAccessIndex.
This brings CGFloat into line with changes recently made to the other
floating-point types. <rdar://problem/17758020>

Swift SVN r20548
2014-07-25 17:17:18 +00:00
Doug Gregor
505674484b Allow construction of CGFloat from the sized Int/UInt types and vice-versa.
Fixes <rdar://problem/17670817> (+ dupes).
Notably, we were also missing a UInt(CGFloat) initializer, which

Swift SVN r20547
2014-07-25 16:56:47 +00:00
Dmitri Hrybenko
aa929798d0 stdlib: eliminate an inconsistent overload of == on NSString that would
make == and != inconsistent in non-generic code, and that would not be
used at all in generic code.

Part of rdar://17498444

Swift SVN r20524
2014-07-24 22:38:41 +00:00
Doug Gregor
d3012a0c26 Replace an 'override' with a 'required' for init(coder:).
Swift SVN r20496
2014-07-24 17:01:03 +00:00
Doug Gregor
5fc8ac7fd1 Require the 'override' keyword for initializers that override designated initializers.
Swift SVN r20490
2014-07-24 15:38:33 +00:00
Dave Abrahams
d00e888d95 [stdlib] Rename reinterpretCast => unsafeBitCast
Also give unsafeBitCast an explicit type parameter.  So

  let x: T = reinterpretCast(y)

becomes

  let x = unsafeBitCast(y, T.self)

Swift SVN r20487
2014-07-24 13:17:36 +00:00
Dmitri Hrybenko
89420772a2 stdlib/String: move enough bridging machinery into the core standard
library so that core library can bridge a String to Objective-C

Part of rdar://17498444

Swift SVN r20485
2014-07-24 13:07:12 +00:00
Dave Abrahams
1a7648b04b [stdlib] String.stringWithBytes: drop length param
The length could already be given by the input sequence.  Also, make it
accept any generic Sequence of bytes, rather than requiring an array.

Fixes <rdar://problem/17034413>

Swift SVN r20480
2014-07-24 08:23:10 +00:00
Doug Gregor
b1b6886fda Add missing required initializers to _NSContiguousString and _NSOpaqueString.
Swift SVN r20449
2014-07-23 23:47:02 +00:00
Dave Abrahams
a3211d0d68 [stdlib] dynamic NSString.localizedStringWithFormat
It used to always construct an NSString; now it constructs the class it
was called through

Swift SVN r20439
2014-07-23 22:59:27 +00:00
Dmitri Hrybenko
766c9816de stdlib: underscore-prefix String.core
Swift SVN r20411
2014-07-23 16:28:57 +00:00
Doug Gregor
c2b5703865 API notes: rework CMake support so that we can separate the API notes sources.
Move all of the information about API notes into the "apinotes"
subdirectory, which specifies the API notes that it provides. The
organization is such that "apinotes" can become its own separate
repository, and the compiler build will pick up those API notes that
are available and build them along with the overlays.

Swift SVN r20406
2014-07-23 16:09:49 +00:00
Dmitri Hrybenko
d168ad3d13 stdlib: don't use Builtin types in public APIs, this is quite pointless
Swift SVN r20392
2014-07-23 13:05:37 +00:00
Dave Abrahams
00f9ca5eda [stdlib] Rename [_]elementStorage=>[_]baseAddress
Swift SVN r20342
2014-07-22 22:29:03 +00:00
Dave Abrahams
1438d617cd [stdlib] Rename ConstUnsafePointer=>UnsafePointer
Swift SVN r20318
2014-07-22 17:10:54 +00:00
Dave Abrahams
21669b3aee [stdlib] Add "Mutable" to [Autoreleasing]UnsafePointer
UnsafePointer becomes UnsafeMutablePointer
AutoreleasingUnsafePointer becomes AutoreleasingUnsafeMutablePointer

Swift SVN r20316
2014-07-22 16:56:23 +00:00
Dmitri Hrybenko
d14f17beef Change 'getLogicValue()' into a property 'boolValue'; change
'getArrayBoundValue()' into a property 'arrayBoundValue'.

rdar://17156123


Swift SVN r20304
2014-07-22 12:08:10 +00:00
Dave Abrahams
2c3ab47cf2 [stdlib] O(1) Array<non-verbatim> round-tripping
Arrays of non-verbatim-bridged types (such as Int, and today's String)
are converted to Objective-C lazily, with the objects created due to
element conversion being autoreleased when necessary.

Fixes <rdar://problem/17360154>

Note: test/SIL/Parser/array_roundtrip.swift was XFAIL'd;
see <rdar://problem/17758203>

Swift SVN r20293
2014-07-22 04:42:47 +00:00
Enrico Granata
c06a072270 After investigating, there is no actual reason why the SpriteKit mirrors had to be disabled on iOS. So, just do the right thing. One change, of course, is to use UIImage on-device instead of NSImage. Both can be built from an NSData, and according to purplefish, the NSData we get back is of the correct image format to be reconstructed on either platform. Fixes rdar://17593122
Swift SVN r20289
2014-07-22 01:37:01 +00:00
Joe Groff
436acb00f3 Foundation: Remove the prepareWithInvocationTarget overlay.
Giving the invocation target proxy a type will be bogus when we turn on 'dynamic'. This breaks the NSUndoManager tests because we still can't work with lvalues through AnyObject. <rdar://problem/17755906>

Swift SVN r20283
2014-07-22 00:23:34 +00:00
Fariborz Jahanian
5197fe0f9d Move noErr to Darwin with OSStatus as its type.
rdar://17285288


Swift SVN r20279
2014-07-21 21:14:27 +00:00