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 @@ -667,8 +667,9 @@ void BindingSet::finalize(
667667 assert (isKnownKeyPathType (bindingTy) || bindingTy->is <FunctionType>());
668668
669669 // Functions don't have capability so we can simply add them.
670- if (bindingTy->is <FunctionType>())
671- updatedBindings.insert (binding);
670+ if (auto *fnType = bindingTy->getAs <FunctionType>()) {
671+ updatedBindings.insert (binding.withType (fnType));
672+ }
672673 }
673674
674675 // 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() {
304304 // expected-error@-1 {{cannot use value of type 'A' as a key path subscript index; argument must be a key path}}
305305 }
306306}
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