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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"

[compat]
CodeTracking = "2"
CodeTracking = "3"
Compiler = "0.1"
JuliaInterpreter = "0.10"
julia = "1.10"
Expand Down
6 changes: 3 additions & 3 deletions src/signatures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,13 @@ function methoddef!(interp::Interpreter, signatures::Vector{MethodInfoKey}, fram
meth = whichtt(sigt, mt)
end
if isa(meth, Method) && (meth.sig <: sigt && sigt <: meth.sig)
push!(signatures, mt => meth.sig)
push!(signatures, MethodInfoKey(mt, meth.sig))
else
if arg1 === false || arg1 === nothing || isa(mt, MethodTable)
# If it's anonymous and not defined, define it
pc = step_expr!(interp, frame, stmt, true)
meth = whichtt(sigt, mt)
isa(meth, Method) && push!(signatures, mt => meth.sig)
isa(meth, Method) && push!(signatures, MethodInfoKey(mt, meth.sig))
return pc, pc3
else
# guard against busted lookup, e.g., https://github.com/JuliaLang/julia/issues/31112
Expand Down Expand Up @@ -614,7 +614,7 @@ function methoddef!(interp::Interpreter, signatures::Vector{MethodInfoKey}, fram
frame.pc = pc
pc = define ? step_expr!(interp, frame, stmt, true) : next_or_nothing!(interp, frame)
meth = whichtt(sigt, mt)
isa(meth, Method) && push!(signatures, mt => meth.sig) # inner methods are not visible
isa(meth, Method) && push!(signatures, MethodInfoKey(mt, meth.sig)) # inner methods are not visible
name === name3 && return pc, pc3 # if this was an inner method we should keep going
stmt = pc_expr(frame, pc) # there *should* be more statements in this frame
end
Expand Down
26 changes: 13 additions & 13 deletions test/signatures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ bodymethtest5(x, y=Dict(1=>2)) = 5

# Manually add the signature for the Caller constructor, since that was defined
# outside of manual lowering
push!(signatures, nothing => Tuple{Type{Lowering.Caller}})
push!(signatures, MethodInfoKey(nothing, Tuple{Type{Lowering.Caller}}))

nms = names(Lowering; all=true)
modeval, modinclude = getfield(Lowering, :eval), getfield(Lowering, :include)
Expand All @@ -107,7 +107,7 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
isa(f, Base.Callable) || continue
(f === modeval || f === modinclude) && continue
for m in methods(f)
if (nothing => m.sig) ∉ signatures
if MethodInfoKey(nothing, m.sig) ∉ signatures
push!(failed, m.sig)
end
end
Expand Down Expand Up @@ -240,8 +240,8 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
if !LoweredCodeUtils.ismethod(stmt)
pc = JuliaInterpreter.next_until!(LoweredCodeUtils.ismethod, frame, true)
end
pc, pc3 = methoddef!(signatures, frame; define=false) # this tests that the return isn't `nothing`
pc, pc3 = methoddef!(signatures, frame; define=false)
pc, _ = methoddef!(signatures, frame; define=false) # this tests that the return isn't `nothing`
pc, _ = methoddef!(signatures, frame; define=false)
@test length(signatures) == 2 # both the GeneratedFunctionStub and the main method

# With anonymous functions in signatures
Expand Down Expand Up @@ -307,13 +307,13 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
frame = Frame(Lowering, ex)
rename_framemethods!(frame)
empty!(signatures)
pc, pc3 = methoddef!(signatures, frame; define=false)
pc, _ = methoddef!(signatures, frame; define=false)
@test pc < length(frame.framecode.src.code)
kw2sig = Tuple{typeof(Lowering.keywrd2), Any}
@test kw2sig ∉ signatures
@test MethodInfoKey(nothing, kw2sig) ∉ signatures
pc = methoddefs!(signatures, frame; define=false)
@test pc === nothing
@test (nothing => kw2sig) ∈ signatures
@test MethodInfoKey(nothing, kw2sig) ∈ signatures

# Module-scoping
ex = :(Base.@irrational π 3.14159265358979323846 pi)
Expand All @@ -339,7 +339,7 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
rename_framemethods!(frame)
empty!(signatures)
methoddefs!(signatures, frame; define=false)
@test (nothing => Tuple{typeof(Lowering.CustomMS)}) ∈ signatures
@test MethodInfoKey(nothing, Tuple{typeof(Lowering.CustomMS)}) ∈ signatures

# https://github.com/timholy/Revise.jl/issues/398
ex = quote
Expand Down Expand Up @@ -373,7 +373,7 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
frame = Frame(Lowering422, ex)
rename_framemethods!(frame)
pc = methoddefs!(signatures, frame; define=false)
@test typeof(Lowering422.fneg) ∈ Set(Base.unwrap_unionall(sig).parameters[1] for (mt, sig) in signatures)
@test typeof(Lowering422.fneg) ∈ Set(Base.unwrap_unionall(sig).parameters[1] for (_, sig) in signatures)

# Scoped names (https://github.com/timholy/Revise.jl/issues/568)
ex = :(f568() = -1)
Expand All @@ -388,7 +388,7 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
pc = JuliaInterpreter.step_expr!(frame, true)
end
pc = methoddef!(signatures, frame, pc; define=true)
@test (nothing => Tuple{typeof(Lowering.f568)}) ∈ signatures
@test MethodInfoKey(nothing, Tuple{typeof(Lowering.f568)}) ∈ signatures
@test Lowering.f568() == -2

# Undefined names
Expand Down Expand Up @@ -515,23 +515,23 @@ end
ex = :(foo(x) = "foo")
Core.eval(ExternalMT, ex)
frame = Frame(ExternalMT, ex)
pc = methoddefs!(signatures, frame; define = false)
methoddefs!(signatures, frame; define = false)
@test length(signatures) == 1
(mt, sig) = pop!(signatures)
@test (mt, sig) === (nothing, Tuple{typeof(ExternalMT.foo), Any})

ex = :(Base.Experimental.@overlay method_table foo(x) = "overlayed foo")
Core.eval(ExternalMT, ex)
frame = Frame(ExternalMT, ex)
pc = methoddefs!(signatures, frame; define = false)
methoddefs!(signatures, frame; define = false)
@test length(signatures) == 1
(mt, sig) = pop!(signatures)
@test (mt, sig) === (ExternalMT.method_table, Tuple{typeof(ExternalMT.foo), Any})

ex = :(@overlay foo(x::Int64) = "overlayed foo, second edition")
Core.eval(ExternalMT, ex)
frame = Frame(ExternalMT, ex)
pc = methoddefs!(signatures, frame; define = false)
methoddefs!(signatures, frame; define = false)
@test length(signatures) == 1
(mt, sig) = pop!(signatures)
@test (mt, sig) === (ExternalMT.method_table, Tuple{typeof(ExternalMT.foo), Int64})
Expand Down
Loading