The pthread APIs on FreeBSD do not include nullability APIs so the
pthread mutex APIs are imported as pointers to optional values.
Other platforms include nullability APIs and import the pthread APIs as
pointers to the mutex. Splitting the locking primitive type based on the
OS.
Fixes: rdar://150880976
The runtime functions for locking end up referencing a symbol that is
not publicly emitted. This leads to broken linux builds.
Since that interface is not public and does not offer a stable mechanism
and Synchronization cannot be used (due to it being a higher deployment
target) instead it has to revert to implementing locking from scratch
for all platforms.
This is mostly replicated from the swift-async-algorithms package and
should be usable enough to accomplish the goals of this module.
Resolves rdar://150060874
* [Observation] ensure event triggers on deinitialziation passes as if all properties that are being observed have changed (for weak storage)
* Add missing deinitialize method for synthetically triggering willSet
* Correct the weak location for tests
* Correct the test to actually test the deinitialization willSet trigger instead of testing weak value deinitialization time
* Refine the tests for deinit triggers to more tightly trigger deinitialization and weak references
* Correct missing trailing closure on deinit replacement
* Ensure all potential ids are triggered at the deinitialization edge trigger
This entails passing a linker flags to Apple linkers when the standard
library is not meant for inclusion in such cache.
For this to have effect on every library, propagate link flags when
building _Concurrency and Observation.
This is needed for Apple internal configurations.
Addresses rdar://120653968
* [Observation] Correct tracking such that recursive but disperate changes can be tracked without crashing
* [Observation] Adjust the SPI interface for tracking to support deferred cancellation of events and handle both willSet and didSet events
This adopts `@attached(peer)` for generating an observable type's
underscored storage when expanding the `@ObservationTracked` macro,
instead of using `arbitrary` with the member macro on the
observable type.
With support for redundant conformance declarations via macros,
the `Observable` protocol can be a non-marker protocol, which
provides more flexibility for evolution in the future.
rdar://111463883
This change also switches to the new ExtensionMacro protocol,
the requirement for which includes information about whether the
conformance to the Observable protocol has already been added, either
in the declaration or in a superclass to the macro-attributed type.
This allows the @Observable macro to be applied to subclasses of
observable types without redundant-conformance errors.
* Make ObservationRegistrar Codable/Hashable
These conformances enable automatic Codable synthesis for Observable
types, and smooth the runway for structs being supported by the
Observable macro in the future.
* Limit Observable macro to classes
This removes the ability for the Observable macro to apply to structs,
and adds diagnostic tests for the three disallowed declaration kinds.
The review of SE-0395 is down to small details at this point that won't
affect the overall shape of the API much. Rename the model in
anticipation of that.
Now that we've made accessor macro expansion more lazy, ensure that
when querying for init accessors (e.g., to build a memberwise
initializer), we also expand any accessor macros that might produce an
init accessor.
This is a partial step toward the real goal, which is that
`AbstractStorageDecl::getAccessor()` should lazily expand macros if
needed.
Update the Observable macro to document that it produces an `init`
accessor.
The `hasStorage()` computation is used in many places to determine the
signatures of other declarations. It currently needs to expand accessor
macros, which causes a number of cyclic references. Provide a
simplified request to determine `hasStorage` without expanding or
resolving macros, breaking a common pattern of cycles when using
macros.
Fixes rdar://109668383.
* [Observation] Transition to peer macros instead of arbitrary members
* [Observation] Lift the initializer requirement by utilizing init accessors for fully formed definite initialization
* [Observation] Gate enabling of peer macros by flag
* [Observation] Enable feature for InitAccessors in the observation tests
* [Observation] Add tests to validate memberwise and definite initialization
* [Observation] Change visibility of observation runtime functions to be hidden
* [Observation] Update API requirements for Observable AsyncSequence names and alter the behavior of value emissions to be based upon transactionality
* [Observation] Slight naming alteration of isolation -> isolatedTo
Note: This re-enables the previously disabled tests since the implementation should be considerably more robust to hangs.
The dependency of the Observation library on the observation macro
plugin introduces a direct dependency of a target library on a host
library, (lib -> stdlib) that we'd like to avoid. Instead, make the
Swift frontend binary depend on the macro plugin libraries that we
build, so that it's the complete host-side stack.