mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user