mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Stdlib] Fix _swift_modifyAtWritableKeyPath_impl to check for ReferenceWritableKeyPaths.
Call through to _swift_modifyAtReferenceWritableKeyPath_impl in that case. This fixes an assertion failure (or worse) when upcasting a ReferenceWritableKeyPath and then using subscript(keyPath:) to modify a value with it. rdar://74191390
This commit is contained in:
@@ -1041,6 +1041,16 @@ keyPath.test("ReferenceWritableKeyPath statically typed as WritableKeyPath") {
|
||||
expectEqual(outer[keyPath: upcastKeyPath], 43)
|
||||
outer[keyPath: upcastKeyPath] = 44
|
||||
expectEqual(outer[keyPath: upcastKeyPath], 44)
|
||||
|
||||
func setWithInout<T>(_ lhs: inout T, _ rhs: T) { lhs = rhs }
|
||||
|
||||
expectEqual(outer[keyPath: keyPath], 44)
|
||||
setWithInout(&outer[keyPath: keyPath], 45);
|
||||
expectEqual(outer[keyPath: keyPath], 45)
|
||||
|
||||
expectEqual(outer[keyPath: upcastKeyPath], 45)
|
||||
setWithInout(&outer[keyPath: upcastKeyPath], 46)
|
||||
expectEqual(outer[keyPath: upcastKeyPath], 46)
|
||||
}
|
||||
|
||||
runAllTests()
|
||||
|
||||
Reference in New Issue
Block a user