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:
@@ -227,8 +227,8 @@ LookupResult &ConstraintSystem::lookupMember(Type base, DeclName name) {
|
||||
return *result;
|
||||
}
|
||||
|
||||
ArrayRef<Type> ConstraintSystem::getAlternativeLiteralTypes(
|
||||
KnownProtocolKind kind) {
|
||||
ArrayRef<Type> ConstraintSystem::
|
||||
getAlternativeLiteralTypes(KnownProtocolKind kind) {
|
||||
unsigned index;
|
||||
|
||||
switch (kind) {
|
||||
@@ -237,37 +237,16 @@ ArrayRef<Type> ConstraintSystem::getAlternativeLiteralTypes(
|
||||
#define LITERAL_CONVERTIBLE_PROTOCOL(Protocol)
|
||||
#include "swift/AST/KnownProtocols.def"
|
||||
|
||||
case KnownProtocolKind::ArrayLiteralConvertible:
|
||||
index = 0;
|
||||
break;
|
||||
|
||||
case KnownProtocolKind::CharacterLiteralConvertible:
|
||||
index = 1;
|
||||
break;
|
||||
|
||||
case KnownProtocolKind::DictionaryLiteralConvertible:
|
||||
index = 2;
|
||||
break;
|
||||
|
||||
case KnownProtocolKind::ExtendedGraphemeClusterLiteralConvertible:
|
||||
index = 3;
|
||||
break;
|
||||
|
||||
case KnownProtocolKind::FloatLiteralConvertible:
|
||||
index = 4;
|
||||
break;
|
||||
|
||||
case KnownProtocolKind::IntegerLiteralConvertible:
|
||||
index = 5;
|
||||
break;
|
||||
|
||||
case KnownProtocolKind::StringInterpolationConvertible:
|
||||
index = 6;
|
||||
break;
|
||||
|
||||
case KnownProtocolKind::StringLiteralConvertible:
|
||||
index = 7;
|
||||
case KnownProtocolKind::ArrayLiteralConvertible: index = 0; break;
|
||||
case KnownProtocolKind::CharacterLiteralConvertible: index = 1; break;
|
||||
case KnownProtocolKind::DictionaryLiteralConvertible:index = 2; break;
|
||||
case KnownProtocolKind::ExtendedGraphemeClusterLiteralConvertible: index = 3;
|
||||
break;
|
||||
case KnownProtocolKind::FloatLiteralConvertible: index = 4; break;
|
||||
case KnownProtocolKind::IntegerLiteralConvertible: index = 5; break;
|
||||
case KnownProtocolKind::StringInterpolationConvertible: index = 6; break;
|
||||
case KnownProtocolKind::StringLiteralConvertible: index = 7; break;
|
||||
case KnownProtocolKind::NilLiteralConvertible: index = 8; break;
|
||||
}
|
||||
|
||||
// If we already looked for alternative literal types, return those results.
|
||||
|
||||
Reference in New Issue
Block a user