rangeOfCharacterFromSet(_:options:range:)
The underlying Objective-C API could return an NSRange of NSNotFound. Swift's
String.Index can not represent that, so change the API to return an optional
Swift Range<Index> instead.
Swift SVN r18679
stringWithBytes(_:length:encoding:) was passing an array to Objective-C
incorrectly, and a garbage NSString was being constructed as a result.
Unhide the initializer was accidentally hidden.
Swift SVN r18674
This is our public API for how quicklooks work in the debugger, and the plan is to have this same API work in playgrounds as well
Fixes rdar://17023157
Swift SVN r18609
XCTest needs a way to get the demangled name of a test case class,
so provide one by overriding NSObject.className.
Addresses <rdar://problem/17010812>.
Swift SVN r18606
There's a bit of a reshuffle of the ExplicitCastExpr subclasses:
- The existing ConditionalCheckedCastExpr expression node now represents
"as?".
- A new ForcedCheckedCastExpr node represents "as" when it is a
downcast.
- CoerceExpr represents "as" when it is a coercion.
- A new UnresolvedCheckedCastExpr node describes "as" before it has
been type-checked down to ForcedCheckedCastExpr or CoerceExpr. This
wasn't a strictly necessary change, but it helps us detangle what's
going on.
There are a few new diagnostics to help users avoid getting bitten by
as/as? mistakes:
- Custom errors when a forced downcast (as) is used as the operand
of postfix '!' or '?', with Fix-Its to remove the '!' or make the
downcast conditional (with as?), respectively.
- A warning when a forced downcast is injected into an optional,
with a suggestion to use a conditional downcast.
- A new error when the postfix '!' is used for a contextual
downcast, with a Fix-It to replace it with "as T" with the
contextual type T.
Lots of test updates, none of which felt like regressions. The new
tests are in test/expr/cast/optionals.swift.
Addresses <rdar://problem/17000058>
Swift SVN r18556
Many changes in how we're presenting the NSString APIs on String, most
notably that we now traffic in String.Index and Range<String.Index>
rather than Int and NSRange. Also we present NSString initializers that
can fail only as factory functions, and factory functions that can't
fail only as init functions.
About 25% of the API changes here have been reviewd by the Foundation
guys, and testing is, as it has always been, admittedly spotty. Dmitri
is going to be writing some more comprehensive tests.
Swift SVN r18553
- rdar://problem/16776273, wherein conversions between nil and .None were permitted
due to an implicit conversion between nil and COpaquePointer.
- rdar://problem/16877526, where we needed to add new equality overloads to handle
conversions between nil and .None given the supression of user conversions.
(Thanks to Ted for the overloads and test.)
Swift SVN r18473
UIViewController is able to find nib files that have names derived from the
UIViewController subclass's name. This change modifies UIViewController's
lookup so it is able to find nib files for Swift class names.
Swift SVN r18470
Dictionary's isBridgedToObjectiveC() was overly restrictive. This went
unnoticed because the tests were using internal Dictionary APIs to construct
the desired state, instead of going thourgh casts.
rdar://16973429
Swift SVN r18454
We were using the bridged non-verbatim path
(_arrayBridgeFromObjectiveC) for bridged-verbatim types. While that
path can do the right thing (and does when the standard library's
internal checking is turned off), it's unnecessarily inefficient.
Swift SVN r18418
This makes fun bridging like
var obj: AnyObject! = [3.14159, 2.71828, 0] as Double[]
if let intArr = obj as Int[] {
println("Array of doubles as ints is \(intArr)")
}
"work", given that NSNumber is the common class type through which we
are bridging.
Swift SVN r18398
Unfortunately, we can't add an implicit conversion from
String to CFString, or anything analogous like string
literal support, without introducing ambiguities
when converting to AnyObject.
rdar://16271682
Swift SVN r18387
This entry point is used when T is bridged verbatim and U is bridged
non-verbatim. It attempts to bridge each T from Objective-C to a U,
and returns nil if any of the elements cannot be bridged back to a U.
For now, only _convertNSArrayToArray and Array.bridgeFromObjectiveC
depend on this. It will soon be used for checked casts from, e.g.,
AnyObject[] to String[].
This is part of <rdar://problem/16952771> and general array bridging.
Swift SVN r18369
conform to LogicValue.
This approach was taken to keep _isNull because I first tried
to just use comparisons to nil instead of isNull(). Apparently
that led to some circular definitions, so it was easier to just
stage it this way.
Swift SVN r18301
upcasts."
Reinstate "Restrict the array-bridged conversion to non-verbatim
bridging."
Reinstate "[stdlib] Fix T[].bridgeFromObjectiveC"
Reinstate "[stdlib] Fix T[].bridgeFromObjectiveC"
Reinstate "[stdlib] Move _arrayBridgedDownCast to Foundation"
Reinstate "Replace "can" with "cannot" in a message."
Reinstate "Implement support for non-verbatim T[] -> AnyObject[]
upcasts."
This reinstates commit r18291.
This reinstates commit r18290.
This reinstates commit r18288.
This reinstates commit r18287.
This reinstates commit r18286.
This reinstates commit r18293.
This reinstates commit r18283.
John fixed the issue in r18294.
Swift SVN r18299
Revert "Restrict the array-bridged conversion to non-verbatim bridging."
Revert "[stdlib] Fix T[].bridgeFromObjectiveC"
Revert "[stdlib] Fix T[].bridgeFromObjectiveC"
Revert "[stdlib] Move _arrayBridgedDownCast to Foundation"
Revert "Replace "can" with "cannot" in a message."
Revert "Implement support for non-verbatim T[] -> AnyObject[] upcasts."
This reverts commit r18291.
This reverts commit r18290.
This reverts commit r18288.
This reverts commit r18287.
This reverts commit r18286.
This reverts commit r18293.
This reverts commit r18283.
Sorry for the number of reverts, but I needed to do this many to get a clean
revert to r18283.
Swift SVN r18296
The new sugar is 'NSErrorPointer', which hides 'AutoreleasingUnsafePointer<NSError?>'.
I have not yet tested this on iOS, which previously had problems
with the type sugar import. I'll try and test that now.
Swift SVN r18270