We have enough flag bits on function types now to warrant stashing an extra word in the metadata key alongside the arguments and results, so add one, and pack the number of arguments, function convention, and 'throws' bit in there. This lets us merge the separate metadata caches for thick/thin/block/C functions into one, saving a bit of runtime memory, and simplifying a bunch of repetitive code in the runtime and IRGen.
This also fixes a subtle bug we had where the runtime getFunctionTypeMetadata function expected the result argument to be passed in the arguments array, but IRGen was passing it as a separate argument, which would have caused function type metadata to fail to be uniqued by result type.
Swift SVN r27651
If we see an ErrorType-conforming value type while casting to NSError, do the coercion in the runtime, so that e.g. 'error as Any as! NSError' works as well as 'error as NSError'.
Unfortunately, we can't do this for ErrorType-conforming classes without shattering SIL's brittle view of the world due to rdar://problem/20507075. Casts between class types are fairly deeply assumed not to change the identity of the reference.
Swift SVN r27225
Some future-proofing to let us change ErrorType's reference counting in the future, or to use various tagged pointer optimizations in its representation.
Swift SVN r27213
We may want to use optimized ErrorType representations that don't naturally "become" NSErrors, such as tagged-pointer representations of small error enums, or a tagged function pointer to a deferred error type constructor. Rename the runtime function to something a bit more descriptive of its real purpose, not its implementation.
Swift SVN r27209
Simplify the observation evaluation in the ErrorType race test by using evaluateObservationsAllEqual, and run the test for real. Apparently round-trip NSString and NSDictionary bridging doesn't produce a stable object, so use valueForKey as a hack to sidestep bridging so we can verify that the identities of the bridged domain and code aren't racy.
Swift SVN r27003
Atomically initialize and load the NSError bridging fields within an ErrorType box so that we do the right thing when two threads concurrently coerce the box to NSError.
Swift SVN r26996
If the NSError part of the box hasn't been initialized yet, fill it in with the domain and code of the contained value. This will allow us to efficiently turn ErrorType values into NSErrors, either for bridging or for coercion purposes.
Swift SVN r26958
This allows ErrorTypes referencing Cocoa NSErrors to be pattern-matched against our bridged enums, at least dynamically. (The compiler still doesn't understand these bridging conversions yet.)
Swift SVN r26839
After some more discussion with John, we decided that subclassing is the only realistic option, at least until we eventually are able to integrate with the OS. Switch things around to allocate Swift error boxes as an ObjC subclass that contains the error value instead of trying to game it as a CFError.
Swift SVN r26562
Teach ExistentialTypeMetadata how to project out the value pointer, type metadata, and protocol witness table from ErrorType containers. NFC yet; the dynamic casting and reflection machinery needs further work to correctly handle ErrorType boxes.
Swift SVN r26509