mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user