Type system support for raw pointer conversion. (#3685)

* [Type System] Handle raw pointer conversion.

As proposed in SE-0107: UnsafeRawPointer.
https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md#implicit-argument-conversion

UnsafeMutablePointer<T> -> UnsafeMutableRawPointer
UnsafeMutablePointer<T> -> UnsafeRawPointer
UnsafePointer<T> -> UnsafeRawPointer
UnsafeMutableRawPointer -> UnsafeRawPointer

inout:
&anyVar -> UnsafeMutableRawPointer
&anyVar -> UnsafeRawPointer

array -> UnsafeRawPointer
string -> UnsafeRawPointer

varArray -> UnsafeMutableRawPointer

* Rename expectEqual(_, _, sameValue:) to expectEqualTest to workaround a type system bug.

<rdar://26058520> Generic type constraints incorrectly applied to functions with the same name

This is exposed by additions to the type system for UnsafeRawPointer.

Warning: unit tests fail very confusingly without this fix.
This commit is contained in:
Andrew Trick
2016-07-23 11:30:49 -07:00
committed by GitHub
parent 765ddb0f87
commit ecc6bd51ad
16 changed files with 280 additions and 49 deletions

View File

@@ -122,7 +122,7 @@ final class CodecTest<Codec : TestableUnicodeCodec> {
default:
fatalError("decoding failed")
}
expectEqual(
expectEqualTest(
scalar, decoded,
"Decoding failed: \(asHex(scalar.value)) => " +
"\(asHex(nsEncoded)) => \(asHex(decoded.value))"
@@ -130,7 +130,7 @@ final class CodecTest<Codec : TestableUnicodeCodec> {
encodeIndex = encodeBuffer.startIndex
Codec.encode(scalar, into: encodeOutput)
expectEqual(
expectEqualTest(
nsEncoded, encodeBuffer[0..<encodeIndex],
"Decoding failed: \(asHex(nsEncoded)) => " +
"\(asHex(scalar.value)) => \(asHex(self.encodeBuffer[0]))"