Commit Graph

1226 Commits

Author SHA1 Message Date
Robert Widmann
740721ab2f Address Dmitri's comments on #3600 2016-08-16 23:59:00 -07:00
Robert Widmann
e6c313bce3 Merge pull request #3600 from russbishop/se0045
[SR-1516][stdlib] Implement SE-0045 prefix(while:) and drop(while:)
2016-08-16 16:26:21 -07:00
Slava Pestov
56e2e1327a Targeted fix for pulling in Hashable conformance for Set and Dictionary when a nil literal is bridged
When bridging values via the ObjectiveCBridgeable protocol,
SILGen has to look up conformances directly, behind the
type checker's back.

To make sure the ObjectiveCBridgeable conformance is forced,
Sema calls useObjectiveCBridgeableConformances() in the right
places.

However, another conformance we may also need when bridging
is the Hashable conformance for a Set or Dictionary's key type.

Make sure we force these too, because otherwise when bridging
a nil literal nothing needs them in Sema.

Fixes <rdar://problem/27470505>.
2016-08-15 14:29:59 -07:00
Russ Bishop
f0e6c306e4 [stdlib][SE-45] Add prefix(while:) and drop(while:) to Sequence
Includes lazy implementation courtesy of Nate Cook
2016-08-15 14:13:27 -07:00
Jordan Rose
af1a8154a3 Guard against racy access to NSError.setUserInfoValueProvider. (#4280)
This API is documented in its headers to only allow being called once
for a particular domain, so we have to make sure our check for an
existing provider is synchronized with the setting.

rdar://problem/27541751
2016-08-15 13:34:30 -07:00
Dave Abrahams
e6dec58cc5 Merge pull request #4041 from xwu/memory-layout-of-value
[stdlib] Implement SE-0136 (Restore MemoryLayout.*(ofValue:))
2016-08-12 11:09:17 -07:00
Argyrios Kyrtzidis
126602d7dd [test] Update 'validation-test/stdlib/CollectionDiagnostics.swift' 2016-08-11 14:04:51 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Ted Kremenek
420088fbc4 Merge pull request #3356 from ultramiraculous/failable-float-to-int
SE-0080 (3/5) - Failable initializers for Float->Int
2016-08-10 08:36:33 -07:00
Chris Williams
a8e3a17090 Fix FixedPointConversion tests spacing 2016-08-09 17:09:00 -07:00
Dmitri Gribenko
f1ec334fe5 stdlib: make AnyHashable(SwiftValue) unbox the value
Previously AnyHashable would consider SwiftValue to be a subclass of
NSObject (which it is in practice) and return false when trying to
compare an AnyHashable of a SwiftValue box to an AnyHashable of the
unboxed value.
2016-08-09 01:38:53 -07:00
Dmitri Gribenko
b162f60070 runtime: make _SwiftNativeNSError use the Hashable conformance, if available
If the Swift error wrapped in a _SwiftNativeNSError box conforms to
Hashable, the box now uses the Swift's conformance to Hashable.

Part of rdar://problem/27574348.
2016-08-09 00:49:20 -07:00
Dmitri Gribenko
bfadfe37e4 stdlib: add (XFAIL'ed) tests for errors and NSErrors in AnyHashable 2016-08-09 00:49:20 -07:00
Dmitri Gribenko
3db584dc45 stdlib: AnyHashable: add a fixme 2016-08-09 00:49:20 -07:00
Dmitri Gribenko
091bd19610 stdlib: add tests for AnyHashable.base, and make test names uniform 2016-08-09 00:49:20 -07:00
Ted Kremenek
e5c8092cc1 Merge pull request #4134 from apple/simplify-tests
Simplify Foundation tests that compare types
2016-08-08 23:47:59 -07:00
Dave Abrahams
b23af7ce3b Merge pull request #4091 from apple/deprecate-indexable
Deprecate the Indexable protocols
2016-08-08 21:01:39 -07:00
Dmitri Gribenko
1425a9201d Foundation tests: simplify some tests using the new expectEqual() assertions 2016-08-08 17:56:08 -07:00
Dmitri Gribenko
e3a32a7044 stdlib tests: coding style fixes 2016-08-08 17:49:42 -07:00
Dave Abrahams
8a73f0b98e [stdlib] Change Indexable deprecation messages
It's important to let people know that, in contrast with existing
practice in other frameworks, we really are going to remove the
deprecated API, and soon.
2016-08-08 13:44:41 -07:00
Xiaodi Wu
f9435b9ce8 [stdlib] Restore MemoryLayout.*(ofValue:) 2016-08-08 10:46:37 -05:00
Dmitri Gribenko
1d6b08ba97 stdlib: share the Unicode dataset across different test files 2016-08-07 23:29:24 -07:00
Dave Abrahams
168047d0f0 Deprecate the Indexable protocols
Using them is always a mistake; the user should choose the corresponding
Collection protocol instead.
2016-08-07 22:20:27 -07:00
Dmitri Gribenko
987acd375d stdlib: make tests rely on Array implementation details less 2016-08-07 14:20:36 -07:00
Dmitri Gribenko
88de90a92d stdlib: fix incorrect distance measurement between UTF-16 indices
String.UTF16View.Index.distance(to:) was returning a negated result.

Fixes SR-1988.
2016-08-07 13:40:34 -06:00
Michael Ilseman
49e0685151 [noescape by default] drop superfluous @noescape from validation suite 2016-08-04 16:23:06 -07:00
Dmitri Gribenko
e0af6f9921 Convert CoreGraphics tests to StdlibUnittest 2016-08-04 10:36:43 -07:00
swift-ci
47fe3bd82c Merge pull request #3945 from jckarter/foundation-overlay-post-0072 2016-08-04 09:50:05 -07:00
Dmitri Gribenko
2119a0e02a Merge pull request #3993 from apple/spritekit-remove-redundant-tests
Remove redundant tests for SpriteKit
2016-08-04 09:38:14 -07:00
Joe Groff
62afa03eb9 Improve Foundation overlay to handle bridging subscripts and dictionary literals.
SE-0072 took implicit bridging conversions away, which regressed the ability to express NSDictionaries as dictionary literals and index them using literal keys. Address this by changing the signature of init(dictionaryLiteral:) to use Hashable and Any, and by replacing the subscript from Objective-C with one using _Hashable that does the bridging on the user's behalf. This largely restores the QoI of working with NS collections.
2016-08-04 08:42:36 -07:00
Dmitri Gribenko
48f852973b Remove redundant tests for SpriteKit
These exact tests already exist in
validation-test/stdlib/SpriteKit.swift.
2016-08-04 02:04:08 -07:00
Dmitri Gribenko
5d13d2a079 Merge pull request #3985 from apple/stdlib-int-stride-tests
stdlib: add tests for Stride types on integers
2016-08-04 00:19:57 -07:00
Doug Gregor
47f01ee98d Revert "Eliminate race in swift_bridgeErrorToNSError."
This reverts commit e07e88706d. The
crash came back, so there's obviously more I need to investigate here:

  https://ci.swift.org/job/swift-PR-osx-smoke-test/881/testReport/junit/Swift(macosx-x86_64)/stdlib/ErrorProtocol_swift/
2016-08-03 23:48:33 -07:00
Dmitri Gribenko
ee773c787a stdlib: add tests for Stride types on integers 2016-08-03 18:57:39 -07:00
Dmitri Gribenko
86741b9ca1 Merge pull request #3960 from apple/spritekit-fixes
SpriteKit overlay: add a better variant of the SKWarpGeometryGrid() initializer overlay
2016-08-03 18:20:25 -07:00
Doug Gregor
e07e88706d Eliminate race in swift_bridgeErrorToNSError.
Huge thanks to John for noting that 'consume' didn't provide the
guarantees we wanted, and to Michael G. for getting a TSan build up
and running to identify/verify this race.

It's possible that this is overlay strict, and that we only need to
look at the domain to ensure that the code and userInfo are
visible. However, TSan seems to prefix the form in this patch, so
we'll be more conservative for now.

Fixes rdar://problem/27541751.
2016-08-03 15:21:15 -07:00
Dmitri Gribenko
c41a9b6341 SpriteKit overlay: add a better variant of the SKWarpGeometryGrid() initializer overlay 2016-08-03 11:41:55 -07:00
Mishal Shah
d28ff854b9 Update master to build with Xcode 8 beta 4, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-08-02 11:47:10 -07:00
Jordan Rose
f42158b12e Revert "[Sema] ban multi-arguments to tuple coercion" (#3922)
It breaks cases where there really is a single unlabeled argument of tuple type, like this:

  let pairs = [(1, "A"), (2, "B")]
  print(pairs.map { $0.0 })
2016-08-01 19:22:19 -07:00
Chris Williams
4caf64a223 Have FloatingPointConversion use float helper methods 2016-08-01 14:27:51 -07:00
Chris Williams
c8458cebc4 Create SwiftFloatingPointTypes for float-related helpers 2016-08-01 14:27:51 -07:00
Chris Williams
2f74e7618d Add max/min helpers to SwiftIntTypes 2016-08-01 14:27:51 -07:00
Chris Williams
ae140e68a1 Tests for Float->Int Initializers 2016-08-01 14:27:51 -07:00
Nicole Jacque
65f933ea27 Disabling test until <rdar://problem/27541751> is resolved 2016-08-01 14:24:11 -07:00
Daniel Duan
c9b73dacc2 [Sema] ban multi-arguments to tuple coercion
Implements part of SE-0110. Single argument in closures will not be accepted if
there exists explicit type with a number of arguments that's not 1.

```swift
let f: (Int, Int) -> Void = { x in } // this is now an error
```

Note there's a second part of SE-0110 which could be considered additive,
which says one must add an extra pair of parens to specify a single arugment
type that is a tuple:

```swift
let g ((Int, Int)) -> Void = { y in } // y should have type (Int, Int)
```

This patch does not implement that part.
2016-07-31 16:22:57 -07:00
Robert Widmann
979ff4eee6 Merge pull request #3894 from CodaFi/string-cheese-to-go
Restore test lost in transition to String(describing:)
2016-07-31 14:00:48 -07:00
Dmitri Gribenko
bb6c6740ca stdlib: fix a bug in ArraySlice.removeLast() when startIndex != 0
ArraySlice.removeLast() only worked when startIndex was equal to zero.

This change fixes the bug, and uses the proper customization point for
the algorithm.

Fixes SR-1791, rdar://problem/26897658.
2016-07-31 02:04:23 -07:00
Robert Widmann
f2165a6e64 Restore test lost in transition to String(describing:) 2016-07-30 18:14:00 -07:00
Robert Widmann
e1ae0391e8 Fixup validation tests 2016-07-30 03:50:16 -07:00
Dmitri Gribenko
382d215ad3 stdlib: SE-0101: remove the last few uses of old APIs (sizeof, alignof, strideof) 2016-07-30 00:38:18 -07:00