mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make "true" and "false" Boolean literal constants for the BooleanLiteralConvertible protocol.
Introduce the new BooleanLiteralConvertible protocol for Boolean literals. Take "true" and "false" as real keywords (which is most of the reason for the testsuite churn). Make Bool BooleanLiteralConvertible and the default Boolean literal type, and ObjCBool BooleanLiteralConvertible. Fixes <rdar://problem/17405310> and the recent regression that made ObjCBool not work with true/false. Swift SVN r19728
This commit is contained in:
@@ -401,36 +401,6 @@ NominalTypeDecl *ASTContext::getStringDecl() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ValueDecl *ASTContext::getTrueDecl() const {
|
||||
auto boolDecl = getBoolDecl();
|
||||
if (!boolDecl) return nullptr;
|
||||
auto boolTy = boolDecl->getDeclaredType();
|
||||
|
||||
SmallVector<ValueDecl*, 1> results;
|
||||
lookupInSwiftModule("true", results);
|
||||
for (auto result : results) {
|
||||
if (result->getType()->isEqual(boolTy))
|
||||
return result;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
ValueDecl *ASTContext::getFalseDecl() const {
|
||||
auto boolDecl = getBoolDecl();
|
||||
if (!boolDecl) return nullptr;
|
||||
auto boolTy = boolDecl->getDeclaredType();
|
||||
|
||||
SmallVector<ValueDecl*, 1> results;
|
||||
lookupInSwiftModule("false", results);
|
||||
for (auto result : results) {
|
||||
if (result->getType()->isEqual(boolTy))
|
||||
return result;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
/// Find the generic implementation declaration for the named syntactic-sugar
|
||||
/// type.
|
||||
static NominalTypeDecl *findSyntaxSugarImpl(const ASTContext &ctx,
|
||||
|
||||
Reference in New Issue
Block a user