Commit Graph

1358 Commits

Author SHA1 Message Date
Dave Abrahams
880f28b3fd [stdlib] Add missing 10.10 NSString APIs.
containsString and localizedCaseInsensitiveContainsString were
introduced in 10.10, release-noted, but never
documented (<rdar://22236574>), so we missed them.

Fixes <rdar://18776075> String.containsString doesn't work in Swift

Swift SVN r31152
2015-08-12 00:37:43 +00:00
Chris Lattner
f2f16dea4c remove a patch accidentally committed with r31130
Swift SVN r31138
2015-08-11 18:28:15 +00:00
Chris Lattner
a899872d91 Reapply r31105, with some fixes to invalid unconstrained generics. These fixes correct
the regressions that r31105 introduced in the validation tests, as well as fixing a number
of other validation tests as well.

Introduce a new UnresolvedType to the type system, and have CSDiags start to use it
as a way to get more type information out of incorrect subexpressions.  UnresolvedType
generally just propagates around the type system like a type variable:
 - it magically conforms to all protocols
 - it CSGens as an unconstrained type variable.
 - it ASTPrints as _, just like a type variable.

The major difference is that UnresolvedType can be used outside the context of a
ConstraintSystem, which is useful for CSGen since it sets up several of them to 
diagnose subexpressions w.r.t. their types.

For now, our use of this is extremely limited: when a closureexpr has no contextual
type available and its parameters are invalid, we wipe them out with UnresolvedType
(instead of the previous nulltype dance) to get ambiguities later on.

We also introduce a new FreeTypeVariableBinding::UnresolvedType approach for
constraint solving (and use this only in one place in CSDiags so far, to resolve
the callee of a CallExpr) which solves a system and rewrites any leftover type 
variables as UnresolvedTypes.  This allows us to get more precise information out,
for example, diagnosing:

 func r22162441(lines: [String]) {
   lines.map { line in line.fooBar() }
 }

with: value of type 'String' has no member 'fooBar'
instead of: type of expression is ambiguous without more context

This improves a number of other diagnostics as well, but is just the infrastructural
stepping stone for greater things.





Swift SVN r31130
2015-08-11 06:06:05 +00:00
David Farler
d5e9bde7e7 Don't use private functions in the CG overlay
Use an internal underscore function instead.

Swift SVN r31094
2015-08-08 01:45:10 +00:00
David Farler
8b10d158d7 Fixit Typo: CGRect.integralRect -> integerRect
Swift SVN r31084
2015-08-07 20:52:37 +00:00
Dmitri Hrybenko
050a2cdea8 Foundation overlay: adopt @warn_unused_result
Reviewed by Michael J LeHew Jr.

Swift SVN r31064
2015-08-06 23:50:53 +00:00
Dmitri Hrybenko
e587ef0086 SDK overlay: adopt @warn_unused_result
Swift SVN r31051
2015-08-06 15:54:52 +00:00
Mish Awadah
10bdef0936 Revert "CMake: build all platforms except watchOS using the public SDK"
This reverts commit cd3f1ba7d1ee2397817e1a165209fdeab8a1c004.

Reverting this b/c it is breaking buildbots with the following:
CMake Error at CMakeLists.txt:522 (message):
  CrashReporterClient library is required, but it was not found

Swift SVN r31047
2015-08-06 06:12:23 +00:00
Dmitri Hrybenko
271acdfcab CMake: build all platforms except watchOS using the public SDK
Covers rdar://problem/21145996.
A step towards rdar://problem/21099318.

Swift SVN r31041
2015-08-06 04:28:05 +00:00
Ben Langmuir
0fa6d7b65f Revert "Move GameKit overlay to GameCenter."
The headers went back to GameKit in a new SDK.

This reverts commit r30322.

Swift SVN r31015
2015-08-04 22:27:47 +00:00
David Farler
313a4c93c6 Review: Index protocol extensions
- Add Strict/Defaulted Index types to StdlibUnittest
- Test whether a random access index calls its more efficient
  customization by tracking successor calls.
- Fix the RandomAccessIndex.advancedBy(n, limit:) API by de-underscoring
  the limit parameter
- Inline some internal transparent default implementations to their only
  call site
- Attach _RandomAccessAmbiguity type to RandomAccessIndex

rdar://problem/22085119

Swift SVN r30979
2015-08-04 03:13:14 +00:00
David Farler
8febbc1095 Suggest NSURL path methods instead of NSString
rdar://problem/22095657

Swift SVN r30978
2015-08-04 02:59:41 +00:00
David Farler
f8e418df74 Add renamed fixits for CG overlay API change rdar://problem/19788137
Swift SVN r30972
2015-08-04 01:16:11 +00:00
Jordan Rose
953424072e Guard "object literals" feature with SWIFT_ENABLE_OBJECT_LITERALS.
This is not a feature we're releasing at the moment, so provide a way
to turn it off.

rdar://problem/21935551

Swift SVN r30966
2015-08-04 00:16:52 +00:00
David Farler
cd947e397b Make CoreGraphics overlay naming consistent with the Standard Library
- Don't repeat type names in methods and properties
- Use 'InPlace' suffix for mutating variants of methods that return
  a CG type.

rdar://problem/19788137

Swift SVN r30960
2015-08-03 20:09:32 +00:00
David Farler
311baf73cf Index protocol extensions
- Remove free Swift functions for advance and distance and replace
  them with protocol extension methods:
  - advancedBy(n)
  - advancedBy(n, limit:)
  - distanceTo(end)
- Modernize the Index tests
  - Use StdlibUnittest
  - Test for custom implementation dispatch

Perf impact: No significant changes reported in the
Swift Performance Measurement Tool.

rdar://problem/22085119

Swift SVN r30958
2015-08-03 20:06:44 +00:00
David Farler
f924e8e007 ArraySlice indexes no longer zero-based
ArraySlice indices now map directly onto the collection it is slicing
and maintains that mapping even after mutations.

Before:

var a = Array(0..<10)
var s = a[5..<10]
s.indices        // 0..<5
s[0] = 111
s                // [111, 6, 7, 8, 9]
s.removeFirst()
s.indices        // 1..<5

After:

var a = Array(0..<10)
var s = a[5..<10]
s.indices        // 5..<10
s[5] = 99
s                // [99, 6, 7, 8, 9]
s.removeFirst()
s.indices        // 6..<10

- Refactor some of the internals of the buffer types to make it easier
  to read and understand.
- Add Array, ArraySlice, and ContiguousArray to the test suite at the
  RangeReplaceable test entry points, subjecting them to the same tests
  as all of our collections.
- Update existing test expectations for the indexing changes.

rdar://problem/21866825

Swift SVN r30840
2015-07-31 03:25:29 +00:00
Zoltan Foley-Fisher
4f87b6e8c5 Fix <rdar://problem/18063644> [SWIFT] XCTAssert(Non)Nil should work on any optional type
Swift SVN r30813
2015-07-30 20:40:10 +00:00
Dmitri Hrybenko
c712ce3b5e simd overlay: drop label from second parameter in distance, distance_squared
Patch by Steve Canon.

Swift SVN r30695
2015-07-27 19:56:34 +00:00
Jordan Rose
a42ff82c80 Handle optional return for UIGraphicsGetImageFromCurrentImageContext too.
rdar://problem/21990808

Swift SVN r30615
2015-07-25 01:39:46 +00:00
Dmitri Hrybenko
f5de8757e4 stdlib: remove Word and UWord
These types are leftovers from the early pre-1.0 times when Int and UInt
were always 64-bit on all platforms.  They serve no useful purpose
today.  Int and UInt are defined to be word-sized and should be used
instead.

rdar://18693488

Swift SVN r30564
2015-07-24 05:01:32 +00:00
Dmitri Hrybenko
f44901dac6 CoreMedia overlay: change camel-casing of preferredTimeScale
Swift SVN r30538
2015-07-23 15:33:53 +00:00
Zoltan Foley-Fisher
4a3b5bada3 <rdar://problem/17541074> [SWIFT] Should XCTAssertEqual and friends take optional/nullable types?
Now comparing optionals in XCTAssertEqual/XCTAssertNotEqual

Swift SVN r30516
2015-07-22 23:42:37 +00:00
David Farler
1f2390f1c7 Drop APIs from NSPathUtilities.h on String
rdar://problem/18848175

Swift SVN r30507
2015-07-22 22:12:56 +00:00
Jordan Rose
5b16185eb6 Fix -Wnullability-declspec issues in GameplayKit overlay.
No functionality change.

Swift SVN r30480
2015-07-22 00:14:04 +00:00
Dmitri Hrybenko
740d0c871e CMake: simplify PassKit dependencies
Swift SVN r30404
2015-07-20 17:16:41 +00:00
Dmitri Hrybenko
a7190bf16e Build the Contacts overlay for watchOS
Thanks Jordan!

Swift SVN r30400
2015-07-20 16:13:37 +00:00
David Farler
da670c5a34 libswiftWatchKit depends on libswiftCoreLocation
<rdar://problem/21885844>

Swift SVN r30373
2015-07-18 06:55:13 +00:00
Dmitri Hrybenko
0fd6fd1f8f CoreMedia overlay: add an initializer CMTimeRange(start🔚)
rdar://20939243

Patch by Adam Sonnanstine + tests from me.

Swift SVN r30364
2015-07-18 03:35:08 +00:00
Dmitri Hrybenko
1e7e471dd9 CMake: record that PassKit overlay depends on the new Concacts overlay
Swift SVN r30363
2015-07-18 03:27:37 +00:00
Dmitri Hrybenko
48c901c918 Foundation overlay: use the new selectors for NSCoder APIs
rdar://21431062

Swift SVN r30362
2015-07-18 03:08:17 +00:00
Joe Groff
d6f1178568 Foundation overlay: Deprecate String "PercentEscapesUsingEncoding" methods.
These have been superseded by newer APIs in Foundation, and Swift should follow suit. rdar://problem/21397308

Swift SVN r30356
2015-07-18 02:25:51 +00:00
Dmitri Hrybenko
9392d76fd7 Additions to the SceneKit overlay
<rdar://problem/20855539> Add SCNVector3/4 Swift convenience
<rdar://problem/20854576> Add SCNFloat to the SceneKit swift overlay

Patch by Amaury Balliet.

Swift SVN r30353
2015-07-18 01:08:05 +00:00
Dmitri Hrybenko
3ba51ad202 Foundation overlay: fix coding style
Swift SVN r30350
2015-07-18 00:39:46 +00:00
Dmitri Hrybenko
6cef57029f Remove the SDK overlay for Security
It is no longer needed per rdar://19785756

Swift SVN r30349
2015-07-18 00:39:43 +00:00
Dmitri Hrybenko
6ba6de23aa Revert "Eliminate the NSError -> error enum bridging from Contacts."
This reverts commits r29003 and r29005.

The blocking issue, rdar://21032649, is fixed.

rdar://21032711

Swift SVN r30345
2015-07-17 23:59:49 +00:00
Doug Gregor
89ff140503 Move the default implementation of ErrorType._domain into the standard library.
There is no reason for the compiler to be synthesizing a body of
_domain when it can be implemented in a protocol extension. As part of
this, fix a recent regression in the computed domain: it was using
string interpolation, which means that the recent changes not to print
qualified names affected the domain of the generated NSErrors. Oops.

Swift SVN r30343
2015-07-17 23:37:59 +00:00
Dmitri Hrybenko
82ec7ea9d2 CoreMedia overlay: make CMTime Comparable, and CMTimeRange Equatable
Change approved by Adam Sonnanstine.

Swift SVN r30335
2015-07-17 22:26:58 +00:00
Jordan Rose
965285f13d Move GameKit overlay to GameCenter.
In iOS 9 and OS X 10.11 the old GameKit was effectively renamed GameCenter, while
the new GameKit is a sort of umbrella framework like Cocoa. We need to support
backwards deployment, though, so the GameCenter overlay links to GameKit.framework.
(This is essentially the same solution implemented for CoreImage moving out of
QuartzCore in r28449)

rdar://problem/21340738

Swift SVN r30322
2015-07-17 19:54:38 +00:00
Dmitri Hrybenko
109add8131 Foundation overlay: add NSCoder.decodeObjectOfClasses(_:forKey:)
Due to the fact that AnyClass is not Hashable, and that currently
NSKeyedArchiver/Unarchiver work with NSObject-derived, NSCoding
compliant classes, we are marking the decodeObjectOfClasses API refined
for Swift in our objc header and providing the desired overlay in our
overlay as shown below.

Arrays were also considered (for both API), but the underlying
implementation is entirely set-based, and using Arrays in Swift vs Sets
in objective C felt like too far a deviation.

Patch by Michael LeHew Jr.

Changes to the Dictionary test are caused by bumping the Fonudation API
epoch and taking in a fix in the types used in an NSDictionary
initializer.

rdar://21486551

Swift SVN r30297
2015-07-17 03:07:47 +00:00
Dmitri Hrybenko
71c5bb9371 CoreMedia overlay: change CMTimeMakeWithSeconds into an initializer
Patch by Adam Sonnanstine.

rdar://20940262

Swift SVN r30271
2015-07-16 20:24:47 +00:00
Dmitri Hrybenko
82c6b23239 SDK overlay: use AnyObject instead of AnyClass to pass an id-compatible
Class representation

As Joe explained, when Swift passes a metatype like AnyClass for an type
defined in Objective-C, it will pass the Swift metadata pointer instead
of an id-compatible Class.

Swift SVN r30268
2015-07-16 17:34:09 +00:00
Dmitri Hrybenko
9d27519a69 SDK overlay: fix a bug in the SceneKit overlay and re-enable the test
Patch by Amaury Balliet.

Part of rdar://20738811

Swift SVN r30234
2015-07-15 23:29:09 +00:00
David Farler
b9fe9eef63 Explicitly mark GameKit -> simd overlay dependency
Speculative fix for rdar://problem/21808853.

Swift SVN r30232
2015-07-15 22:57:12 +00:00
David Farler
e689ab3369 Mark AppKit -> CoreData dependency in the overlays
AppKit links CoreData and this relationship isn't expressed
in the build mechanics for the overlays, which can cause
link failures when building the overlay.

rdar://problem/21837604

Swift SVN r30223
2015-07-15 18:49:10 +00:00
Jordan Rose
497e990c0b Handle UIGraphicsGetCurrentContext's return value becoming optional.
...in such a way that both older and newer SDKs are supported (at least for now).

rdar://problem/21819293

Swift SVN r30193
2015-07-14 20:31:44 +00:00
Enrico Granata
88e3c41f39 Provide a specific (legacy) Mirror for NSString
This does not cause any functionality change, except it solves the issue I was running into last night where an array of NSString-s would expose its child values as plain Strings



Swift SVN r30092
2015-07-10 21:37:46 +00:00
Ted Kremenek
56a3ddbdb4 Make UIEdgeInsets and UIOffset conform to Equatable.
Implemented at the behest of the UIKit team.

Implements <rdar://problem/18109916>.

Swift SVN r30089
2015-07-10 21:11:25 +00:00
Jordan Rose
cbda31eba4 [stdlib] Underscore the 'value' members of DarwinBoolean and ObjCBool.
Per Dmitri's request and stdlib conventions. Also, remove the reference to
what's now '_value' from the DarwinBoolean tests, and use unsafeBitCast
instead to mimic representation-compatible access from C.

Swift SVN r30066
2015-07-10 06:25:06 +00:00
Jordan Rose
0b5428fcd3 Import DarwinBoolean as Bool in fully-bridgeable contexts.
These are contexts where we have enough information to bridge /back/
properly; that is, where we can distinguish CBool, ObjCBool, and
DarwinBoolean. In cases where we can't, we keep the three separate;
only CBool is really the same type as Bool.

This also affects current import behavior for ObjCBool, which was previously
incorrectly conflated with CBool in certain cases.

More rdar://problem/19013551

Swift SVN r30051
2015-07-10 01:11:30 +00:00