10
10
// when only known to be comparable".
11
11
12
12
// Could calls to the different comparison operators.
13
- public var comparedAsComparablesCount : Int = 0
13
+ public var comparedAsCauxmparablesCount : Int = 0
14
14
public var comparedAsFauxtsCount : Int = 0
15
15
16
- public protocol FauxtingPoint : Comparable {
16
+ public protocol Cauxmparable {
17
+ static func < ( lhs: Self , rhs: Self ) -> Bool
18
+ }
19
+
20
+ public protocol FauxtingPoint : Cauxmparable {
17
21
static var nan : Self { get }
18
22
static var one : Self { get }
19
23
static var two : Self { get }
@@ -24,11 +28,11 @@ public protocol BinaryFauxtingPoint: FauxtingPoint {
24
28
}
25
29
26
30
public extension BinaryFauxtingPoint {
27
- // This version of < will be called in a context that only knows it has a Comparable .
28
- @_implements ( Comparable , < ( _: _: ) )
29
- static func _ComparableLessThan ( _ lhs: Fauxt , _ rhs: Fauxt ) -> Bool {
30
- print ( " compared as Comparables " )
31
- comparedAsComparablesCount += 1
31
+ // This version of < will be called in a context that only knows it has a Cauxmparable .
32
+ @_implements ( Cauxmparable , < ( _: _: ) )
33
+ static func _CauxmparableLessThan ( _ lhs: Fauxt , _ rhs: Fauxt ) -> Bool {
34
+ print ( " compared as Cauxmparables " )
35
+ comparedAsCauxmparablesCount += 1
32
36
return lhs. bitPattern < rhs. bitPattern
33
37
}
34
38
}
@@ -73,7 +77,7 @@ public extension Fauxt {
73
77
// This version of < will be called in a context that knows it has a Fauxt.
74
78
// It is inside an extension of Fauxt rather than the declaration of Fauxt
75
79
// itself in order to avoid a warning about near-matches with the defaulted
76
- // requirement from Comparable .< up above.
80
+ // requirement from Cauxmparable .< up above.
77
81
static func < ( _ lhs: Fauxt , _ rhs: Fauxt ) -> Bool {
78
82
print ( " compared as Fauxts " )
79
83
comparedAsFauxtsCount += 1
@@ -85,7 +89,7 @@ public extension Fauxt {
85
89
}
86
90
}
87
91
88
- public func compare_Comparables < T: Comparable > ( _ x: T , _ y: T ) -> Bool {
92
+ public func compare_Cauxmparables < T: Cauxmparable > ( _ x: T , _ y: T ) -> Bool {
89
93
return x < y
90
94
}
91
95
@@ -98,25 +102,25 @@ public func compare_Fauxts(_ x: Fauxt, _ y: Fauxt) -> Bool {
98
102
}
99
103
100
104
public func main( ) {
101
- assert ( compare_Comparables ( Fauxt . one, Fauxt . two) )
102
- assert ( comparedAsComparablesCount == 1 )
103
- // CHECK: compared as Comparables
104
- assert ( compare_Comparables ( Fauxt . one, Fauxt . nan) )
105
- assert ( comparedAsComparablesCount == 2 )
106
- // CHECK: compared as Comparables
107
- assert ( !compare_Comparables ( Fauxt . nan, Fauxt . one) )
108
- assert ( comparedAsComparablesCount == 3 )
109
- // CHECK: compared as Comparables
105
+ assert ( compare_Cauxmparables ( Fauxt . one, Fauxt . two) )
106
+ assert ( comparedAsCauxmparablesCount == 1 )
107
+ // CHECK: compared as Cauxmparables
108
+ assert ( compare_Cauxmparables ( Fauxt . one, Fauxt . nan) )
109
+ assert ( comparedAsCauxmparablesCount == 2 )
110
+ // CHECK: compared as Cauxmparables
111
+ assert ( !compare_Cauxmparables ( Fauxt . nan, Fauxt . one) )
112
+ assert ( comparedAsCauxmparablesCount == 3 )
113
+ // CHECK: compared as Cauxmparables
110
114
111
115
assert ( compare_FauxtingPoint ( Fauxt . one, Fauxt . two) )
112
- assert ( comparedAsComparablesCount == 4 )
113
- // CHECK: compared as Comparables
116
+ assert ( comparedAsCauxmparablesCount == 4 )
117
+ // CHECK: compared as Cauxmparables
114
118
assert ( compare_FauxtingPoint ( Fauxt . one, Fauxt . nan) )
115
- assert ( comparedAsComparablesCount == 5 )
116
- // CHECK: compared as Comparables
119
+ assert ( comparedAsCauxmparablesCount == 5 )
120
+ // CHECK: compared as Cauxmparables
117
121
assert ( !compare_FauxtingPoint( Fauxt . nan, Fauxt . one) )
118
- assert ( comparedAsComparablesCount == 6 )
119
- // CHECK: compared as Comparables
122
+ assert ( comparedAsCauxmparablesCount == 6 )
123
+ // CHECK: compared as Cauxmparables
120
124
121
125
assert ( compare_Fauxts ( Fauxt . one, Fauxt . two) )
122
126
assert ( comparedAsFauxtsCount == 1 )
0 commit comments