InteractiveUtils: Fully support broadcasting expressions for code introspection macros (#58349)
This PR includes a fix and a feature for code introspection macros
(`@code_typed`, `@code_llvm` and friends *but not* `@which`, `@edit`,
etc):
- Fixes a bug for expressions of the form `f.(x; y = 3)`, for which
keyword arguments were not properly handled and led to an internal
error.
- Adds support for broadcasting assignments of the form `x .= f(y)`, `x
.<<= f.(y, z)`, etc.
The way this was (and still is) implemented is by constructing a
temporary function, `f(x1, x2, x3, ...) = <body>` and feeding that to
code introspection functions. This trick doesn't apply to `@which` and
`@edit`, which need to map to a single function call (we could arguably
choose to target `materialize`/`materialize!`, but this behavior could
be a bit surprising and difficult to support).
The switch differentiating the families of macro
`@code_typed`/`@code_llvm` and `@which`/`@edit` etc was further exposed
as an additional argument to `gen_call_with_extracted_types` and
`gen_call_with_extracted_types_and_kwargs`, which default to the
previous behavior (differentiating them based on whether their name
starts with `code_`). The intent is to allow other macros such as
`Cthulhu.@descend` to register themselves as code introspection macros.
Quick tests indicate that it works as intended, e.g. with this PR
Cthulhu supports `@descend [1, 2] .+= [2, 3]` (or equivalently, as added
in #57909, `@descend ::Vector{Int} .+= ::Vector{Int}`).
I originally just went for the fix, and after some refactoring I
realized the feature was very straightforward to implement.