Commit Graph

3245 Commits

Author SHA1 Message Date
Doug Gregor
cccfe7ab1f [Printing] Print tuple labels when available.
When printing a tuple via print(...), print tuple labels when they are
available. This is possible now that the runtime metadata properly
stores tuple labels. Fixes rdar://problem/23130016.
2016-09-21 09:00:22 -07:00
Joe Groff
2bfe9214ed Merge pull request #4869 from jckarter/optional-bridging
(take 2) SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel.
2016-09-20 14:35:13 -07:00
Joe Groff
1a52e3f2c2 SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel.
id-as-Any lets you pass Optional to an ObjC API that takes `nonnull id`, and also lets you bridge containers of `Optional` to `NSArray` etc. When this occurs, we can unwrap the value and bridge it so that inhabited optionals still pass into ObjC in the expected way, but we need something to represent `none` other than the `nil` pointer. Cocoa provides `NSNull` as the canonical "null for containers" object, which is the least bad of many possible answers. If we happen to have the rare nested optional `T??`, there is no precedented analog for these in Cocoa, so just generate a unique sentinel object to preserve the `nil`-ness depth so we at least don't lose information round-tripping across the ObjC-Swift bridge.

Making Optional conform to _ObjectiveCBridgeable is more or less enough to make this all work, though there are a few additional edge case things that need to be fixed up. We don't want to accept `AnyObject??` as an @objc-compatible type, so special-case Optional in `getForeignRepresentable`.

Implements SR-0140 (rdar://problem/27905315).
2016-09-20 13:04:09 -07:00
Erik Eckstein
e3840cea01 tests: exclude a test on linux rather than xfail it.
The test is not deterministic on linux and can actually pass in some cases.
2016-09-19 13:22:42 -07:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
practicalswift
3a4ee89034 [gardening] Use consistent formatting. 2016-09-17 12:12:49 +02:00
Dmitri Gribenko
0c68d0fc97 Merge pull request #4821 from apple/stdlib-test-improvements
stdlib tests: remove ObjC requirement from CollectionOfOne tests
2016-09-15 20:18:47 -07:00
Greg Parker
cd9a8afd5d Revert "SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel." (#4820) 2016-09-15 18:18:07 -07:00
Dmitri Gribenko
349c2d2d65 stdlib tests: remove ObjC requirement from CollectionOfOne tests 2016-09-15 17:06:12 -07:00
Dmitri Gribenko
9507bf19b5 Merge pull request #4810 from apple/stdlib-custom-AnyHashable-for-NSSet
Foundation: add a custom AnyHashable representation for NSSet
2016-09-15 16:16:28 -07:00
Dmitri Gribenko
f06c34398a stdlib: Improve tests for Repeated<Element> 2016-09-15 13:34:20 -07:00
Dmitri Gribenko
30c1695aeb Foundation: add a custom AnyHashable representation for NSSet 2016-09-15 13:27:36 -07:00
Joe Groff
3441fe8ca4 Merge pull request #4782 from jckarter/bridging-enhancements
SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel.
2016-09-15 13:06:01 -07:00
Dmitri Gribenko
39a3a1fb43 Eliminate boilerplate from stdlib tests 2016-09-15 10:20:09 -07:00
Dmitri Gribenko
30509f1b64 StdlibUnittest: add an argument label to checkHashable
I think it improves readability of the callsite.
2016-09-15 10:20:09 -07:00
Doug Gregor
605218d2c2 Merge pull request #4793 from DougGregor/custom-anyhashable-nsmeasurement
[Foundation overlay] Enable custom AnyHashable representation for NSMeasurement
2016-09-15 09:33:17 -07:00
Doug Gregor
8fc8a5ea3e [Foundation overlay] Minor improvements to the Measurement AnyHashable test. 2016-09-15 09:30:54 -07:00
Dmitri Gribenko
75fa0bf588 stdlib: add an ABI FIXME 2016-09-15 00:57:19 -07:00
Doug Gregor
fa4331b729 [Foundation overlay] Enable custom AnyHashable representation for NSMeasurement
Enables the overlay behavior blocked by rdar://problem/27539951.
2016-09-14 22:22:36 -07:00
Joe Groff
cfa9cd9a08 SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel.
id-as-Any lets you pass Optional to an ObjC API that takes `nonnull id`, and also lets you bridge containers of `Optional` to `NSArray` etc. When this occurs, we can unwrap the value and bridge it so that inhabited optionals still pass into ObjC in the expected way, but we need something to represent `none` other than the `nil` pointer. Cocoa provides `NSNull` as the canonical "null for containers" object, which is the least bad of many possible answers. If we happen to have the rare nested optional `T??`, there is no precedented analog for these in Cocoa, so just generate a unique sentinel object to preserve the `nil`-ness depth so we at least don't lose information round-tripping across the ObjC-Swift bridge.

Making Optional conform to _ObjectiveCBridgeable is more or less enough to make this all work, though there are a few additional edge case things that need to be fixed up. We don't want to accept `AnyObject??` as an @objc-compatible type, so special-case Optional in `getForeignRepresentable`.

Implements SR-0140 (rdar://problem/27905315).
2016-09-14 15:50:13 -07:00
Dave Abrahams
c3533f176c Adjust test to run in the Output directory
When running distributed tests, the shared volume does not support all
of the necessary operations, and writing anywhere else is poor form.
2016-09-12 19:38:48 -07:00
Dmitri Gribenko
c9041beea3 Migrate callsites from 'expectNotEmpty()' to 'expectNotNil()' 2016-09-10 20:05:43 -07:00
Dmitri Gribenko
243a35cd65 Migrate callsites from 'expectEmpty()' to 'expectNil()' 2016-09-10 20:05:42 -07:00
Joe Groff
8232d3355b Foundation overlay: Remove unnecessary precondition that array elements be ObjectiveCBridgeable.
This caused a crash when arrays were bridged from ObjC with `Any` or other non-bridged value type elements. Fixes rdar://problem/27905230.
2016-09-07 10:39:05 -07:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
Doug Gregor
73e2143213 [SE-0112] Provide default implementations for CustomNSError requirements.
Provide default implementations for all of the CustomNSError requirements:
  * errorDomain: default to the name of the enum type
  * errorCode: default to the same thing "_code" gets, e.g., the enum tag or
    raw value
  * errorUserInfo: default to empty

This makes it significantly easier to customize just one aspect of the
NSError view of an error type, e.g., just the user-info dictionary,
without having to write boilerplate for the others. This was actually
part of SE-0112, but I missed it in the original implementation and we
thought it was an amendment.

Fixes rdar://problem/23511842.
2016-09-02 10:33:15 -07:00
Max Moiseev
9fc37efee4 [test] renaming test/1_stdlib to just test/stdlib 2016-09-01 16:51:43 -07:00
Jordan Rose
e83c117c30 [test] Hack: run stdlib tests first to start long-running tests earlier.
This decreases total testing time by over a minute on my old Mac Pro.
It probably has much less effect on systems with fewer cores, but shouldn't
be any worse there.

Swift SVN r22745
2014-10-15 01:30:51 +00:00
Jordan Rose
b7a63a74c6 [test] Drop -parse-stdlib from %target-run-stdlib-swift.
The latter now only refers to tests that need to violate access control in
the standard library. Only one test was actually using Builtin types; I've
modified that test specifically to use -parse-stdlib.

Swift SVN r22744
2014-10-15 01:22:46 +00:00
Jordan Rose
367160793b [test] Drop -enable-source-import from almost all tests that use IRGen.
-enable-source-import doesn't play nice with debug info, and we want to be
able to run all tests with -g added. The last few tests that require
-enable-source-import could be built with --no-debug-info, or however we
end up spelling that.

rdar://problem/18140021 (most of it)

Swift SVN r22742
2014-10-15 01:22:43 +00:00
Erik Eckstein
bec6758105 Enable tests which use ~= for Ranges.
These tests were disabled because of <rdar://problem/17668465> Failure to find overload
It seems that this is fixed now.



Swift SVN r22726
2014-10-14 09:06:55 +00:00
Dave Abrahams
5c7738c98b Correct a gyb-o
Swift SVN r22708
2014-10-13 19:08:57 +00:00
Dmitri Hrybenko
fea5de2fc8 stdlib and runtime: coding style fixes
Swift SVN r22685
2014-10-11 01:40:57 +00:00
Dave Abrahams
5c33278e63 [stdlib] Add ManagedBufferPointer
A revamped version of HeapBuffer that doesn't allow null buffer
references.  Something like this is needed for killing the null array
state.

Swift SVN r22683
2014-10-11 01:10:38 +00:00
Erik Eckstein
d0697f2ac1 Make internal stdlib functions public, which are called from the stdlib tests.
And make sure that all those public identifiers are preceeded with underscores.

I marked these public-modifiers with "// @testable" to document why they are public.
If some day we have a @testable attribute it should be used instead of those public-modifiers.

Again, this is needed for enabling dead internal function elimination in the stdlib.



Swift SVN r22657
2014-10-10 09:45:10 +00:00
Dave Abrahams
2d850421bc [stdlib] Internalize HeapBuffer[Storage], OnHeap
They were never really useful to users, because their APIs were
insufficiently public.  They have been replaced with a single class,
ManagedBuffer<Value,Element>, which is really designed for user
consumption.

Swift SVN r22636
2014-10-09 21:45:44 +00:00
Dave Abrahams
3f36a4d5e7 Use %target-run-stdlib-swift in more tests
Now that it disables access control, this lit definition applies to many
more tests, where we used to use %target-run-stdlib-swift before access
control came online.

Also, drop -Xfrontend -disable-access-control from a bunch of tests that
don't need it.

Swift SVN r22634
2014-10-09 20:53:07 +00:00
Dave Abrahams
57367877c4 [stdlib] Make 'Character' a struct
It used to be a public enum, which unnecessarily exposed structure that
was intended to be private implementation detail.  This change also has
the benefit that converting a String to a Character will avoid
allocating memory in many more cases.

Swift SVN r22629
2014-10-09 18:25:25 +00:00
Dmitri Hrybenko
d410ee7598 Move FixedPointDiagnostics to the validation testsuite
It is taking too long to run, rdar://18594315

Swift SVN r22619
2014-10-09 09:07:45 +00:00
Dave Abrahams
74e27aaab1 [stdlib] uniqueness checking for users
Make unique reference checking available to users, making ManagedBuffer
a complete facility for building COW value types.  Also rationalize the
way we name and organize the runtime primitives we ultimately call.

Swift SVN r22594
2014-10-08 04:48:52 +00:00
Dave Abrahams
eac8ca27f9 [stdlib] Use a universal empty array buffer
NFC, and no significant performance change expected.  This is part one
of a move to eliminate nil checks from the array implementation.

Swift SVN r22526
2014-10-05 17:55:11 +00:00
Dave Abrahams
b740ad0df9 Revert "[stdlib] Use a universal empty array buffer"
This reverts commit r22495, because it wroke havoc with SIL and the perf
test suite somehow.

Swift SVN r22499
2014-10-03 18:52:11 +00:00
Dave Abrahams
f2f068c3dc [stdlib] Use a universal empty array buffer
NFC, and no significant performance change expected.  This is part one
of a move to eliminate nil checks from the array implementation.

Swift SVN r22495
2014-10-03 16:01:50 +00:00
Erik Eckstein
ef120db075 Changed test for Dictionary init crash
Swift SVN r22488
2014-10-03 06:06:54 +00:00
Erik Eckstein
10133eb6d7 Fix wrong effects attribute for Dictionary.init()
This bug caused a crash in the Dictionary benchmark when compiled with -Ounchecked.
The problem was the CSE moved the Dictionary.init() over a store to the argument's
array buffer.



Swift SVN r22464
2014-10-02 11:45:47 +00:00
Dave Abrahams
43deddf8ac [stdlib] Move ManagedBuffer prototype into stdlib
...in preparation to use it in _[Contiguous]ArrayBuffer

Swift SVN r22440
2014-10-01 21:12:43 +00:00
Erik Eckstein
e5e796fcf0 Add tests for: Don't call reserveCapacity if constructing an empty uninitalized array.
Swift SVN r22433
2014-10-01 18:36:17 +00:00
Dmitri Hrybenko
b833355506 ArrayNew test: simplify checks
Swift SVN r22426
2014-10-01 13:14:08 +00:00
John McCall
1fa4f422ba Use mutable addressors for Array, now that doing so
doesn't prevent us from using a getter for immutable
accesses.

rdar://17270560

Swift SVN r22421
2014-10-01 05:20:43 +00:00
Dmitri Hrybenko
f3fa19ce01 stdlib: add tests for operator overloads on Strideable
Swift SVN r22417
2014-10-01 01:12:14 +00:00