diff --git a/README.md b/README.md index 2e8cc445b..24dc29f64 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `firstindex` to obtain the first index of an iterable ([#25458]). +* `Compat.names` supporting keyword arguments for `all` and `imported` ([#25647]). + ## Renaming diff --git a/src/Compat.jl b/src/Compat.jl index 3fd5d2f95..0bfe9eb39 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1643,6 +1643,13 @@ else findall(b::OccursIn, a::Number) = a in b.x ? [1] : Vector{Int}() end +# https://github.com/JuliaLang/julia/pull/25647 +@static if VERSION < v"0.7.0-DEV.3526" + names(m; all=true, imported=true) = Base.names(m, all, imported) +else + import Base: names +end + if VERSION >= v"0.7.0-DEV.3666" import UUIDs else diff --git a/test/runtests.jl b/test/runtests.jl index a2cd3b559..23995bfaa 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1413,4 +1413,12 @@ end import Compat.Markdown @test isa(Markdown.parse("foo"), Markdown.MD) +# 0.7.0-DEV.3526 +module TestNames + export foo + function bar end +end +@test :foo in Compat.names(TestNames) +@test :bar in Compat.names(TestNames, all=true) + nothing