s/LogicValueType/BooleanType/

We're moving toward using that protocol for straight-up Bool types

Swift SVN r19884
This commit is contained in:
Dave Abrahams
2014-07-12 18:58:18 +00:00
parent 6d1095f44e
commit cbcf9aba21
47 changed files with 100 additions and 100 deletions

View File

@@ -1015,7 +1015,7 @@ ERROR(reference_non_inout,sema_tce,none,
NOTE(subscript_decl_here,sema_tca,none,
"subscript operator declared here", ())
ERROR(condition_broken_proto,sema_tce,none,
"protocol 'LogicValueType' is broken", ())
"protocol 'BooleanType' is broken", ())
ERROR(broken_bool,sema_tce,none, "type 'Bool' is broken", ())
ERROR(binding_injected_optional,sema_tce,none,
"operand of postfix '?' should have optional type; type is %0", (Type))

View File

@@ -39,7 +39,7 @@
PROTOCOL(ArrayBoundType)
PROTOCOL(SequenceType)
PROTOCOL(GeneratorType)
PROTOCOL(LogicValueType)
PROTOCOL(BooleanType)
PROTOCOL(AnyObject)
PROTOCOL(RawRepresentable)
PROTOCOL(RawOptionSetType)

View File

@@ -1154,7 +1154,7 @@ namespace index_block {
ArrayBoundType = 1,
SequenceType,
// killed
LogicValueType = 4,
BooleanType = 4,
ArrayLiteralConvertible,
BooleanLiteralConvertible,

View File

@@ -5203,7 +5203,7 @@ Solution::convertToLogicValue(Expr *expr, ConstraintLocator *locator) const {
auto result = convertViaBuiltinProtocol(
*this, expr, locator,
tc.getProtocol(expr->getLoc(),
KnownProtocolKind::LogicValueType),
KnownProtocolKind::BooleanType),
tc.Context.Id_GetLogicValue,
tc.Context.Id_GetBuiltinLogicValue,
diag::condition_broken_proto,
@@ -5223,7 +5223,7 @@ Solution::convertOptionalToBool(Expr *expr, ConstraintLocator *locator) const {
auto &tc = cs.getTypeChecker();
auto proto = tc.getProtocol(
expr->getLoc(), KnownProtocolKind::LogicValueType);
expr->getLoc(), KnownProtocolKind::BooleanType);
// Find the witness we need to use.
Type type = expr->getType();

View File

@@ -1092,7 +1092,7 @@ namespace {
Expr *condExpr = expr->getCondExpr();
auto logicValue
= CS.getTypeChecker().getProtocol(expr->getQuestionLoc(),
KnownProtocolKind::LogicValueType);
KnownProtocolKind::BooleanType);
if (!logicValue)
return Type();

View File

@@ -1374,7 +1374,7 @@ bool TypeChecker::typeCheckCondition(Expr *&expr, DeclContext *dc) {
// Otherwise, the result must be a LogicValue.
auto &tc = cs.getTypeChecker();
auto logicValueProto = tc.getProtocol(expr->getLoc(),
KnownProtocolKind::LogicValueType);
KnownProtocolKind::BooleanType);
if (!logicValueProto) {
return true;
}

View File

@@ -430,7 +430,7 @@ public func max<T : Comparable>(x: T, y: T, z: T, rest: T...) -> T {
return r
}
public func split<Seq: Sliceable, R:LogicValueType>(
public func split<Seq: Sliceable, R:BooleanType>(
seq: Seq,
isSeparator: (Seq.Generator.Element)->R,
maxSplit: Int = Int.max,
@@ -638,7 +638,7 @@ public func lexicographicalCompare<
/// Return `true` iff an element in `seq` satisfies `predicate`.
public func contains<
S: SequenceType, L: LogicValueType
S: SequenceType, L: BooleanType
>(seq: S, predicate: (S.Generator.Element)->L) -> Bool {
for a in seq {
if predicate(a) {

View File

@@ -34,7 +34,7 @@ func assert(
}
}
@transparent public
func assert<T : LogicValueType>(
func assert<T : BooleanType>(
condition: @auto_closure () -> T, _ message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__
) {
@@ -81,7 +81,7 @@ func _precondition(
}
}
@transparent public
func _precondition<T : LogicValueType>(
func _precondition<T : BooleanType>(
condition: @auto_closure () -> T, _ message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__
) {
@@ -147,7 +147,7 @@ func _debugPrecondition(
}
@transparent public
func _debugPrecondition<T : LogicValueType>(
func _debugPrecondition<T : BooleanType>(
condition: @auto_closure () -> T, _ message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__
) {
@@ -188,7 +188,7 @@ func _sanityCheck(
}
@transparent public
func _sanityCheck<T : LogicValueType>(
func _sanityCheck<T : BooleanType>(
condition: @auto_closure () -> T, _ message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__
) {

View File

@@ -37,15 +37,15 @@ extension Bool : _BuiltinBooleanLiteralConvertible, BooleanLiteralConvertible {
}
}
extension Bool : LogicValueType {
extension Bool : BooleanType {
@transparent public func _getBuiltinLogicValue() -> Builtin.Int1 {
return value
}
@transparent public func getLogicValue() -> Bool { return self }
// Bool can be constructed from LogicValueType
public init(_ v : LogicValueType) {
// Bool can be constructed from BooleanType
public init(_ v : BooleanType) {
self = v.getLogicValue()
}
}

View File

@@ -240,7 +240,7 @@ var _nilRawPointer: Builtin.RawPointer {
/// because it only needs to reference the results of inout conversions, which
/// already have writeback-scoped lifetime.
public struct AutoreleasingUnsafePointer<T /* TODO : class */>
: Equatable, LogicValueType, NilLiteralConvertible, _PointerType {
: Equatable, BooleanType, NilLiteralConvertible, _PointerType {
let value: Builtin.RawPointer
@transparent

View File

@@ -127,17 +127,17 @@ internal func _isClassOrObjCExistential<T>(x: T.Type) -> Bool {
// mandatory generic inlining.
@transparent @semantics("branchhint") internal
func _branchHint<C: LogicValueType>(actual: C, expected: Bool) -> Bool {
func _branchHint<C: BooleanType>(actual: C, expected: Bool) -> Bool {
return Bool(Builtin.int_expect_Int1(actual.getLogicValue().value, expected.value))
}
@transparent @semantics("fastpath") public
func _fastPath<C: LogicValueType>(x: C) -> Bool {
func _fastPath<C: BooleanType>(x: C) -> Bool {
return _branchHint(x.getLogicValue(), true)
}
@transparent @semantics("slowpath") public
func _slowPath<C: LogicValueType>(x: C) -> Bool {
func _slowPath<C: BooleanType>(x: C) -> Bool {
return _branchHint(x.getLogicValue(), false)
}

View File

@@ -76,7 +76,7 @@ public typealias CBool = Bool
///
/// Opaque pointers are used to represent C pointers to types that
/// cannot be represented in Swift, such as incomplete struct types.
public struct COpaquePointer : Equatable, Hashable, LogicValueType,
public struct COpaquePointer : Equatable, Hashable, BooleanType,
NilLiteralConvertible {
var value : Builtin.RawPointer
@@ -128,7 +128,7 @@ extension COpaquePointer {
}
}
public struct CFunctionPointer<T> : Equatable, Hashable, LogicValueType,
public struct CFunctionPointer<T> : Equatable, Hashable, BooleanType,
NilLiteralConvertible {
var value: COpaquePointer

View File

@@ -25,11 +25,11 @@ public protocol ArrayBoundType {
/// Protocol describing types that can be used as logical values within
/// a condition.
///
/// Types that conform to the `LogicValueType` protocol can be used as
/// Types that conform to the `BooleanType` protocol can be used as
/// condition in various control statements (`if`, `while`, C-style
/// `for`) as well as other logical value contexts (e.g., `case`
/// statement guards).
public protocol LogicValueType {
public protocol BooleanType {
func getLogicValue() -> Bool
}
@@ -158,7 +158,7 @@ public protocol _RawOptionSetType: RawRepresentable {
}
// TODO: This is an incomplete implementation of our option sets vision.
public protocol RawOptionSetType : _RawOptionSetType, LogicValueType, Equatable,
public protocol RawOptionSetType : _RawOptionSetType, BooleanType, Equatable,
NilLiteralConvertible {
// A non-failable version of RawRepresentable.fromRaw.
class func fromMask(raw: Raw) -> Self

View File

@@ -47,7 +47,7 @@ final internal class _ContiguousArrayStorage<T> : _NSSwiftArray {
}
}
public struct _ContiguousArrayBuffer<T> : _ArrayBufferType, LogicValueType {
public struct _ContiguousArrayBuffer<T> : _ArrayBufferType, BooleanType {
/// Make a buffer with uninitialized elements. After using this
/// method, you must either initialize the count elements at the

View File

@@ -82,7 +82,7 @@ public func _isUniquelyReferenced<T>(inout x: T) -> Bool {
return _swift_isUniquelyReferenced(reinterpretCast(x))
}
public struct HeapBuffer<Value, Element> : LogicValueType, Equatable {
public struct HeapBuffer<Value, Element> : BooleanType, Equatable {
public typealias Storage = HeapBufferStorage<Value, Element>
let storage: Storage?

View File

@@ -17,7 +17,7 @@
/// ImplicitlyUnwrappedOptional<T>, but always interacts with it using the
/// library intrinsics below.
public enum ImplicitlyUnwrappedOptional<T>
: LogicValueType, Reflectable, NilLiteralConvertible {
: BooleanType, Reflectable, NilLiteralConvertible {
case None
case Some(T)

View File

@@ -9,10 +9,10 @@
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// LogicValueType
// BooleanType
//===----------------------------------------------------------------------===//
@prefix public func !<T : LogicValueType>(a: T) -> Bool {
@prefix public func !<T : BooleanType>(a: T) -> Bool {
return !a.getLogicValue()
}
@@ -28,11 +28,11 @@
// [Implement overload resolution].
@transparent public
func &&(lhs: LogicValueType, rhs: @auto_closure () -> LogicValueType) -> Bool {
func &&(lhs: BooleanType, rhs: @auto_closure () -> BooleanType) -> Bool {
return lhs.getLogicValue() ? rhs().getLogicValue() : false
}
@transparent public
func ||(lhs: LogicValueType, rhs: @auto_closure () -> LogicValueType) -> Bool {
func ||(lhs: BooleanType, rhs: @auto_closure () -> BooleanType) -> Bool {
return lhs.getLogicValue() ? true : rhs().getLogicValue()
}

View File

@@ -12,7 +12,7 @@
// The compiler has special knowledge of Optional<T>, including the fact that
// it is an enum with cases named 'None' and 'Some'.
public enum Optional<T>: LogicValueType, Reflectable, NilLiteralConvertible {
public enum Optional<T>: BooleanType, Reflectable, NilLiteralConvertible {
case None
case Some(T)

View File

@@ -40,7 +40,7 @@ public struct RangeGenerator<
public struct Range<
T: ForwardIndexType
> : LogicValueType, Equatable, CollectionType {
> : BooleanType, Equatable, CollectionType {
@transparent public
init(start: T, end: T) {

View File

@@ -27,7 +27,7 @@
/// to allocate and free memory appropriately.
public struct ${Self}<T>
: BidirectionalIndexType, Comparable, Hashable,
LogicValueType, NilLiteralConvertible, _PointerType {
BooleanType, NilLiteralConvertible, _PointerType {
/// The underlying raw (untyped) pointer.
var value : Builtin.RawPointer

View File

@@ -22,7 +22,7 @@ import ObjectiveC
/// On 64-bit iOS, the Objective-C BOOL type is a typedef of C/C++
/// bool. Elsewhere, it is "signed char". The Clang importer imports it as
/// ObjCBool.
public struct ObjCBool : LogicValueType, BooleanLiteralConvertible {
public struct ObjCBool : BooleanType, BooleanLiteralConvertible {
#if os(OSX) || (os(iOS) && (arch(i386) || arch(arm)))
// On OS X and 32-bit iOS, Objective-C's BOOL type is a "signed char".
var value: Int8

View File

@@ -107,12 +107,12 @@ func XCTAssertNotNil(expression: @auto_closure () -> AnyObject?, _ message: Stri
// TODO: handle an exception for which we can't get a description
}
func XCTAssert(expression: @auto_closure () -> LogicValueType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
func XCTAssert(expression: @auto_closure () -> BooleanType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
// XCTAssert is just a cover for XCTAssertTrue.
XCTAssertTrue(expression, message, file: file, line: line);
}
func XCTAssertTrue(expression: @auto_closure () -> LogicValueType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
func XCTAssertTrue(expression: @auto_closure () -> BooleanType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
let assertionType = _XCTAssertionType.True
// evaluate the expression exactly once
@@ -128,7 +128,7 @@ func XCTAssertTrue(expression: @auto_closure () -> LogicValueType, _ message: St
// TODO: handle an exception for which we can't get a description
}
func XCTAssertFalse(expression: @auto_closure () -> LogicValueType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
func XCTAssertFalse(expression: @auto_closure () -> BooleanType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
let assertionType = _XCTAssertionType.False
// evaluate the expression exactly once

View File

@@ -222,7 +222,7 @@ public func expectGE(
%end
public struct AssertionResult : Printable, LogicValueType {
public struct AssertionResult : Printable, BooleanType {
init(isPass: Bool) {
self._isPass = isPass
}

View File

@@ -6,7 +6,7 @@ func simpleIf(b: Bool) {
}
// Support for non-Bool logic values
struct OtherLogicValue : LogicValueType {
struct OtherLogicValue : BooleanType {
func getLogicValue() -> Bool { return true }
}
@@ -15,12 +15,12 @@ func otherIf(b : OtherLogicValue) {
}
// Support for arbitrary logic values in generics
func doIf<T : LogicValueType>(t: T) {
func doIf<T : BooleanType>(t: T) {
if t { }
}
doIf(true)
// Using LogicValueType-ness to resolve overloading.
// Using BooleanType-ness to resolve overloading.
func getValue() -> OtherLogicValue {}
func getValue() -> Int {}

View File

@@ -1,6 +1,6 @@
// RUN: %swift -parse %s -verify
struct MyLogicValue : LogicValueType {
struct MyLogicValue : BooleanType {
func getLogicValue() -> Bool {
return true
}

View File

@@ -2,8 +2,8 @@
class C {}
var c = C()
if c as C { // expected-error{{type 'C' does not conform to protocol 'LogicValueType'}}
if c as C { // expected-error{{type 'C' does not conform to protocol 'BooleanType'}}
}
if {1} as ()->Int { // expected-error{{type '() -> Int' does not conform to protocol 'LogicValueType'}}
if {1} as ()->Int { // expected-error{{type '() -> Int' does not conform to protocol 'BooleanType'}}
}

View File

@@ -38,7 +38,7 @@ var format : String
format._splitFirstIf({ $0.isASCII() })
// Archetypes
func doGetLogicValue<T : LogicValueType>(t: T) {
func doGetLogicValue<T : BooleanType>(t: T) {
t.getLogicValue()
}

View File

@@ -14,7 +14,7 @@ operator infix &&&&& {
precedence 120
}
func &&&&&(lhs: LogicValueType, rhs: @auto_closure ()->LogicValueType) -> Bool {
func &&&&&(lhs: BooleanType, rhs: @auto_closure ()->BooleanType) -> Bool {
return lhs.getLogicValue() ? rhs().getLogicValue() : false
}

View File

@@ -3,7 +3,7 @@
// The iOS/arm64 target uses _Bool for Objective C's BOOL. We include
// x86_64 here as well because the iOS simulator also uses _Bool.
#if os(iOS) && (arch(arm64) || arch(x86_64))
public struct ObjCBool : LogicValueType {
public struct ObjCBool : BooleanType {
private var value : Bool
public init(_ value: Bool) {
@@ -18,7 +18,7 @@ public struct ObjCBool : LogicValueType {
#else
public struct ObjCBool : LogicValueType {
public struct ObjCBool : BooleanType {
private var value : UInt8
public init(_ value: Bool) {

View File

@@ -5,11 +5,11 @@
operator prefix !! {}
operator infix &&& {}
@prefix func !!<T : LogicValueType>(x: T) -> Bool {
@prefix func !!<T : BooleanType>(x: T) -> Bool {
return x.getLogicValue()
}
func &&&(x: LogicValueType, y: @auto_closure () -> LogicValueType) -> Bool {
func &&&(x: BooleanType, y: @auto_closure () -> BooleanType) -> Bool {
return x.getLogicValue() ? y().getLogicValue() : false
}

View File

@@ -1,16 +1,16 @@
// RUN: %target-run-simple-swift | FileCheck %s
func andc<T : LogicValueType>(x: Bool, y: T) -> Bool {
func andc<T : BooleanType>(x: Bool, y: T) -> Bool {
return x && !y.getLogicValue()
}
struct Truthy : LogicValueType {
struct Truthy : BooleanType {
func getLogicValue() -> Bool {
return true
}
}
struct Falselike : LogicValueType {
struct Falselike : BooleanType {
func getLogicValue() -> Bool {
return false
}
@@ -21,10 +21,10 @@ println(andc(false, Truthy())) // CHECK: false
println(andc(true, Falselike())) // CHECK: true
println(andc(false, Falselike())) // CHECK: false
func must<T : LogicValueType>(x: T) {
func must<T : BooleanType>(x: T) {
assert(x.getLogicValue())
}
func shant<T : LogicValueType>(x: T) {
func shant<T : BooleanType>(x: T) {
assert(!x.getLogicValue())
}

View File

@@ -175,7 +175,7 @@ func missingControllingExprInFor() {
}
// A trailing closure is not accepted for the condition.
for ; acceptsClosure { 42 }; { // expected-error{{does not conform to protocol 'LogicValueType'}}
for ; acceptsClosure { 42 }; { // expected-error{{does not conform to protocol 'BooleanType'}}
// expected-error@-1{{expected ';' in 'for' statement}}
// expected-error@-2{{braced block}}
}

View File

@@ -64,7 +64,7 @@ case _ where x % 2 == 0,
x = 1
case var y where y % 2 == 0:
x = y + 1
case _ where 0: // expected-error {{type 'Int' does not conform to protocol 'LogicValueType'}}
case _ where 0: // expected-error {{type 'Int' does not conform to protocol 'BooleanType'}}
x = 0
default:
x = 1

View File

@@ -2,7 +2,7 @@
@exported import ObjectiveC
public struct ObjCBool : LogicValueType {
public struct ObjCBool : BooleanType {
var value : UInt8
/// \brief Allow use in a Boolean context.

View File

@@ -1,10 +1,10 @@
// RUN: %swift -module-name=Swift -parse-stdlib -emit-silgen %s | FileCheck %s
protocol LogicValueType {
protocol BooleanType {
func getLogicValue() -> Bool
}
struct Bool : LogicValueType {
struct Bool : BooleanType {
var value: Builtin.Int1
func _getBuiltinLogicValue() -> Builtin.Int1 { return value }
func getLogicValue() -> Bool { return self }

View File

@@ -106,7 +106,7 @@ struct HasVarInit {
static var state = true && false
}
// CHECK-LABEL: // function_ref mangling.HasVarInit.(state : Swift.Bool).(variable initialization expression).(implicit closure #1)
// CHECK-NEXT: function_ref @_TFIvV8mangling10HasVarInit5stateSbiu_KT_PSs14LogicValueType_
// CHECK-NEXT: function_ref @_TFIvV8mangling10HasVarInit5stateSbiu_KT_PSs11BooleanType_
// auto_closures should not collide with the equivalent non-auto_closure
// function type.

View File

@@ -7,4 +7,4 @@ func foo(a: NSKeyValueObservingOptions) -> Bool {
return a || true
}
// CHECK: sil_witness_table shared NSKeyValueObservingOptions: LogicValueType module Foundation
// CHECK: sil_witness_table shared NSKeyValueObservingOptions: BooleanType module Foundation

View File

@@ -876,20 +876,20 @@ bb0:
}
// Generic call to "branchHint" for use in specialized @slowPath
sil public_external [transparent] [semantics "branchhint"] @_TFSs11_branchHintUSs14LogicValueType__FTQ_Sb_Sb : $@thin <C where C : LogicValueType> (@in C, Bool) -> Bool {
sil public_external [transparent] [semantics "branchhint"] @_TFSs11_branchHintUSs11BooleanType__FTQ_Sb_Sb : $@thin <C where C : BooleanType> (@in C, Bool) -> Bool {
bb0(%0 : $*C, %1 : $Bool):
%2 = witness_method $C, #LogicValueType.getLogicValue!1 : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : LogicValueType> (@inout τ_0_0) -> Bool // user: %4
%3 = apply %2<C>(%0) : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : LogicValueType> (@inout τ_0_0) -> Bool
%2 = witness_method $C, #BooleanType.getLogicValue!1 : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : BooleanType> (@inout τ_0_0) -> Bool // user: %4
%3 = apply %2<C>(%0) : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : BooleanType> (@inout τ_0_0) -> Bool
return %3 : $Bool
}
// Specialized call to "slowPath" for use in @coldcall_caller
sil shared [transparent] [semantics "slowpath"] @_TTSSbSbSs14LogicValueType___TFSs9_slowPathUSs14LogicValueType__FQ_Sb : $@thin (@in Bool) -> Bool {
sil shared [transparent] [semantics "slowpath"] @_TTSSbSbSs11BooleanType___TFSs9_slowPathUSs11BooleanType__FQ_Sb : $@thin (@in Bool) -> Bool {
bb0(%0 : $*Bool):
%3 = integer_literal $Builtin.Int1, 0
%4 = struct $Bool (%3 : $Builtin.Int1)
%5 = function_ref @_TFSs11_branchHintUSs14LogicValueType__FTQ_Sb_Sb : $@thin <τ_0_0 where τ_0_0 : LogicValueType> (@in τ_0_0, Bool) -> Bool
%6 = apply [transparent] %5<Bool>(%0, %4) : $@thin <τ_0_0 where τ_0_0 : LogicValueType> (@in τ_0_0, Bool) -> Bool
%5 = function_ref @_TFSs11_branchHintUSs11BooleanType__FTQ_Sb_Sb : $@thin <τ_0_0 where τ_0_0 : BooleanType> (@in τ_0_0, Bool) -> Bool
%6 = apply [transparent] %5<Bool>(%0, %4) : $@thin <τ_0_0 where τ_0_0 : BooleanType> (@in τ_0_0, Bool) -> Bool
return %6 : $Bool
}
@@ -908,7 +908,7 @@ bb0(%0 : $Int):
%5 = apply %3(%4, %2) : $@thin (Builtin.Word, Builtin.Word) -> Builtin.Int1 // user: %6
%6 = struct $Bool (%5 : $Builtin.Int1) // user: %7
store %6 to %1#1 : $*Bool // id: %7
%8 = function_ref @_TTSSbSbSs14LogicValueType___TFSs9_slowPathUSs14LogicValueType__FQ_Sb : $@thin (@in Bool) -> Bool // user: %9
%8 = function_ref @_TTSSbSbSs11BooleanType___TFSs9_slowPathUSs11BooleanType__FQ_Sb : $@thin (@in Bool) -> Bool // user: %9
%9 = apply [transparent] %8(%1#1) : $@thin (@in Bool) -> Bool // user: %10
%10 = struct_extract %9 : $Bool, #Bool.value // user: %12
dealloc_stack %1#0 : $*@local_storage Bool // id: %11
@@ -930,7 +930,7 @@ bb0:
return %t : $()
}
sil [transparent] [semantics "fastpath"] @fastPathHelper : $@thin <τ_0_0 where τ_0_0 : LogicValueType> (@in τ_0_0) -> Bool
sil [transparent] [semantics "fastpath"] @fastPathHelper : $@thin <τ_0_0 where τ_0_0 : BooleanType> (@in τ_0_0) -> Bool
// fastpath.closedTest0 () -> ()
// From <rdar://problem/17611447> _fastPath kills optimizer
@@ -945,12 +945,12 @@ sil [transparent] [semantics "fastpath"] @fastPathHelper : $@thin <τ_0_0 where
// CHECK-LABEL: bb2:
sil @testNoInlineSlow : $@thin () -> () {
bb0:
%f1 = function_ref @fastPathHelper : $@thin <τ_0_0 where τ_0_0 : LogicValueType> (@in τ_0_0) -> Bool
%f1 = function_ref @fastPathHelper : $@thin <τ_0_0 where τ_0_0 : BooleanType> (@in τ_0_0) -> Bool
%v9 = alloc_stack $Bool
%v12 = integer_literal $Builtin.Int1, 0
%v16 = struct $Bool (%v12 : $Builtin.Int1)
store %v16 to %v9#1 : $*Bool // id: %17
%v18 = apply [transparent] %f1<Bool>(%v9#1) : $@thin <τ_0_0 where τ_0_0 : LogicValueType> (@in τ_0_0) -> Bool
%v18 = apply [transparent] %f1<Bool>(%v9#1) : $@thin <τ_0_0 where τ_0_0 : BooleanType> (@in τ_0_0) -> Bool
%v19 = struct_extract %v18 : $Bool, #Bool.value
dealloc_stack %v9#0 : $*@local_storage Bool // id: %20
cond_br %v19, bb2, bb1 // id: %21
@@ -974,12 +974,12 @@ bb2:
// CHECK-LABEL: bb2:
sil @testInlineSlowTransparent : $@thin () -> () {
bb0:
%f1 = function_ref @fastPathHelper : $@thin <τ_0_0 where τ_0_0 : LogicValueType> (@in τ_0_0) -> Bool
%f1 = function_ref @fastPathHelper : $@thin <τ_0_0 where τ_0_0 : BooleanType> (@in τ_0_0) -> Bool
%v9 = alloc_stack $Bool
%v12 = integer_literal $Builtin.Int1, 0
%v16 = struct $Bool (%v12 : $Builtin.Int1)
store %v16 to %v9#1 : $*Bool // id: %17
%v18 = apply [transparent] %f1<Bool>(%v9#1) : $@thin <τ_0_0 where τ_0_0 : LogicValueType> (@in τ_0_0) -> Bool
%v18 = apply [transparent] %f1<Bool>(%v9#1) : $@thin <τ_0_0 where τ_0_0 : BooleanType> (@in τ_0_0) -> Bool
%v19 = struct_extract %v18 : $Bool, #Bool.value
dealloc_stack %v9#0 : $*@local_storage Bool // id: %20
cond_br %v19, bb2, bb1 // id: %21

View File

@@ -332,14 +332,14 @@ bb0:
// rdar://15887292 - PredictableMemoryOptimizations crashes on load from init_existential
// CHECK-LABEL: sil @init_existential_crash
sil @init_existential_crash : $() -> () {
%99 = alloc_stack $LogicValueType
%100 = init_existential %99#1 : $*LogicValueType, $*Bool
%99 = alloc_stack $BooleanType
%100 = init_existential %99#1 : $*BooleanType, $*Bool
%105 = integer_literal $Builtin.Int1, 0
%106 = struct $Bool (%105 : $Builtin.Int1)
store %106 to %100 : $*Bool
%108 = struct_element_addr %100 : $*Bool, #Bool.value
%109 = load %108 : $*Builtin.Int1
dealloc_stack %99#0 : $*@local_storage LogicValueType
dealloc_stack %99#0 : $*@local_storage BooleanType
return undef : $()
}

View File

@@ -791,13 +791,13 @@ sil @print_a_number : $@thin (Int) -> ()
//CHECK: return
sil @remove_init_ex : $@thin (Int) -> () {
bb0(%0 : $Int):
%1 = alloc_stack $LogicValueType
%2 = init_existential %1#1 : $*LogicValueType, $*Bool
%1 = alloc_stack $BooleanType
%2 = init_existential %1#1 : $*BooleanType, $*Bool
%3 = integer_literal $Builtin.Int1, 1
%4 = struct $Bool (%3 : $Builtin.Int1)
store %4 to %2 : $*Bool
destroy_addr %1#1 : $*LogicValueType
dealloc_stack %1#0 : $*@local_storage LogicValueType
destroy_addr %1#1 : $*BooleanType
dealloc_stack %1#0 : $*@local_storage BooleanType
%8 = tuple ()
return %8 : $()
}

View File

@@ -158,7 +158,7 @@ class NonObjC {}
@IBOutlet var outlet4: AnyObject?
func testStrong() {
if outlet3 {} // expected-error {{type 'Infer' does not conform to protocol 'LogicValueType'}}
if outlet3 {} // expected-error {{type 'Infer' does not conform to protocol 'BooleanType'}}
if outlet4 {}
}
}

View File

@@ -201,11 +201,11 @@ func != <T>(lhs : T, rhs : NoneType) -> Bool { // expected-error{{invalid redecl
}
// <rdar://problem/15082356>
func &&(lhs: LogicValueType, rhs: @auto_closure ()->LogicValueType) -> Bool { // expected-note{{previously declared}}
func &&(lhs: BooleanType, rhs: @auto_closure ()->BooleanType) -> Bool { // expected-note{{previously declared}}
return lhs.getLogicValue() && rhs().getLogicValue()
}
func &&(lhs: LogicValueType, rhs: @auto_closure ()->LogicValueType) -> Bool { // expected-error{{invalid redeclaration of '&&'}}
func &&(lhs: BooleanType, rhs: @auto_closure ()->BooleanType) -> Bool { // expected-error{{invalid redeclaration of '&&'}}
return lhs.getLogicValue() || rhs().getLogicValue()
}

View File

@@ -5,7 +5,7 @@
//
// RUN: %target-run %t/a.out fatal 2>&1 | FileCheck %s -check-prefix=CHECK_FATAL
// RUN: %target-run %t/a.out Bool 2>&1 | FileCheck %s -check-prefix=CHECK_BOOL
// RUN: %target-run %t/a.out LogicValueType 2>&1 | FileCheck %s -check-prefix=CHECK_LOGICVALUE
// RUN: %target-run %t/a.out BooleanType 2>&1 | FileCheck %s -check-prefix=CHECK_LOGICVALUE
// REQUIRES: swift_stdlib_asserts
@@ -15,7 +15,7 @@ import Darwin
// Utilities.
//===---
struct Truthiness : LogicValueType {
struct Truthiness : BooleanType {
init(_ value: Bool) { self.value = value }
func getLogicValue() -> Bool { return value }
@@ -78,7 +78,7 @@ func test_securityCheckLogicValue() {
// CHECK_LOGICVALUE-NEXT: CRASHED: SIG{{ILL|TRAP}}
}
if (Process.arguments[1] == "LogicValueType") {
if (Process.arguments[1] == "BooleanType") {
test_securityCheckLogicValue()
}

View File

@@ -41,7 +41,7 @@ if (Process.arguments[1] == "debugTrapBool") {
test_debugTrapBool()
}
struct Truthiness : LogicValueType {
struct Truthiness : BooleanType {
init(_ value: Bool) { self.value = value }
func getLogicValue() -> Bool { return value }

View File

@@ -1,6 +1,6 @@
// RUN: %target-run-simple-swift | FileCheck %s
enum Bewl : LogicValueType {
enum Bewl : BooleanType {
case False, True
func getLogicValue() -> Bool {
@@ -25,11 +25,11 @@ func falsy() -> Bewl {
func logicValueTests() {
// Logic values should convert to bool.
struct X : LogicValueType {
struct X : BooleanType {
func getLogicValue() -> Bool { return false }
}
var anX = X()
println("LogicValueType Bool = \(Bool(anX))") // CHECK: LogicValueType Bool = false
println("BooleanType Bool = \(Bool(anX))") // CHECK: BooleanType Bool = false
println("\(!Bewl.True)") // CHECK: false
println("\(!Bewl.False)") // CHECK: true

View File

@@ -207,16 +207,16 @@ RuntimeBridging.test("isBridgedVerbatimToObjectiveC") {
// The protocol should be defined in the standard library, otherwise the cast
// does not work.
typealias P1 = LogicValueType
typealias P1 = BooleanType
protocol P2 {}
struct StructConformsToP1 : LogicValueType, P2 {
struct StructConformsToP1 : BooleanType, P2 {
func getLogicValue() -> Bool {
return true
}
}
struct Struct2ConformsToP1<T : LogicValueType> : LogicValueType, P2 {
struct Struct2ConformsToP1<T : BooleanType> : BooleanType, P2 {
init(_ value: T) {
self.value = value
}
@@ -228,13 +228,13 @@ struct Struct2ConformsToP1<T : LogicValueType> : LogicValueType, P2 {
struct StructDoesNotConformToP1 : P2 {}
class ClassConformsToP1 : LogicValueType, P2 {
class ClassConformsToP1 : BooleanType, P2 {
func getLogicValue() -> Bool {
return true
}
}
class Class2ConformsToP1<T : LogicValueType> : LogicValueType, P2 {
class Class2ConformsToP1<T : BooleanType> : BooleanType, P2 {
init(_ value: T) {
self.value = [ value ]
}

View File

@@ -52,7 +52,7 @@ func funcdecl5(a: Int, y: Int) {
}
// FIXME: This diagnostic is terrible - rdar://12939553
if x {} // expected-error {{type 'Int' does not conform to protocol 'LogicValueType'}}
if x {} // expected-error {{type 'Int' does not conform to protocol 'BooleanType'}}
if true {
if (B) {
@@ -92,7 +92,7 @@ struct infloopbool {
}
func infloopbooltest() {
if (infloopbool()) {} // expected-error {{type 'infloopbool' does not conform to protocol 'LogicValueType'}}
if (infloopbool()) {} // expected-error {{type 'infloopbool' does not conform to protocol 'BooleanType'}}
}
// test "builder" API style