The attribute makes the declaration unavailable from the perspective of clients
of the module's public interface and was creating a loophole that admitted
inappropriate unavailability.
Marking an observer unavailable (or potentially unavailable) has no effect
since the compiler emits calls to them unconditionally.
Resolves rdar://80337141.
The changes in https://github.com/apple/swift/pull/72410 caused a regression
when checking availability in the following example:
```
// warning: Setter for 'hasDeprecatedSetter' is deprecated: ...
x[y.hasDeprecatedSetter] = ...
```
The result of `y.hasDeprecatedSetter` is being passed as an argument to the
subscript and its setter will not be called. To fix this,
`ExprAvailabilityWalker` now consistently creates a new default
`MemberAccessContext` when descending into any `Argument`, since the access
context for the expressions surrounding the call should not affect the
arguments to the call.
Additionally, `MemberAccessContext` has been refactored to better model context
state transitions. Instead of only modeling which accessors will be called, the
enumeration's members now reflect the possible states that
`ExprAvailabilityWalker` can be in during its traversal. This should hopefully
make it easier to follow the logic for traversal of `LoadExpr`s and arguments.
Resolves rdar://130487998.
This fixes a regression from https://github.com/swiftlang/swift/pull/72369.
The compiler now incorrectly diagnoses use of an unavailable setter in this
example:
```
func increaseBrightness(in window: UIWindow) {
// warning: setter for 'screen' was deprecated in iOS 13.0
window.screen.brightness = 1.0
}
```
While the setter is deprecated, it would not be called in the generated code
since `screen` is a reference type and there is no writeback through the setter
for `screen` after setting `brightness`.
Resolves rdar://129679658
In the following example, the writeback via the property `b` should be
diagnosed since `b`'s setter is unavailable:
```
struct A {
struct B {
var x: Int = 0
}
private var _b: B = B()
var b: B {
get { _b }
@available(*, unavailable) set {
_b = newValue
}
}
}
var a = A()
a.b.x = 1
```
Resolves rdar://125019717
Fixes the missing diagnostic about the availability of the setter of `x` in the
following example:
```
struct S {
var x: Int {
get { 0 }
@available(*, unavailable) set {}
}
}
var s = S()
s[keyPath: \.x] = 1
```
Resolves rdar://124977727
The recent deprecation of the set accessor for `CommandLine.arguments` exposed
a bug in availability checking:
```
for arg in CommandLine.arguments[1...] {
╰─ warning: setter for 'arguments' is deprecated: ...
```
The parser generates an `InOutExpr` in the AST for the subscript access in the
code above and the availabilty checker was unconditionally diagnosing set
accessors for `InOutExprs`, resulting in spurious availability warnings for
read-only accesses of properties. The fix is to check whether there is an
enclosing `LoadExpr` in the AST and only diagnose the getter accessor in that
case.
Resolves rdar://124566405
This test documents the current behavior of availability diagnostics for
generalized accessors, including some bugs which have been called out as
FIXMEs.