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(
634634 assert (isKnownKeyPathType (bindingTy) || bindingTy->is <FunctionType>());
635635
636636 // 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+ }
639640 }
640641
641642 // 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