Skip to content

Commit 6d3229a

Browse files
committed
Sema: Update tuple conformance test case to use pack iteration
Unfortunately SILGen still blows up when emitting witness thunks here.
1 parent 072d12a commit 6d3229a

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

test/Generics/tuple-conformances.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,30 @@ extension Tuple: Equatable where repeat each Element: Equatable {
9696
// FIXME: Hack
9797
@_disfavoredOverload
9898
public static func ==(lhs: Self, rhs: Self) -> Bool {
99-
var result = true
100-
func update<E: Equatable>(lhs: E, rhs: E) {
101-
result = result && (lhs == rhs)
99+
for (l, r) in repeat (each lhs, each rhs) {
100+
if l != r { return false }
102101
}
103-
104-
repeat update(lhs: each lhs, rhs: each rhs)
105-
return result
102+
return true
106103
}
107104
}
108105

109106
extension Tuple: Hashable where repeat each Element: Hashable {
110107
public func hash(into hasher: inout Hasher) {
111-
repeat (each self).hash(into: &hasher)
108+
for elt in repeat each self {
109+
elt.hash(into: &hasher)
110+
}
112111
}
113112
}
113+
114+
extension Tuple: Comparable where repeat each Element: Comparable {
115+
// FIXME: Hack
116+
@_disfavoredOverload
117+
public static func <(lhs: Self, rhs: Self) -> Bool {
118+
for (l, r) in repeat (each lhs, each rhs) {
119+
if l > r { return false }
120+
if l < r { return true }
121+
}
122+
return false
123+
}
124+
}
125+

0 commit comments

Comments
 (0)