Skip to content

Commit 9c94ab7

Browse files
committed
Deprecate Base.datatype_name to a name method
1 parent 5af942a commit 9c94ab7

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

base/reflection.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ fieldnames(t::UnionAll) = fieldnames(unwrap_unionall(t))
143143
fieldnames(t::Type{<:Tuple}) = Int[n for n in 1:fieldcount(t)]
144144

145145
"""
146-
Base.datatype_name(t) -> Symbol
146+
name(t::Type) -> Symbol
147147
148-
Get the name of a (potentially UnionAll-wrapped) `DataType` (without its parent module) as a symbol.
148+
Get the name of a (potentially `UnionAll`-wrapped) `DataType` (without its parent module)
149+
as a symbol.
149150
150151
# Examples
151152
```jldoctest
@@ -155,12 +156,12 @@ julia> module Foo
155156
end
156157
Foo
157158
158-
julia> Base.datatype_name(Foo.S{T} where T)
159+
julia> name(Foo.S{T} where T)
159160
:S
160161
```
161162
"""
162-
datatype_name(t::DataType) = t.name.name
163-
datatype_name(t::UnionAll) = datatype_name(unwrap_unionall(t))
163+
name(t::DataType) = t.name.name
164+
name(t::UnionAll) = name(unwrap_unionall(t))
164165

165166
"""
166167
Base.datatype_module(t::DataType) -> Module

doc/src/base/base.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ Base.fieldname
319319
Base.fieldcount
320320
Base.propertynames
321321
Base.datatype_module
322-
Base.datatype_name
323322
Base.isconst
324323
Base.function_module(::Function)
325324
Base.function_module(::Any, ::Any)

stdlib/Dates/src/parse.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function character_codes(directives::SimpleVector)
1616
return letters
1717
end
1818

19-
genvar(t::DataType) = Symbol(lowercase(string(Base.datatype_name(t))))
19+
genvar(t::DataType) = Symbol(lowercase(string(name(t))))
2020

2121
"""
2222
tryparsenext_core(str::AbstractString, pos::Int, len::Int, df::DateFormat, raise=false)

test/reflection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ let
278278
@test Base.function_module(foo9475, (Any,)) == TestMod7648.TestModSub9475
279279
@test Base.function_module(foo9475) == TestMod7648.TestModSub9475
280280
@test Base.datatype_module(Foo7648) == TestMod7648
281-
@test Base.datatype_name(Foo7648) == :Foo7648
281+
@test name(Foo7648) == :Foo7648
282282
@test basename(functionloc(foo7648, (Any,))[1]) == "reflection.jl"
283283
@test first(methods(TestMod7648.TestModSub9475.foo7648)) == @which foo7648(5)
284284
@test TestMod7648 == @which foo7648

0 commit comments

Comments
 (0)