From e5f17530203ae760efa18dba95e962822b6a58fd Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Fri, 18 Mar 2022 14:02:07 +0100 Subject: [PATCH] Fix display bug of abstract type EnumX.Enum. --- Project.toml | 2 +- src/EnumX.jl | 6 +++++- test/runtests.jl | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 2897405..c2a552c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "EnumX" uuid = "4e289a0a-7415-4d19-859d-a7e5c4648b56" -version = "1.0.0" +version = "1.0.1" [compat] julia = "1.6" diff --git a/src/EnumX.jl b/src/EnumX.jl index 7e7945f..51c0d98 100644 --- a/src/EnumX.jl +++ b/src/EnumX.jl @@ -138,7 +138,11 @@ function Base.show(io::IO, ::MIME"text/plain", x::E) where E <: Enum write(io, seekstart(iob)) return nothing end -function Base.show(io::IO, ::MIME"text/plain", ::Base.Type{E}) where E <: Enum +function Base.show(io::IO, ::MIME"text/plain", ::Type{E}) where E <: Enum + if !isconcretetype(E) # handle EnumX.Enum and EnumX.Enum{T} + invoke(show, Tuple{IO, Type}, io, E) + return + end iob = IOBuffer() insts = Base.Enums.instances(E) n = length(insts) diff --git a/test/runtests.jl b/test/runtests.jl index 35f65e4..243d701 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -71,6 +71,12 @@ let io = IOBuffer() show(io, "text/plain", Fruit.Banana) str = String(take!(io)) @test str == "Fruit.Banana = 1" + show(io, "text/plain", EnumX.Enum) + str = String(take!(io)) + @test str == "EnumX.Enum" + show(io, "text/plain", EnumX.Enum{Int32}) + str = String(take!(io)) + @test str == "EnumX.Enum{Int32}" end