File tree Expand file tree Collapse file tree 4 files changed +16
-1
lines changed Expand file tree Collapse file tree 4 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 181
181
Return a tuple `(filename,line)` giving the location of a generic `Function` definition.
182
182
"""
183
183
functionloc (@nospecialize (f), @nospecialize (types)) = functionloc (which (f,types))
184
+ functionloc (@nospecialize (argtypes:: Union{Tuple, Type{<:Tuple}} )) = functionloc (which (argtypes))
184
185
185
186
function functionloc (@nospecialize (f))
186
187
mt = methods (f)
Original file line number Diff line number Diff line change @@ -960,6 +960,7 @@ Returns the method that would be called by the given type signature (as a tuple
960
960
function which (@nospecialize (tt#= ::Type=# ))
961
961
return _which (tt). method
962
962
end
963
+ which (@nospecialize (argtypes:: Tuple )) = which (to_tuple_type (argtypes))
963
964
964
965
"""
965
966
which(module, symbol)
Original file line number Diff line number Diff line change @@ -269,7 +269,8 @@ function edit(@nospecialize f)
269
269
end
270
270
edit (m:: Method ) = edit (functionloc (m)... )
271
271
edit (@nospecialize (f), idx:: Integer ) = edit (methods (f). ms[idx])
272
- edit (f, t) = (@nospecialize ; edit (functionloc (f, t)... ))
272
+ edit (f, t) = (@nospecialize ; edit (functionloc (f, t)... ))
273
+ edit (@nospecialize argtypes:: Union{Tuple, Type{<:Tuple}} ) = edit (functionloc (argtypes)... )
273
274
edit (file:: Nothing , line:: Integer ) = error (" could not find source file for function" )
274
275
edit (m:: Module ) = edit (pathof (m))
275
276
Original file line number Diff line number Diff line change @@ -329,6 +329,18 @@ catch err13464
329
329
@test startswith (err13464. msg, " expression is not a function call" )
330
330
end
331
331
332
+ @testset " Single-argument forms" begin
333
+ a = which (+ , (Int, Int))
334
+ b = which ((typeof (+ ), Int, Int))
335
+ c = which (Tuple{typeof (+ ), Int, Int})
336
+ @test a == b == c
337
+
338
+ a = functionloc (+ , (Int, Int))
339
+ b = functionloc ((typeof (+ ), Int, Int))
340
+ c = functionloc (Tuple{typeof (+ ), Int, Int})
341
+ @test a == b == c
342
+ end
343
+
332
344
# PR 57909
333
345
@testset " Support for type annotations as arguments" begin
334
346
@test (@which (:: Vector{Int} )[:: Int ]). name === :getindex
You can’t perform that action at this time.
0 commit comments