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

Check for piracy against Base by default #101

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 5 additions & 2 deletions src/piracy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ function all_methods!(
result
end

function all_methods(mod::Module; filter_default::Bool = true)
function all_methods(mod::Module; filter_default::Bool = true, include_base::Bool = true)
result = Method[]
done_callables = Base.IdSet()
walkmodules(mod) do mod
all_methods!(mod, done_callables, result, filter_default)
end
return result
# Base may not be reachable from walkmodules, but needs to be checked,
# since it's one of the most common targets of piracy
include_base && all_methods!(Base, done_callables, result, filter_default)
result
end

##################################
Expand Down
4 changes: 0 additions & 4 deletions test/test_piracy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ Base.findlast(::Val{:foo}, x::Int) = x + 1
Base.findfirst(::Set{Vector{Char}}, ::Int) = 1
Base.findfirst(::Union{Foo,Bar{Set{Unsigned}},UInt}, ::Tuple{Vararg{String}}) = 1
Base.findfirst(::AbstractChar, ::Set{T}) where {Int <: T <: Integer} = 1

# Assign them names in this module so they can be found by all_methods
x = Base.findfirst
y = Base.findlast
end # PiracyModule

using Aqua: Piracy
Expand Down