Skip to content

Commit

Permalink
Type assert the :compact IOContext type
Browse files Browse the repository at this point in the history
Duplicates the improvement made to Base's Enums: JuliaLang/julia#35928
  • Loading branch information
jmert committed Sep 9, 2020
1 parent 930823d commit 9f2d512
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/BitFlags.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Base.:|(x::T, y::T) where {T<:BitFlag} = T(Integer(x) | Integer(y))
Base.:&(x::T, y::T) where {T<:BitFlag} = T(Integer(x) & Integer(y))

function Base.print(io::IO, x::T) where T<:BitFlag
compact = get(io, :compact, false)
compact = get(io, :compact, false)::Bool
xi = Integer(x)
multi = (haszero(T) && !iszero(xi)) && !compact && !ispow2(xi)
first = true
Expand All @@ -48,7 +48,7 @@ function Base.print(io::IO, x::T) where T<:BitFlag
nothing
end
function Base.show(io::IO, x::BitFlag)
if get(io, :compact, false)
if get(io, :compact, false)::Bool
print(io, x)
else
print(io, x, "::")
Expand Down

0 comments on commit 9f2d512

Please sign in to comment.