diff --git a/NEWS.md b/NEWS.md index a05af515970dd..280a4be4cc422 100644 --- a/NEWS.md +++ b/NEWS.md @@ -955,8 +955,8 @@ Deprecated or removed * The module `Random.dSFMT` is renamed `Random.DSFMT` ([#25567]). * `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 diff --git a/base/deprecated.jl b/base/deprecated.jl index f7966af1f7a98..2abdbf0800fc2 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1604,8 +1604,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} diff --git a/base/reflection.jl b/base/reflection.jl index 2d9372c4dbe7d..55be971951aa9 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -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 @@ -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 diff --git a/doc/src/base/base.md b/doc/src/base/base.md index 532f835d25a92..c34915b572b98 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -315,7 +315,6 @@ Base.fieldnames Base.fieldname Base.fieldcount Base.propertynames -Base.datatype_name Base.isconst Base.functionloc(::Any, ::Any) Base.functionloc(::Method) diff --git a/stdlib/Dates/src/parse.jl b/stdlib/Dates/src/parse.jl index 1b0e4165394c0..ea11368a71c3a 100644 --- a/stdlib/Dates/src/parse.jl +++ b/stdlib/Dates/src/parse.jl @@ -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) diff --git a/test/reflection.jl b/test/reflection.jl index 902f5c932034d..b85d9bac717fb 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -278,7 +278,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