Implement <rdar://problem/16951729> nil should be a literal type

This is all goodness, and eliminates a major source of implicit conversions.
One thing this regresses on though, is that we now reject "x == nil" where
x is an option type and the element of the optional is not Equtatable.  If
this is important, there are ways to enable this, but directly testing it as
a logic value is more straight-forward.

This does not include support for pattern matching against nil, that will be
a follow on patch.



Swift SVN r18918
This commit is contained in:
Chris Lattner
2014-06-15 22:59:03 +00:00
parent 17e3604b43
commit 60fc0e6cd2
42 changed files with 284 additions and 275 deletions

View File

@@ -148,8 +148,8 @@ protocol _RawOptionSet: RawRepresentable {
}
// TODO: This is an incomplete implementation of our option sets vision.
protocol RawOptionSet : _RawOptionSet, LogicValue, Equatable
/*FIXME: , BitwiseOperations*/ {
protocol RawOptionSet : _RawOptionSet, LogicValue, Equatable,
NilLiteralConvertible {
// A non-failable version of RawRepresentable.fromRaw.
class func fromMask(raw: RawType) -> Self
@@ -162,6 +162,12 @@ protocol RawOptionSet : _RawOptionSet, LogicValue, Equatable
/* func getLogicValue() -> Bool { return toRaw() != .allZeros() } */
}
/// Conforming to this protocol allows a type to be usable with the 'nil'
/// literal.
protocol NilLiteralConvertible {
class func convertFromNilLiteral() -> Self
}
protocol _BuiltinIntegerLiteralConvertible {
class func _convertFromBuiltinIntegerLiteral(
value: MaxBuiltinIntegerType) -> Self