Commit Graph

3245 Commits

Author SHA1 Message Date
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
6a80cbbaa2 [stdlib] Capitalize the cases of Bit
Fixes <rdar://problem/17821517>

Swift SVN r20718
2014-07-29 23:25:28 +00:00
Dave Abrahams
7c7fb3eea0 Restore "[Release note] deferred array cast checks"
I had just gone too far with the laziness; everything was already
working after only one change

Swift SVN r20717
2014-07-29 23:25:27 +00:00
Dave Abrahams
0b562db701 Revert "[Release note] deferred array cast checks"
This reverts commit r20700 and r20702

I'll bring these back when I work out the problems.

Swift SVN r20708
2014-07-29 22:52:28 +00:00
Dmitri Hrybenko
8db3907d54 NSStringAPI test: allow to pass under iOS simulator
Swift SVN r20704
2014-07-29 22:07:51 +00:00
Dave Abrahams
d9dc321ccd [stdlib] Tests shouldn't use internal entry points
There's no reason not to test the actual casting syntax here.

Swift SVN r20703
2014-07-29 22:01:46 +00:00
Dave Abrahams
18b81228d5 [stdlib] Defer array bridge cast checks
Part 2 (of 2) of <rdar://problem/17340393>

Swift SVN r20700
2014-07-29 21:41:11 +00:00
Dave Abrahams
5847a0f7c3 [stdlib] defer Array element down-cast checks
Part 1 of <rdar://problem/17340393>

Swift SVN r20699
2014-07-29 21:41:10 +00:00
Dmitri Hrybenko
fca8237688 TrapTestPrototype: relax CHECK line to allow this test to pass on iOS
Swift SVN r20688
2014-07-29 20:37:32 +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
Dmitri Hrybenko
98188d1da9 NSString APIs on String: add more tests
Swift SVN r20673
2014-07-29 16:06:36 +00:00
Dmitri Hrybenko
a0c8140529 Reflection: fix a leak in TupleMirror
rdar://17840810


Swift SVN r20671
2014-07-29 15:08:48 +00:00
Dmitri Hrybenko
bdc78be4e5 Reflection: reorder dump() arguments so that one can print to a stream and take
advantage of default values

Also, fix dump() to actually print everything into the supplied stream.


Swift SVN r20670
2014-07-29 15:07:25 +00:00
Dmitri Hrybenko
35344b72c2 TrapTestPrototype: relax assertion for iOS
Swift SVN r20669
2014-07-29 13:57:41 +00:00
Dmitri Hrybenko
8c277e35e9 StdlibUnittest: add a prototype of a Swift-based driver for trapping tests
This technique is about 10x faster than using lit as the driver.


Swift SVN r20668
2014-07-29 10:26:32 +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
Dave Abrahams
5496c4beac [stdlib] Default == for Strideables
...which we can provide now that <rdar://problem/17620349> is fixed.
Thanks, JoeP!

Swift SVN r20645
2014-07-28 21:14:53 +00:00
Dave Abrahams
f467efe289 [stdlib] Un-break a test
This got missed in the big de-Bool-ification of Optionals

Swift SVN r20643
2014-07-28 20:34:09 +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
9f93d94dc6 Eliminate the ~> hack in the type checker I introduced in r20626.
We don't need to permit non-final classes and ForwardIndexTypes
<rdar://problem/17828741>.

Swift SVN r20633
2014-07-28 18:26:29 +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
f75968d9cd stdlib: add a trap() function that traps in debug and release modes
rdar://17792445


Swift SVN r20620
2014-07-28 11:30:42 +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
5e82e13234 stdlib: NSString APIs on String: more extensive tests for getCString() and
getFileSystemRepresentation()

rdar://17034216


Swift SVN r20617
2014-07-28 09:54:56 +00:00
Dmitri Hrybenko
b204bed0b8 stdlib: NSString APIs on String: add a test that shows getCString() behavior
when supplied a string with unpaired surrogates

rdar://17034216


Swift SVN r20616
2014-07-28 09:13:01 +00:00
Doug Gregor
0b802ce6e9 String: add some unavailable subscript overloads for String with integer (or integer range) indices.
The compiler's QoI for these cases is horrible, and it's a common
pitfall, so be more direct about the fact that this cannot be done.


Swift SVN r20613
2014-07-28 03:50:26 +00:00
Dave Abrahams
31d6f95452 [stdlib] UnsafeBufferPointer: add ".count"
In answering a forum post I noiced that I wanted this and it was
missing.

Also, extensive comments

Also, rename the length: init parameter to count:.  When writing the
comments for the init function it became painfully clear why we use
"count" is better than "length" especially around pointers and memory:
the former is much less easy to mistake for "length in bytes".  Plus
it's consistent with the new ".count" property

Swift SVN r20609
2014-07-28 01:03:09 +00:00
Dmitri Hrybenko
06a9ea552c stdlib/String: fix hasPrefix() and hasSuffix() to perform proper Unicode
comparison

rdar://17498444


Swift SVN r20603
2014-07-27 18:12:02 +00:00
Dmitri Hrybenko
a4c1ef90e7 stdlib/Algorithm: add an overload for startsWith that accepts a
comparison predicate

Swift SVN r20601
2014-07-27 01:00:26 +00:00
Joe Groff
61f64f3323 stdlib: Add a '??' nil-coalescing operator.
Similar to nil-coalescing operators in other languages, this operator takes an optional on the left and a non-optional expression on the right, and if the optional is nil, evaluates the right side, otherwise returning the value from the optional itself. <rdar://problem/15247356>

Swift SVN r20593
2014-07-26 19:48:50 +00:00
Dmitri Hrybenko
0b76e88fea stdlib: fix memory leak in _stdlib_NSStringNFDHashValue
rdar://17498444


Swift SVN r20589
2014-07-26 18:52:30 +00:00
Dave Abrahams
7fcc484e30 [stdlib] Construct UnicodeScalar from UInt16/UInt8
Fixes <rdar://problem/17819254>

Swift SVN r20588
2014-07-26 05:12:24 +00:00
Dave Abrahams
b81c4b2dca Revert "[stdlib] Concise operators for advance(i, +/-n)"
This reverts r20561 until we've had a chance to discuss it in a design meeting

Swift SVN r20579
2014-07-25 23:52:38 +00:00
Dave Abrahams
b2ac0e32dd [stdlib] Concise operators for advance(i, +/-n)
Fixes <rdar://problem/17814560>.

Swift SVN r20561
2014-07-25 20:53:38 +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
Dmitri Hrybenko
c44b42c7aa stdlib/String: add a test that shows that equality comparison of strings
is performed according to the deterministic Unicode collation algorithm,
which allows us to use the hash of the NFD form.

rdar://17498444

Swift SVN r20543
2014-07-25 14:31:07 +00:00
Dmitri Hrybenko
eff383932c stdlib/Character: add Hashable conformance
Swift SVN r20539
2014-07-25 10:32:00 +00:00
Dmitri Hrybenko
a38b282a7b StdlibUnittest: move checkHashable to unit testing library, it is a
utility that is useful in general

Swift SVN r20536
2014-07-25 10:06:22 +00:00
Dmitri Hrybenko
9302423c3d stdlib/Character: trap when trying to construct a Character from more
than one grapheme cluster

Swift SVN r20535
2014-07-25 10:06:18 +00:00
Dmitri Hrybenko
706934b98f stdlib/Printing: fold a small test into the existing one
Swift SVN r20528
2014-07-25 00:14:17 +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
Dave Abrahams
bd80eb7863 [stdlib] Make "required/override" checking happy
Swift SVN r20519
2014-07-24 21:48:07 +00:00
Dmitri Hrybenko
27cbb5a9d5 stdlib/String: change == to perform string comparison after NFD
normalization

There is still some obscure bug with != on NSString, probably caused by
an ill-thought overload somewhere.

Part of rdar://17498444

Swift SVN r20518
2014-07-24 21:36:01 +00:00
Dave Abrahams
e00e41af39 [stdlib] Remove String.compare()
This was added for benchmarking purposes, without the realization that
it conflicts with the NSString API we adopt when importing Foundation.
http://oleb.net/blog/2014/07/swift-strings/#comparing-strings describes
the problem.

Fixes <rdar://problem/17800504>

Swift SVN r20517
2014-07-24 21:29:48 +00:00
Dmitri Hrybenko
6193c4d4eb Fix some stdlib tests after API annotations landed
Swift SVN r20514
2014-07-24 21:12:03 +00:00
Dmitri Hrybenko
c2adafc897 Revert "stdlib/String: change == to perform string comparison after NFD"
This breaks consistency between == comparison and hash value.

Swift SVN r20500
2014-07-24 17:28:40 +00:00
Doug Gregor
64e73744bd Mark NSString's designated initializers.
Different SDKs have different beliefs on what NSString's designated
initializers are. Use API notes to smooth over the differences.


Swift SVN r20498
2014-07-24 17:16:36 +00:00
Dmitri Hrybenko
a3d5a8a0de stdlib/String: change == to perform string comparison after NFD
normalization

There is still some obscure bug with != on NSString, probably caused by
an ill-thought overload somewhere.

Part of rdar://17498444

Swift SVN r20495
2014-07-24 16:51:48 +00:00