Skip to content

Commit

Permalink
Add hasmethod and objectid (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored Feb 3, 2018
1 parent f2bd1a9 commit 02367e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ Currently, the `@compat` macro supports the following syntaxes:

* `nb_available` is now `bytesavailable` ([#25634]).

* `method_exists` is now `hasmethod` ([#25615]).

* `object_id` is now `objectid` ([#25615]).

## New macros

* `@__DIR__` has been added ([#18380])
Expand Down Expand Up @@ -519,6 +523,7 @@ includes this fix. Find the minimum version from there.
[#25544]: https://github.com/JuliaLang/julia/issues/25544
[#25545]: https://github.com/JuliaLang/julia/issues/25545
[#25571]: https://github.com/JuliaLang/julia/issues/25571
[#25615]: https://github.com/JuliaLang/julia/issues/25615
[#25616]: https://github.com/JuliaLang/julia/issues/25616
[#25622]: https://github.com/JuliaLang/julia/issues/25622
[#25628]: https://github.com/JuliaLang/julia/issues/25628
Expand Down
10 changes: 10 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,16 @@ end
export printstyled
end

# 0.7.0-DEV.3455
@static if !isdefined(Base, :hasmethod)
const hasmethod = method_exists
export hasmethod
end
@static if !isdefined(Base, :objectid)
const objectid = object_id
export objectid
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 @@ -1318,4 +1318,10 @@ let buf = IOBuffer()
@test startswith(String(take!(buf)), Base.text_colors[:red])
end

# 0.7.0-DEV.3455
@test hasmethod(sin, Tuple{Float64})
let x = y = 1
@test objectid(x) == objectid(y)
end

nothing

0 comments on commit 02367e6

Please sign in to comment.