Sema: Sometimes allow universally unavailable declarations to be referenced.

In implicit contexts that are universally unavailable, allow writable key paths
to be formed to properties with setters that are also marked as universally
unavailable. This fixes a regression from the previous commit where the code
synthesized for `@Observable` properties in universally unavailable classes was
rejected by the availability checker.
This commit is contained in:
Allan Shortlidge
2025-07-15 14:08:55 -07:00
parent 4076fa6b2e
commit 99380bf00f
6 changed files with 61 additions and 7 deletions

View File

@@ -186,3 +186,36 @@ func unavailableOnMacOSFunc(
@WrappedValueUnavailableOnMacOS var unavailableWrappedValueLocal = S()
@WrappedValueAvailable51 var wrappedValueAavailable51 = S()
}
@propertyWrapper
struct Observable<Value> {
private var stored: Value
init(wrappedValue: Value) {
self.stored = wrappedValue
}
var wrappedValue: Value {
get { fatalError() }
set { fatalError() }
}
static subscript<EnclosingSelf>(
_enclosingInstance observed: EnclosingSelf,
wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>,
storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Self>
) -> Value {
get { fatalError() }
set { fatalError() }
}
}
@available(macOS, unavailable)
class UnavailableOnMacOSObserved {
@Observable var observedProperty = 17
}
@available(*, unavailable)
class UniversallyUnavailableObserved {
@Observable var observedProperty = 17
}