Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,25 @@ function is_func_expr(@nospecialize(ex), meth::Method)
if !(isa(fname, Symbol) && is_gensym(fname)) && !isexpr(fname, :$)
if fname === :Type && isexpr(ex.args[1], :where) && isexpr(callex.args[1], :(::)) && isexpr(callex.args[1].args[end], :curly)
Tsym = callex.args[1].args[end].args[2]
for wheretyp in ex.args[1].args[2:end]
@assert isexpr(wheretyp, :(<:))
if Tsym == wheretyp.args[1]
fname = wheretyp.args[2]
break
whereex = ex.args[1]
while true
found = false
for wheretyp in whereex.args[2:end]
isexpr(wheretyp, :(<:)) || continue
if Tsym == wheretyp.args[1]
fname = wheretyp.args[2]
found = true
break
end
end
found && break
whereex = whereex.args[1]
end
end
# match the function name
if isexpr(fname, :curly)
fname = fname.args[1]
end
fname === strip_gensym(meth.name) || return false
end
exargs = callex.args[2:end]
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
if !isdefined(Main, :Revise)
@test definition(String, only(methods(wrongline))) === nothing
end

# Nested `where`s
m = @which Parametric{2}(5)
src, line = definition(String, m)
@test occursin("::Type{P}", src)
@test line == 148
end

@testset "With Revise" begin
Expand Down
4 changes: 4 additions & 0 deletions test/script.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,7 @@ end

wrongline() = 1 # for use testing #124
only(methods(wrongline)).line = 9999 # unclear how it happened in the wild, but this at least catches the problem

# Nested `where`s
struct Parametric{N} end
(::Type{P})(x::Int) where P<:Parametric{N} where N = P()