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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ Currently, the `@compat` macro supports the following syntaxes:

* `ipermute!` is now `invpermute!` ([#25168]).

* `module_parent`, `Base.function_module`, and `Base.datatype_module` are now methods of
a new function called `parentmodule` ([#25629]).

## New macros

* `@__DIR__` has been added ([#18380])
Expand Down Expand Up @@ -470,3 +473,4 @@ includes this fix. Find the minimum version from there.
[#25227]: https://github.com/JuliaLang/julia/issues/25227
[#25249]: https://github.com/JuliaLang/julia/issues/25249
[#25402]: https://github.com/JuliaLang/julia/issues/25402
[#25629]: https://github.com/JuliaLang/julia/issues/25629
9 changes: 9 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,15 @@ else
@eval const $(Symbol("@error")) = Base.$(Symbol("@error"))
end

@static if !isdefined(Base, :parentmodule)
parentmodule(m::Module) = Base.module_parent(m)
parentmodule(f::Function) = Base.function_module(f)
parentmodule(@nospecialize(f), @nospecialize(t)) = Base.function_module(f, t)
parentmodule(t::DataType) = Base.datatype_module(t)
parentmodule(t::UnionAll) = Base.datatype_module(Base.unwrap_unionall(t))
export parentmodule
end

include("deprecated.jl")

end # module Compat
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,12 @@ if !isdefined(Base, Symbol("@info"))
end
end

# 0.7.0-DEV.3460
@test parentmodule(Compat.Sys) == Compat
@test parentmodule(sin) == Base
@test parentmodule(sin, Tuple{Int}) == Base.Math
@test parentmodule(Int) == Core
@test parentmodule(Array) == Core

if VERSION < v"0.6.0"
include("deprecated.jl")
Expand Down