Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix functionality and tests on nightly #90

Merged
merged 1 commit into from
Oct 4, 2020
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
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