File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1285,7 +1285,10 @@ namespace {
1285
1285
} else {
1286
1286
auto keyPathBGT = keyPathTy->castTo <BoundGenericType>();
1287
1287
baseTy = keyPathBGT->getGenericArgs ()[0 ];
1288
-
1288
+
1289
+ // Coerce the index to the key path's type
1290
+ indexKP = coerceToType (indexKP, keyPathTy, locator);
1291
+
1289
1292
// Coerce the base to the key path's expected base type.
1290
1293
if (!baseTy->isEqual (cs.getType (base)->getRValueType ()))
1291
1294
base = coerceToType (base, baseTy, locator);
Original file line number Diff line number Diff line change @@ -51,3 +51,11 @@ func testFunc() {
51
51
let f = \S . i
52
52
let _: ( S ) -> Int = f // expected-error {{cannot convert value of type 'KeyPath<S, Int>' to specified type '(S) -> Int'}}
53
53
}
54
+
55
+ // SR-11234
56
+ public extension Array {
57
+ func sorted< C: Comparable , K: KeyPath < Element , C > > ( by keyPath: K ) -> Array < Element > {
58
+ let sortedA = self . sorted ( by: { $0 [ keyPath: keyPath] < $1 [ keyPath: keyPath] } )
59
+ return sortedA
60
+ }
61
+ }
You can’t perform that action at this time.
0 commit comments