mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Allowing forming WritableKeyPath to read-only value in Swift 3/4.
We inadvertantly allowed this in the past, so continue to do so when compiling in Swift 3/4 mode to avoid suddenly breaking existing code. The diagnostic here is pretty bad, and I've opened issues for that as well as providing some kind of deprecation warning for this so that even under Swift 3/4 mode we alert users that this is unsupported. rdar://problem/39802797
This commit is contained in:
@@ -514,8 +514,9 @@ struct VisibilityTesting {
|
||||
toHaveType: Exactly<WritableKeyPath<VisibilityTesting, Int>>.self)
|
||||
expect(&yRef,
|
||||
toHaveType: Exactly<WritableKeyPath<VisibilityTesting, Int>>.self)
|
||||
// Allow WritableKeyPath for Swift 3/4 only.
|
||||
expect(&zRef,
|
||||
toHaveType: Exactly<KeyPath<VisibilityTesting, Int>>.self)
|
||||
toHaveType: Exactly<WritableKeyPath<VisibilityTesting, Int>>.self)
|
||||
}
|
||||
|
||||
func inPrivateContext() {
|
||||
@@ -536,8 +537,9 @@ struct VisibilityTesting2 {
|
||||
var xRef = \VisibilityTesting.x
|
||||
var yRef = \VisibilityTesting.y
|
||||
var zRef = \VisibilityTesting.z
|
||||
// Allow WritableKeyPath for Swift 3/4 only.
|
||||
expect(&xRef,
|
||||
toHaveType: Exactly<KeyPath<VisibilityTesting, Int>>.self)
|
||||
toHaveType: Exactly<WritableKeyPath<VisibilityTesting, Int>>.self)
|
||||
expect(&yRef,
|
||||
toHaveType: Exactly<WritableKeyPath<VisibilityTesting, Int>>.self)
|
||||
expect(&zRef,
|
||||
|
||||
Reference in New Issue
Block a user