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
16 changes: 16 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,19 @@ function split2(str, on)
return (SubString(str, firstindex(str), prevind(str, first(i))),
SubString(str, nextind(str, last(i))))
end

function methods_with_generators(m::Module)
meths = Method[]
for name in names(m; all=true)
isdefined(m, name) || continue
f = getfield(m, name)
if isa(f, Function)
for method in methods(f)
if isdefined(method, :generator)
push!(meths, method)
end
end
end
end
return meths
end
11 changes: 11 additions & 0 deletions test/snoop_inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,10 @@ end
@test SnoopCompile.itrigs_higherorder_demo() isa SnoopCompile.InferenceTimingNode
end

# must be outside @testset
@generated gen407(x) = x <: Integer ? :(x^2) : :(-x)
callgen407(x) = gen407(x)

include("testmodules/SnoopBench.jl")
@testset "parcel" begin
a = SnoopBench.A()
Expand Down Expand Up @@ -784,6 +788,13 @@ include("testmodules/SnoopBench.jl")
g197(@nospecialize(x::Vector{<:Number})) = f197(x)
g197([1,2,3])
@test SnoopCompile.get_reprs([(rand(), mi) for mi in methodinstances(f197)])[1] isa AbstractSet

# issue #407
tinf = @snoop_inference callgen407(3)
tinft = flatten(tinf; tmin=0)
tmi = [(inclusive(inft), Core.MethodInstance(inft)) for inft in tinft]
strs, twritten = SnoopCompile.get_reprs(tmi; tmin=0)
@test any(str -> occursin("which(gen407,(Any,)).generator", str), strs)
end

@testset "Specialization" begin
Expand Down
Loading