* [Observation] Exclude generic class types from pre-caching their keypaths
* Account for multiple nesting levels of generics for observation cached keypaths
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.
Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).
All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.
There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
original source location of a macro expansion when walking up the ancestor
list.
The original source range of a macro expansion buffer contains the entire
range of the code that is replaced by the expansion. In some cases, the
original code is type checked, so ASTScope needs to represent both the
original code and the macro-expanded code in the scope tree.
For accessor macros, the original code -- the initializer expression of
the property -- is type checked, but not before macro expansion, so
unqualified lookup must deal with the scope tree for the initializer and
the expanded accessors. The accessors are inserted in the tree after the
initializer scope, but the `isBeforeInSource` was using the start location
of the original source range for macro expansions, so the accessor scopes
were incorrectly considered to be ordered before a source location in the
initializer expression, which caused unqualified lookup of local variables
within the initializer to fail.
This fixes a recent regression introduced in the changes to make
TRC construction lazier in b33a71d64f.
Calling VarDecl::hasInitialValue() can ask for attached property
wrappers, which can trigger macro expansion. However, macro
expansion can result in TRC construction, causing a cycle.
Instead, just always build a lazy TRC for the initializer. It
might not be needed, but it's safest to not ask anything of the
VarDecl at all.
Fixes rdar://118452948.
Use this to define the macro location rather than the "host" dir (which
is actually for the build and not the host). Furthermore, on Windows,
the build dir is /usr/lib/swift as the host content is in the SDK.
This prepares the tests for Windows.
The checking of the accessors generated by a macro against the
documented set of accessors for the macro is slightly too strict and
produces misleading error messages. Make the check slightly looser in
the case where an observer-producing macro (such as
`@ObservationIgnored`) is applied to a computed property. Here, we
would diagnose that the observer did not in fact produce any
observers, even though it couldn't have: computed properties don't get
observers. Remove the diagnostic in this case.
While here, add some tests and improve the wording of diagnostics a
bit.
Fixes rdar://113710199.
Add a test case for Observable types that are extended from other
source files. Prior to the recent changes to make
`TypeRefinementContext` more lazy, this would trigger circular
references through the `TypeRefinementContextBuilder`.
Finishes rdar://112079160.
* [Observation] Forward availability and defines to extensions
* Simplify availability slightly from review feedback
* Simplify availability for extensions to use `.with`
* [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.
* [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
The macro tests were all using "REQUIRES: OS=macosx" as a proxy for
"have the Swift Swift parser". There was an existing feature for this,
but it was just checking whether the path was passed through. Fix that
to use the same variable as in CMake.
Also remove all extraneous `-I` and `-L` to the host libs in the target
invocations.
* [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.