File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -1331,6 +1331,14 @@ bool BindingSet::favoredOverConjunction(Constraint *conjunction) const {
13311331 }
13321332 }
13331333
1334+ // If key path capability is not yet determined it cannot be favored
1335+ // over a conjunction because:
1336+ // 1. There could be no other bindings and that would mean that
1337+ // key path would be selected even though it's not yet ready.
1338+ // 2. A conjunction could be the source of type context for the key path.
1339+ if (TypeVar->getImpl ().isKeyPathType () && isDelayed ())
1340+ return false ;
1341+
13341342 return true ;
13351343}
13361344
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift
2+
3+ // rdar://119055010 - greedy key path type assignment breaks keypath-to-function conversion
4+
5+ protocol Executable { }
6+
7+ final class Wrapper < Value> {
8+ func update< Return> ( _ work: ( inout Value ) throws -> Return ) rethrows -> Return {
9+ fatalError ( )
10+ }
11+ }
12+
13+ enum Lookup < Value> {
14+ func flatMap< T> ( _ transform: ( Value ) throws -> Lookup < T > ) rethrows -> Lookup < T > { fatalError ( ) }
15+ }
16+
17+ protocol Entry {
18+ }
19+
20+ extension Entry {
21+ var executable : Lookup < any Executable > {
22+ fatalError ( )
23+ }
24+ }
25+
26+ func lookup( ) -> Lookup < any Entry > {
27+ fatalError ( )
28+ }
29+
30+ struct Test {
31+ struct Data {
32+ }
33+
34+ let value = Wrapper < Data > ( )
35+
36+ func run( ) -> Lookup < any Executable > {
37+ value. update { data in
38+ let _ = 42
39+ return lookup ( )
40+ }
41+ . flatMap ( \. executable)
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments