Skip to content

Commit cbcf9ab

Browse files
author
Dave Abrahams
committed
s/LogicValueType/BooleanType/
We're moving toward using that protocol for straight-up Bool types Swift SVN r19884
1 parent 6d1095f commit cbcf9ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+100
-100
lines changed

Diff for: include/swift/AST/DiagnosticsSema.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ ERROR(reference_non_inout,sema_tce,none,
10151015
NOTE(subscript_decl_here,sema_tca,none,
10161016
"subscript operator declared here", ())
10171017
ERROR(condition_broken_proto,sema_tce,none,
1018-
"protocol 'LogicValueType' is broken", ())
1018+
"protocol 'BooleanType' is broken", ())
10191019
ERROR(broken_bool,sema_tce,none, "type 'Bool' is broken", ())
10201020
ERROR(binding_injected_optional,sema_tce,none,
10211021
"operand of postfix '?' should have optional type; type is %0", (Type))

Diff for: include/swift/AST/KnownProtocols.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
PROTOCOL(ArrayBoundType)
4040
PROTOCOL(SequenceType)
4141
PROTOCOL(GeneratorType)
42-
PROTOCOL(LogicValueType)
42+
PROTOCOL(BooleanType)
4343
PROTOCOL(AnyObject)
4444
PROTOCOL(RawRepresentable)
4545
PROTOCOL(RawOptionSetType)

Diff for: include/swift/Serialization/ModuleFormat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ namespace index_block {
11541154
ArrayBoundType = 1,
11551155
SequenceType,
11561156
// killed
1157-
LogicValueType = 4,
1157+
BooleanType = 4,
11581158

11591159
ArrayLiteralConvertible,
11601160
BooleanLiteralConvertible,

Diff for: lib/Sema/CSApply.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -5203,7 +5203,7 @@ Solution::convertToLogicValue(Expr *expr, ConstraintLocator *locator) const {
52035203
auto result = convertViaBuiltinProtocol(
52045204
*this, expr, locator,
52055205
tc.getProtocol(expr->getLoc(),
5206-
KnownProtocolKind::LogicValueType),
5206+
KnownProtocolKind::BooleanType),
52075207
tc.Context.Id_GetLogicValue,
52085208
tc.Context.Id_GetBuiltinLogicValue,
52095209
diag::condition_broken_proto,
@@ -5223,7 +5223,7 @@ Solution::convertOptionalToBool(Expr *expr, ConstraintLocator *locator) const {
52235223
auto &tc = cs.getTypeChecker();
52245224

52255225
auto proto = tc.getProtocol(
5226-
expr->getLoc(), KnownProtocolKind::LogicValueType);
5226+
expr->getLoc(), KnownProtocolKind::BooleanType);
52275227

52285228
// Find the witness we need to use.
52295229
Type type = expr->getType();

Diff for: lib/Sema/CSGen.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ namespace {
10921092
Expr *condExpr = expr->getCondExpr();
10931093
auto logicValue
10941094
= CS.getTypeChecker().getProtocol(expr->getQuestionLoc(),
1095-
KnownProtocolKind::LogicValueType);
1095+
KnownProtocolKind::BooleanType);
10961096
if (!logicValue)
10971097
return Type();
10981098

Diff for: lib/Sema/TypeCheckConstraints.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ bool TypeChecker::typeCheckCondition(Expr *&expr, DeclContext *dc) {
13741374
// Otherwise, the result must be a LogicValue.
13751375
auto &tc = cs.getTypeChecker();
13761376
auto logicValueProto = tc.getProtocol(expr->getLoc(),
1377-
KnownProtocolKind::LogicValueType);
1377+
KnownProtocolKind::BooleanType);
13781378
if (!logicValueProto) {
13791379
return true;
13801380
}

Diff for: stdlib/core/Algorithm.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public func max<T : Comparable>(x: T, y: T, z: T, rest: T...) -> T {
430430
return r
431431
}
432432

433-
public func split<Seq: Sliceable, R:LogicValueType>(
433+
public func split<Seq: Sliceable, R:BooleanType>(
434434
seq: Seq,
435435
isSeparator: (Seq.Generator.Element)->R,
436436
maxSplit: Int = Int.max,
@@ -638,7 +638,7 @@ public func lexicographicalCompare<
638638

639639
/// Return `true` iff an element in `seq` satisfies `predicate`.
640640
public func contains<
641-
S: SequenceType, L: LogicValueType
641+
S: SequenceType, L: BooleanType
642642
>(seq: S, predicate: (S.Generator.Element)->L) -> Bool {
643643
for a in seq {
644644
if predicate(a) {

Diff for: stdlib/core/Assert.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func assert(
3434
}
3535
}
3636
@transparent public
37-
func assert<T : LogicValueType>(
37+
func assert<T : BooleanType>(
3838
condition: @auto_closure () -> T, _ message: StaticString = StaticString(),
3939
file: StaticString = __FILE__, line: UWord = __LINE__
4040
) {
@@ -81,7 +81,7 @@ func _precondition(
8181
}
8282
}
8383
@transparent public
84-
func _precondition<T : LogicValueType>(
84+
func _precondition<T : BooleanType>(
8585
condition: @auto_closure () -> T, _ message: StaticString = StaticString(),
8686
file: StaticString = __FILE__, line: UWord = __LINE__
8787
) {
@@ -147,7 +147,7 @@ func _debugPrecondition(
147147
}
148148

149149
@transparent public
150-
func _debugPrecondition<T : LogicValueType>(
150+
func _debugPrecondition<T : BooleanType>(
151151
condition: @auto_closure () -> T, _ message: StaticString = StaticString(),
152152
file: StaticString = __FILE__, line: UWord = __LINE__
153153
) {
@@ -188,7 +188,7 @@ func _sanityCheck(
188188
}
189189

190190
@transparent public
191-
func _sanityCheck<T : LogicValueType>(
191+
func _sanityCheck<T : BooleanType>(
192192
condition: @auto_closure () -> T, _ message: StaticString = StaticString(),
193193
file: StaticString = __FILE__, line: UWord = __LINE__
194194
) {

Diff for: stdlib/core/Bool.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ extension Bool : _BuiltinBooleanLiteralConvertible, BooleanLiteralConvertible {
3737
}
3838
}
3939

40-
extension Bool : LogicValueType {
40+
extension Bool : BooleanType {
4141
@transparent public func _getBuiltinLogicValue() -> Builtin.Int1 {
4242
return value
4343
}
4444

4545
@transparent public func getLogicValue() -> Bool { return self }
4646

47-
// Bool can be constructed from LogicValueType
48-
public init(_ v : LogicValueType) {
47+
// Bool can be constructed from BooleanType
48+
public init(_ v : BooleanType) {
4949
self = v.getLogicValue()
5050
}
5151
}

Diff for: stdlib/core/BridgeObjectiveC.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ var _nilRawPointer: Builtin.RawPointer {
240240
/// because it only needs to reference the results of inout conversions, which
241241
/// already have writeback-scoped lifetime.
242242
public struct AutoreleasingUnsafePointer<T /* TODO : class */>
243-
: Equatable, LogicValueType, NilLiteralConvertible, _PointerType {
243+
: Equatable, BooleanType, NilLiteralConvertible, _PointerType {
244244
let value: Builtin.RawPointer
245245

246246
@transparent

Diff for: stdlib/core/Builtin.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ internal func _isClassOrObjCExistential<T>(x: T.Type) -> Bool {
127127
// mandatory generic inlining.
128128

129129
@transparent @semantics("branchhint") internal
130-
func _branchHint<C: LogicValueType>(actual: C, expected: Bool) -> Bool {
130+
func _branchHint<C: BooleanType>(actual: C, expected: Bool) -> Bool {
131131
return Bool(Builtin.int_expect_Int1(actual.getLogicValue().value, expected.value))
132132
}
133133

134134
@transparent @semantics("fastpath") public
135-
func _fastPath<C: LogicValueType>(x: C) -> Bool {
135+
func _fastPath<C: BooleanType>(x: C) -> Bool {
136136
return _branchHint(x.getLogicValue(), true)
137137
}
138138

139139
@transparent @semantics("slowpath") public
140-
func _slowPath<C: LogicValueType>(x: C) -> Bool {
140+
func _slowPath<C: BooleanType>(x: C) -> Bool {
141141
return _branchHint(x.getLogicValue(), false)
142142
}
143143

Diff for: stdlib/core/CTypes.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public typealias CBool = Bool
7676
///
7777
/// Opaque pointers are used to represent C pointers to types that
7878
/// cannot be represented in Swift, such as incomplete struct types.
79-
public struct COpaquePointer : Equatable, Hashable, LogicValueType,
79+
public struct COpaquePointer : Equatable, Hashable, BooleanType,
8080
NilLiteralConvertible {
8181
var value : Builtin.RawPointer
8282

@@ -128,7 +128,7 @@ extension COpaquePointer {
128128
}
129129
}
130130

131-
public struct CFunctionPointer<T> : Equatable, Hashable, LogicValueType,
131+
public struct CFunctionPointer<T> : Equatable, Hashable, BooleanType,
132132
NilLiteralConvertible {
133133
var value: COpaquePointer
134134

Diff for: stdlib/core/CompilerProtocols.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public protocol ArrayBoundType {
2525
/// Protocol describing types that can be used as logical values within
2626
/// a condition.
2727
///
28-
/// Types that conform to the `LogicValueType` protocol can be used as
28+
/// Types that conform to the `BooleanType` protocol can be used as
2929
/// condition in various control statements (`if`, `while`, C-style
3030
/// `for`) as well as other logical value contexts (e.g., `case`
3131
/// statement guards).
32-
public protocol LogicValueType {
32+
public protocol BooleanType {
3333
func getLogicValue() -> Bool
3434
}
3535

@@ -158,7 +158,7 @@ public protocol _RawOptionSetType: RawRepresentable {
158158
}
159159

160160
// TODO: This is an incomplete implementation of our option sets vision.
161-
public protocol RawOptionSetType : _RawOptionSetType, LogicValueType, Equatable,
161+
public protocol RawOptionSetType : _RawOptionSetType, BooleanType, Equatable,
162162
NilLiteralConvertible {
163163
// A non-failable version of RawRepresentable.fromRaw.
164164
class func fromMask(raw: Raw) -> Self

Diff for: stdlib/core/ContiguousArrayBuffer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final internal class _ContiguousArrayStorage<T> : _NSSwiftArray {
4747
}
4848
}
4949

50-
public struct _ContiguousArrayBuffer<T> : _ArrayBufferType, LogicValueType {
50+
public struct _ContiguousArrayBuffer<T> : _ArrayBufferType, BooleanType {
5151

5252
/// Make a buffer with uninitialized elements. After using this
5353
/// method, you must either initialize the count elements at the

Diff for: stdlib/core/HeapBuffer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public func _isUniquelyReferenced<T>(inout x: T) -> Bool {
8282
return _swift_isUniquelyReferenced(reinterpretCast(x))
8383
}
8484

85-
public struct HeapBuffer<Value, Element> : LogicValueType, Equatable {
85+
public struct HeapBuffer<Value, Element> : BooleanType, Equatable {
8686
public typealias Storage = HeapBufferStorage<Value, Element>
8787
let storage: Storage?
8888

Diff for: stdlib/core/ImplicitlyUnwrappedOptional.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/// ImplicitlyUnwrappedOptional<T>, but always interacts with it using the
1818
/// library intrinsics below.
1919
public enum ImplicitlyUnwrappedOptional<T>
20-
: LogicValueType, Reflectable, NilLiteralConvertible {
20+
: BooleanType, Reflectable, NilLiteralConvertible {
2121
case None
2222
case Some(T)
2323

Diff for: stdlib/core/LogicValue.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
12-
// LogicValueType
12+
// BooleanType
1313
//===----------------------------------------------------------------------===//
1414

15-
@prefix public func !<T : LogicValueType>(a: T) -> Bool {
15+
@prefix public func !<T : BooleanType>(a: T) -> Bool {
1616
return !a.getLogicValue()
1717
}
1818

@@ -28,11 +28,11 @@
2828
// [Implement overload resolution].
2929

3030
@transparent public
31-
func &&(lhs: LogicValueType, rhs: @auto_closure () -> LogicValueType) -> Bool {
31+
func &&(lhs: BooleanType, rhs: @auto_closure () -> BooleanType) -> Bool {
3232
return lhs.getLogicValue() ? rhs().getLogicValue() : false
3333
}
3434

3535
@transparent public
36-
func ||(lhs: LogicValueType, rhs: @auto_closure () -> LogicValueType) -> Bool {
36+
func ||(lhs: BooleanType, rhs: @auto_closure () -> BooleanType) -> Bool {
3737
return lhs.getLogicValue() ? true : rhs().getLogicValue()
3838
}

Diff for: stdlib/core/Optional.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

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

Diff for: stdlib/core/Range.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct RangeGenerator<
4040

4141
public struct Range<
4242
T: ForwardIndexType
43-
> : LogicValueType, Equatable, CollectionType {
43+
> : BooleanType, Equatable, CollectionType {
4444

4545
@transparent public
4646
init(start: T, end: T) {

Diff for: stdlib/core/UnsafePointer.swift.gyb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/// to allocate and free memory appropriately.
2828
public struct ${Self}<T>
2929
: BidirectionalIndexType, Comparable, Hashable,
30-
LogicValueType, NilLiteralConvertible, _PointerType {
30+
BooleanType, NilLiteralConvertible, _PointerType {
3131

3232
/// The underlying raw (untyped) pointer.
3333
var value : Builtin.RawPointer

Diff for: stdlib/objc/ObjectiveC.swift

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

Diff for: stdlib/objc/XCTest/XCTest.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ func XCTAssertNotNil(expression: @auto_closure () -> AnyObject?, _ message: Stri
107107
// TODO: handle an exception for which we can't get a description
108108
}
109109

110-
func XCTAssert(expression: @auto_closure () -> LogicValueType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
110+
func XCTAssert(expression: @auto_closure () -> BooleanType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
111111
// XCTAssert is just a cover for XCTAssertTrue.
112112
XCTAssertTrue(expression, message, file: file, line: line);
113113
}
114114

115-
func XCTAssertTrue(expression: @auto_closure () -> LogicValueType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
115+
func XCTAssertTrue(expression: @auto_closure () -> BooleanType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
116116
let assertionType = _XCTAssertionType.True
117117

118118
// evaluate the expression exactly once
@@ -128,7 +128,7 @@ func XCTAssertTrue(expression: @auto_closure () -> LogicValueType, _ message: St
128128
// TODO: handle an exception for which we can't get a description
129129
}
130130

131-
func XCTAssertFalse(expression: @auto_closure () -> LogicValueType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
131+
func XCTAssertFalse(expression: @auto_closure () -> BooleanType, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Void {
132132
let assertionType = _XCTAssertionType.False
133133

134134
// evaluate the expression exactly once

Diff for: stdlib/unittest/StdlibUnittest.swift.gyb

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public func expectGE(
222222

223223
%end
224224

225-
public struct AssertionResult : Printable, LogicValueType {
225+
public struct AssertionResult : Printable, BooleanType {
226226
init(isPass: Bool) {
227227
self._isPass = isPass
228228
}

Diff for: test/Constraints/condition.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ func simpleIf(b: Bool) {
66
}
77

88
// Support for non-Bool logic values
9-
struct OtherLogicValue : LogicValueType {
9+
struct OtherLogicValue : BooleanType {
1010
func getLogicValue() -> Bool { return true }
1111
}
1212

@@ -15,12 +15,12 @@ func otherIf(b : OtherLogicValue) {
1515
}
1616

1717
// Support for arbitrary logic values in generics
18-
func doIf<T : LogicValueType>(t: T) {
18+
func doIf<T : BooleanType>(t: T) {
1919
if t { }
2020
}
2121
doIf(true)
2222

23-
// Using LogicValueType-ness to resolve overloading.
23+
// Using BooleanType-ness to resolve overloading.
2424
func getValue() -> OtherLogicValue {}
2525
func getValue() -> Int {}
2626

Diff for: test/Constraints/if_expr.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %swift -parse %s -verify
22

3-
struct MyLogicValue : LogicValueType {
3+
struct MyLogicValue : BooleanType {
44
func getLogicValue() -> Bool {
55
return true
66
}

Diff for: test/Constraints/invalid_logicvalue_coercion.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
class C {}
44
var c = C()
5-
if c as C { // expected-error{{type 'C' does not conform to protocol 'LogicValueType'}}
5+
if c as C { // expected-error{{type 'C' does not conform to protocol 'BooleanType'}}
66
}
77

8-
if {1} as ()->Int { // expected-error{{type '() -> Int' does not conform to protocol 'LogicValueType'}}
8+
if {1} as ()->Int { // expected-error{{type '() -> Int' does not conform to protocol 'BooleanType'}}
99
}

Diff for: test/Constraints/members.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var format : String
3838
format._splitFirstIf({ $0.isASCII() })
3939

4040
// Archetypes
41-
func doGetLogicValue<T : LogicValueType>(t: T) {
41+
func doGetLogicValue<T : BooleanType>(t: T) {
4242
t.getLogicValue()
4343
}
4444

Diff for: test/DebugInfo/autoclosure.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ operator infix &&&&& {
1414
precedence 120
1515
}
1616

17-
func &&&&&(lhs: LogicValueType, rhs: @auto_closure ()->LogicValueType) -> Bool {
17+
func &&&&&(lhs: BooleanType, rhs: @auto_closure ()->BooleanType) -> Bool {
1818
return lhs.getLogicValue() ? rhs().getLogicValue() : false
1919
}
2020

0 commit comments

Comments
 (0)