@@ -1660,7 +1660,9 @@ function is_in_mods(m::Module, recursive::Bool, mods)
16601660end
16611661
16621662"""
1663- detect_ambiguities(mod1, mod2...; recursive=false, ambiguous_bottom=false)
1663+ detect_ambiguities(mod1, mod2...; recursive=false,
1664+ ambiguous_bottom=false,
1665+ allowed_undefineds=nothing)
16641666
16651667Returns a vector of `(Method,Method)` pairs of ambiguous methods
16661668defined in the specified modules.
@@ -1669,10 +1671,17 @@ Use `recursive=true` to test in all submodules.
16691671`ambiguous_bottom` controls whether ambiguities triggered only by
16701672`Union{}` type parameters are included; in most cases you probably
16711673want to set this to `false`. See [`Base.isambiguous`](@ref).
1674+
1675+ See [`Test.detect_unbound_args`](@ref) for an explanation of
1676+ `allowed_undefineds`.
1677+
1678+ !!! compat "Julia 1.8"
1679+ `allowed_undefineds` requires at least Julia 1.8.
16721680"""
16731681function detect_ambiguities (mods:: Module... ;
16741682 recursive:: Bool = false ,
1675- ambiguous_bottom:: Bool = false )
1683+ ambiguous_bottom:: Bool = false ,
1684+ allowed_undefineds = nothing )
16761685 @nospecialize
16771686 ambs = Set {Tuple{Method,Method}} ()
16781687 mods = collect (mods):: Vector{Module}
@@ -1709,7 +1718,11 @@ function detect_ambiguities(mods::Module...;
17091718 for n in names (mod, all = true )
17101719 Base. isdeprecated (mod, n) && continue
17111720 if ! isdefined (mod, n)
1712- is_in_mods (mod, recursive, mods) && println (" Skipping " , mod, ' .' , n) # typically stale exports
1721+ if is_in_mods (mod, recursive, mods)
1722+ if allowed_undefineds === nothing || GlobalRef (mod, n) ∉ allowed_undefineds
1723+ println (" Skipping " , mod, ' .' , n) # typically stale exports
1724+ end
1725+ end
17131726 continue
17141727 end
17151728 f = Base. unwrap_unionall (getfield (mod, n))
@@ -1726,13 +1739,29 @@ function detect_ambiguities(mods::Module...;
17261739end
17271740
17281741"""
1729- detect_unbound_args(mod1, mod2...; recursive=false)
1742+ detect_unbound_args(mod1, mod2...; recursive=false, allowed_undefineds=nothing )
17301743
17311744Returns a vector of `Method`s which may have unbound type parameters.
17321745Use `recursive=true` to test in all submodules.
1746+
1747+ By default, any undefined symbols trigger a warning. This warning can
1748+ be suppressed by supplying a collection of `GlobalRef`s for which
1749+ the warning can be skipped. For example, setting
1750+
1751+ ```
1752+ allow_undefineds = Set([GlobalRef(Base, :active_repl),
1753+ GlobalRef(Base, :active_repl_backend)])
1754+ ```
1755+
1756+ would suppress warnings about `Base.active_repl` and
1757+ `Base.active_repl_backend`.
1758+
1759+ !!! compat "Julia 1.8"
1760+ `allowed_undefineds` requires at least Julia 1.8.
17331761"""
17341762function detect_unbound_args (mods... ;
1735- recursive:: Bool = false )
1763+ recursive:: Bool = false ,
1764+ allowed_undefineds= nothing )
17361765 @nospecialize mods
17371766 ambs = Set {Method} ()
17381767 mods = collect (mods):: Vector{Module}
@@ -1760,7 +1789,11 @@ function detect_unbound_args(mods...;
17601789 for n in names (mod, all = true )
17611790 Base. isdeprecated (mod, n) && continue
17621791 if ! isdefined (mod, n)
1763- is_in_mods (mod, recursive, mods) && println (" Skipping " , mod, ' .' , n) # typically stale exports
1792+ if is_in_mods (mod, recursive, mods)
1793+ if allowed_undefineds === nothing || GlobalRef (mod, n) ∉ allowed_undefineds
1794+ println (" Skipping " , mod, ' .' , n) # typically stale exports
1795+ end
1796+ end
17641797 continue
17651798 end
17661799 f = Base. unwrap_unionall (getfield (mod, n))
0 commit comments