Files
swift-mirror/validation-test/compiler_crashers_2_fixed/rdar56700017.swift
2019-11-01 18:55:16 -04:00

18 lines
359 B
Swift

// RUN: %target-swift-frontend -typecheck %s
extension Sequence {
func sorted<T: Comparable, K: KeyPath<Element, T>>(by keyPath: K) -> Array<Element> {
self.sorted { $0[keyPath:keyPath] < $1[keyPath:keyPath] }
}
}
struct Foo {
let a: Int
}
func main() {
print([Foo(a: 2), Foo(a:1), Foo(a:4), Foo(a:3)].sorted(by: \Foo.a))
}
main()