File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1932,6 +1932,11 @@ func _modifyAtWritableKeyPath_impl<Root, Value>(
19321932 root: inout Root ,
19331933 keyPath: WritableKeyPath < Root , Value >
19341934) -> ( UnsafeMutablePointer < Value > , AnyObject ? ) {
1935+ if type ( of: keyPath) . kind == . reference {
1936+ return _modifyAtReferenceWritableKeyPath_impl ( root: root,
1937+ keyPath: _unsafeUncheckedDowncast ( keyPath,
1938+ to: ReferenceWritableKeyPath< Root, Value> . self ) )
1939+ }
19351940 return keyPath. _projectMutableAddress ( from: & root)
19361941}
19371942
Original file line number Diff line number Diff line change @@ -1041,6 +1041,16 @@ keyPath.test("ReferenceWritableKeyPath statically typed as WritableKeyPath") {
10411041 expectEqual ( outer [ keyPath: upcastKeyPath] , 43 )
10421042 outer [ keyPath: upcastKeyPath] = 44
10431043 expectEqual ( outer [ keyPath: upcastKeyPath] , 44 )
1044+
1045+ func setWithInout< T> ( _ lhs: inout T , _ rhs: T ) { lhs = rhs }
1046+
1047+ expectEqual ( outer [ keyPath: keyPath] , 44 )
1048+ setWithInout ( & outer[ keyPath: keyPath] , 45 ) ;
1049+ expectEqual ( outer [ keyPath: keyPath] , 45 )
1050+
1051+ expectEqual ( outer [ keyPath: upcastKeyPath] , 45 )
1052+ setWithInout ( & outer[ keyPath: upcastKeyPath] , 46 )
1053+ expectEqual ( outer [ keyPath: upcastKeyPath] , 46 )
10441054}
10451055
10461056runAllTests ( )
You can’t perform that action at this time.
0 commit comments