File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -634,8 +634,9 @@ void BindingSet::finalize(
634
634
assert (isKnownKeyPathType (bindingTy) || bindingTy->is <FunctionType>());
635
635
636
636
// Functions don't have capability so we can simply add them.
637
- if (bindingTy->is <FunctionType>())
638
- updatedBindings.insert (binding);
637
+ if (auto *fnType = bindingTy->getAs <FunctionType>()) {
638
+ updatedBindings.insert (binding.withType (fnType));
639
+ }
639
640
}
640
641
641
642
// Note that even though key path literal maybe be invalid it's
Original file line number Diff line number Diff line change @@ -304,3 +304,17 @@ func test_invalid_argument_to_keypath_subscript() {
304
304
// expected-error@-1 {{cannot use value of type 'A' as a key path subscript index; argument must be a key path}}
305
305
}
306
306
}
307
+
308
+ extension Collection {
309
+ func prefix< R: RangeExpression > (
310
+ _ range: R ,
311
+ while predicate: ( ( Element ) -> Bool ) ? = nil
312
+ ) -> SubSequence where R. Bound == Self . Index {
313
+ fatalError ( )
314
+ }
315
+ }
316
+
317
+ // https://github.com/apple/swift/issues/56393
318
+ func keypathToFunctionWithOptional( ) {
319
+ _ = Array ( " " ) . prefix ( 1 ... 4 , while: \. isNumber) // Ok
320
+ }
You can’t perform that action at this time.
0 commit comments