Skip to content

Commit

Permalink
Deprecate Base.datatype_name to a name method
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Jan 22, 2018
1 parent 01428bb commit 00c9369
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ Deprecated or removed
`Random.RandomDevice(; unlimited=unlimited)` ([#25668]).

* `module_name` has been deprecated in favor of a new, general `name` function. Similarly,
the unexported `Base.function_name` has been deprecated in favor of a `name` method
([#25622]).
the unexported `Base.function_name` and `Base.datatype_name` have been deprecated in favor
of `name` methods ([#25622]).

* The generic implementations of `strides(::AbstractArray)` and `stride(::AbstractArray, ::Int)`
have been deprecated. Subtypes of `AbstractArray` that implement the newly introduced strided
Expand Down
4 changes: 2 additions & 2 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1627,8 +1627,8 @@ export readandwrite
# PR 25622
@deprecate module_name(m::Module) name(m)
@deprecate function_name(f::Function) name(f) false
@deprecate Base.datatype_name(t::DataType) name(t)
@deprecate Base.datatype_name(t::UnionAll) name(t)
@deprecate datatype_name(t::DataType) name(t) false
@deprecate datatype_name(t::UnionAll) name(t) false

# PR #25196
@deprecate_binding ObjectIdDict IdDict{Any,Any}
Expand Down
11 changes: 6 additions & 5 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ fieldnames(t::UnionAll) = fieldnames(unwrap_unionall(t))
fieldnames(t::Type{<:Tuple}) = Int[n for n in 1:fieldcount(t)]

"""
Base.datatype_name(t) -> Symbol
name(t::Type) -> Symbol
Get the name of a (potentially UnionAll-wrapped) `DataType` (without its parent module) as a symbol.
Get the name of a (potentially `UnionAll`-wrapped) `DataType` (without its parent module)
as a symbol.
# Examples
```jldoctest
Expand All @@ -155,12 +156,12 @@ julia> module Foo
end
Foo
julia> Base.datatype_name(Foo.S{T} where T)
julia> name(Foo.S{T} where T)
:S
```
"""
datatype_name(t::DataType) = t.name.name
datatype_name(t::UnionAll) = datatype_name(unwrap_unionall(t))
name(t::DataType) = t.name.name
name(t::UnionAll) = name(unwrap_unionall(t))

"""
parentmodule(t::DataType) -> Module
Expand Down
1 change: 0 additions & 1 deletion doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ Base.isimmutable
Base.isabstracttype
Base.isprimitivetype
Base.isstructtype
Base.datatype_name
Base.fieldnames
Base.fieldname
```
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Dates/src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function character_codes(directives::SimpleVector)
return letters
end

genvar(t::DataType) = Symbol(lowercase(string(Base.datatype_name(t))))
genvar(t::DataType) = Symbol(lowercase(string(name(t))))

"""
tryparsenext_core(str::AbstractString, pos::Int, len::Int, df::DateFormat, raise=false)
Expand Down
2 changes: 1 addition & 1 deletion test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ let
@test parentmodule(foo9475, (Any,)) == TestMod7648.TestModSub9475
@test parentmodule(foo9475) == TestMod7648.TestModSub9475
@test parentmodule(Foo7648) == TestMod7648
@test Base.datatype_name(Foo7648) == :Foo7648
@test name(Foo7648) == :Foo7648
@test basename(functionloc(foo7648, (Any,))[1]) == "reflection.jl"
@test first(methods(TestMod7648.TestModSub9475.foo7648)) == @which foo7648(5)
@test TestMod7648 == @which foo7648
Expand Down

0 comments on commit 00c9369

Please sign in to comment.