Skip to content

Commit b24014a

Browse files
authored
InteractiveUtils: Support callable objects as functions in introspection macros (#58905)
Follow-up to the follow-up #57911, building on the changes to introspection functions to support signature tuples being provided as a single argument. This enables support for calls of the form ```julia @code_typed (::Returns{Int})(1) @code_llvm (::Base.Fix2{typeof(+), Float64})(::Int) ``` by providing an extra `use_signature_tuple::Bool = false` parameter in `gen_call_with_extracted_types`. Setting this parameter to true changes the code generation from `$fcn(f, Tuple{argtypes...})` to `$fcn(Tuple{f, argtypes...})` (where `$fcn` can be e.g. `code_typed`, `code_llvm` etc).
1 parent 566ee44 commit b24014a

File tree

3 files changed

+335
-153
lines changed

3 files changed

+335
-153
lines changed

doc/src/base/reflection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ the unquoted and interpolated expression ([`Expr`](@ref)) form for a given macro
8585
`quote` the expression block itself (otherwise, the macro will be evaluated and the result will
8686
be passed instead!). For example:
8787

88-
```jldoctest; setup = :(using InteractiveUtils)
89-
julia> InteractiveUtils.macroexpand(@__MODULE__, :(@edit println("")) )
90-
:(InteractiveUtils.edit(println, InteractiveUtils.Tuple{(InteractiveUtils.Core).Typeof("")}))
88+
```jldoctest
89+
julia> macroexpand(@__MODULE__, :(@invoke identity(1::Int)))
90+
:(Core.invoke(identity, Base.Tuple{Int}, 1))
9191
```
9292

9393
The functions `Base.Meta.show_sexpr` and [`dump`](@ref) are used to display S-expr style views

0 commit comments

Comments
 (0)