Skip to content

Commit 84a8d7c

Browse files
authored
migrate to CodeTracking v3 (#139)
1 parent ad4d0ba commit 84a8d7c

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
99
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
1010

1111
[compat]
12-
CodeTracking = "2"
12+
CodeTracking = "3"
1313
Compiler = "0.1"
1414
JuliaInterpreter = "0.10"
1515
julia = "1.10"

src/signatures.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,13 @@ function methoddef!(interp::Interpreter, signatures::Vector{MethodInfoKey}, fram
551551
meth = whichtt(sigt, mt)
552552
end
553553
if isa(meth, Method) && (meth.sig <: sigt && sigt <: meth.sig)
554-
push!(signatures, mt => meth.sig)
554+
push!(signatures, MethodInfoKey(mt, meth.sig))
555555
else
556556
if arg1 === false || arg1 === nothing || isa(mt, MethodTable)
557557
# If it's anonymous and not defined, define it
558558
pc = step_expr!(interp, frame, stmt, true)
559559
meth = whichtt(sigt, mt)
560-
isa(meth, Method) && push!(signatures, mt => meth.sig)
560+
isa(meth, Method) && push!(signatures, MethodInfoKey(mt, meth.sig))
561561
return pc, pc3
562562
else
563563
# guard against busted lookup, e.g., https://github.com/JuliaLang/julia/issues/31112
@@ -614,7 +614,7 @@ function methoddef!(interp::Interpreter, signatures::Vector{MethodInfoKey}, fram
614614
frame.pc = pc
615615
pc = define ? step_expr!(interp, frame, stmt, true) : next_or_nothing!(interp, frame)
616616
meth = whichtt(sigt, mt)
617-
isa(meth, Method) && push!(signatures, mt => meth.sig) # inner methods are not visible
617+
isa(meth, Method) && push!(signatures, MethodInfoKey(mt, meth.sig)) # inner methods are not visible
618618
name === name3 && return pc, pc3 # if this was an inner method we should keep going
619619
stmt = pc_expr(frame, pc) # there *should* be more statements in this frame
620620
end

test/signatures.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
9797

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

102102
nms = names(Lowering; all=true)
103103
modeval, modinclude = getfield(Lowering, :eval), getfield(Lowering, :include)
@@ -107,7 +107,7 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
107107
isa(f, Base.Callable) || continue
108108
(f === modeval || f === modinclude) && continue
109109
for m in methods(f)
110-
if (nothing => m.sig) signatures
110+
if MethodInfoKey(nothing, m.sig) signatures
111111
push!(failed, m.sig)
112112
end
113113
end
@@ -240,8 +240,8 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
240240
if !LoweredCodeUtils.ismethod(stmt)
241241
pc = JuliaInterpreter.next_until!(LoweredCodeUtils.ismethod, frame, true)
242242
end
243-
pc, pc3 = methoddef!(signatures, frame; define=false) # this tests that the return isn't `nothing`
244-
pc, pc3 = methoddef!(signatures, frame; define=false)
243+
pc, _ = methoddef!(signatures, frame; define=false) # this tests that the return isn't `nothing`
244+
pc, _ = methoddef!(signatures, frame; define=false)
245245
@test length(signatures) == 2 # both the GeneratedFunctionStub and the main method
246246

247247
# With anonymous functions in signatures
@@ -307,13 +307,13 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
307307
frame = Frame(Lowering, ex)
308308
rename_framemethods!(frame)
309309
empty!(signatures)
310-
pc, pc3 = methoddef!(signatures, frame; define=false)
310+
pc, _ = methoddef!(signatures, frame; define=false)
311311
@test pc < length(frame.framecode.src.code)
312312
kw2sig = Tuple{typeof(Lowering.keywrd2), Any}
313-
@test kw2sig signatures
313+
@test MethodInfoKey(nothing, kw2sig) signatures
314314
pc = methoddefs!(signatures, frame; define=false)
315315
@test pc === nothing
316-
@test (nothing => kw2sig) signatures
316+
@test MethodInfoKey(nothing, kw2sig) signatures
317317

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

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

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

394394
# Undefined names
@@ -515,23 +515,23 @@ end
515515
ex = :(foo(x) = "foo")
516516
Core.eval(ExternalMT, ex)
517517
frame = Frame(ExternalMT, ex)
518-
pc = methoddefs!(signatures, frame; define = false)
518+
methoddefs!(signatures, frame; define = false)
519519
@test length(signatures) == 1
520520
(mt, sig) = pop!(signatures)
521521
@test (mt, sig) === (nothing, Tuple{typeof(ExternalMT.foo), Any})
522522

523523
ex = :(Base.Experimental.@overlay method_table foo(x) = "overlayed foo")
524524
Core.eval(ExternalMT, ex)
525525
frame = Frame(ExternalMT, ex)
526-
pc = methoddefs!(signatures, frame; define = false)
526+
methoddefs!(signatures, frame; define = false)
527527
@test length(signatures) == 1
528528
(mt, sig) = pop!(signatures)
529529
@test (mt, sig) === (ExternalMT.method_table, Tuple{typeof(ExternalMT.foo), Any})
530530

531531
ex = :(@overlay foo(x::Int64) = "overlayed foo, second edition")
532532
Core.eval(ExternalMT, ex)
533533
frame = Frame(ExternalMT, ex)
534-
pc = methoddefs!(signatures, frame; define = false)
534+
methoddefs!(signatures, frame; define = false)
535535
@test length(signatures) == 1
536536
(mt, sig) = pop!(signatures)
537537
@test (mt, sig) === (ExternalMT.method_table, Tuple{typeof(ExternalMT.foo), Int64})

0 commit comments

Comments
 (0)