Skip to content

Commit

Permalink
Fix functionality and tests on nightly (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy authored Oct 4, 2020
1 parent f71e27a commit b3dc48b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ function find_callsites(CI::Core.CodeInfo, mi::Core.MethodInstance, slottypes; p
if isa(ft, Const)
ft = ft.val
end
if isa(ft, Function)
ft = typeof(ft)
end
argTs = argextype(c.args[arg_base + 3], CI, sptypes, slottypes)
if isa(argTs, Const)
sig = Tuple{widenconst(ft), argTs.val.parameters...}
Expand Down
32 changes: 20 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,16 @@ end
callf(f::F, x) where F = f(x)
let callsites = find_callsites_by_ftt(callf, Tuple{Union{typeof(sin), typeof(cos)}, Float64})
@test !isempty(callsites)
@test first(callsites).info isa Cthulhu.MultiCallInfo
callinfos = first(callsites).info.callinfos
@test !isempty(callinfos)
mis = map(Cthulhu.get_mi, callinfos)
@test any(mi->mi.def.name == :cos, mis)
@test any(mi->mi.def.name == :sin, mis)
if length(callsites) == 1
@test first(callsites).info isa Cthulhu.MultiCallInfo
callinfos = first(callsites).info.callinfos
@test !isempty(callinfos)
mis = map(Cthulhu.get_mi, callinfos)
@test any(mi->mi.def.name == :cos, mis)
@test any(mi->mi.def.name == :sin, mis)
else
@test all(cs->cs.info isa Cthulhu.MICallInfo, callsites)
end
end

function toggler(toggle)
Expand All @@ -121,12 +125,16 @@ function toggler(toggle)
end
let callsites = find_callsites_by_ftt(toggler, Tuple{Bool})
@test !isempty(callsites)
@test first(callsites).info isa Cthulhu.MultiCallInfo
callinfos = first(callsites).info.callinfos
@test !isempty(callinfos)
mis = map(Cthulhu.get_mi, callinfos)
@test any(mi->mi.def.name == :cos, mis)
@test any(mi->mi.def.name == :sin, mis)
if length(callsites) == 1
@test first(callsites).info isa Cthulhu.MultiCallInfo
callinfos = first(callsites).info.callinfos
@test !isempty(callinfos)
mis = map(Cthulhu.get_mi, callinfos)
@test any(mi->mi.def.name == :cos, mis)
@test any(mi->mi.def.name == :sin, mis)
else
@test all(cs->cs.info isa Cthulhu.MICallInfo, callsites)
end
end

@testset "warntype variables" begin
Expand Down

0 comments on commit b3dc48b

Please sign in to comment.