@@ -180,14 +180,10 @@ func testKeyPath(sub: Sub, optSub: OptSub,
180180 var m = [ \A . property, \A . [ sub] , \A . optProperty!]
181181 expect ( & m, toHaveType: Exactly < [ PartialKeyPath < A > ] > . self)
182182
183- // \.optProperty returns an optional of Prop and `\.[sub]` returns `A`
184- // expected-error@+2 {{key path value type 'Prop?' cannot be converted to contextual type 'Prop'}}
185- // expected-error@+1 {{key path value type 'A' cannot be converted to contextual type 'Prop'}}
183+ // \.optProperty returns an optional of Prop and `\.[sub]` returns `A`, all this unifies into `[PartialKeyPath<A>]`
186184 var n = [ \A . property, \. optProperty, \. [ sub] , \. optProperty!]
187185 expect ( & n, toHaveType: Exactly < [ PartialKeyPath < A > ] > . self)
188186
189- // FIXME: shouldn't be ambiguous
190- // expected-error@+1{{ambiguous}}
191187 let _: [ PartialKeyPath < A > ] = [ \. property, \. optProperty, \. [ sub] , \. optProperty!]
192188
193189 var o = [ \A . property, \C < A > . value]
@@ -1122,6 +1118,29 @@ func test_kp_as_function_mismatch() {
11221118
11231119}
11241120
1121+ func test_partial_keypath_inference( ) {
1122+ // rdar://problem/34144827
1123+
1124+ struct S { var i : Int = 0 }
1125+ enum E { case A( pkp: PartialKeyPath < S > ) }
1126+
1127+ _ = E . A ( pkp: \. i) // Ok
1128+
1129+ // rdar://problem/36472188
1130+
1131+ class ThePath {
1132+ var isWinding : Bool ?
1133+ }
1134+
1135+ func walk< T> ( aPath: T , forKey: PartialKeyPath < T > ) { }
1136+ func walkThePath( aPath: ThePath , forKey: PartialKeyPath < ThePath > ) { }
1137+
1138+ func test( path: ThePath ) {
1139+ walkThePath ( aPath: path, forKey: \. isWinding) // Ok
1140+ walk ( aPath: path, forKey: \. isWinding) // Ok
1141+ }
1142+ }
1143+
11251144// SR-14499
11261145struct SR14499_A { }
11271146struct SR14499_B { }
0 commit comments