From 7534cd0c619bb7909fb25ec8b190b09ab952a66e Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 4 Oct 2020 12:14:54 -0500 Subject: [PATCH] Fix functionality and tests on nightly --- src/reflection.jl | 3 +++ test/runtests.jl | 32 ++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/reflection.jl b/src/reflection.jl index c145a45d..ee22b6ae 100644 --- a/src/reflection.jl +++ b/src/reflection.jl @@ -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...} diff --git a/test/runtests.jl b/test/runtests.jl index 73510163..7f2883ec 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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) @@ -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