Skip to content

Commit 116c5bf

Browse files
committed
Add a regression test for rdar://problem/56700017
1 parent 2dddfcb commit 116c5bf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -typecheck %s
2+
3+
extension Sequence {
4+
func sorted<T: Comparable, K: KeyPath<Element, T>>(by keyPath: K) -> Array<Element> {
5+
self.sorted { $0[keyPath:keyPath] < $1[keyPath:keyPath] }
6+
}
7+
}
8+
9+
struct Foo {
10+
let a: Int
11+
}
12+
13+
func main() {
14+
print([Foo(a: 2), Foo(a:1), Foo(a:4), Foo(a:3)].sorted(by: \Foo.a))
15+
}
16+
17+
main()

0 commit comments

Comments
 (0)