Skip to content

Commit

Permalink
Improve type inference of nonmissingtype, nonnothingtype and of Ryu (#…
Browse files Browse the repository at this point in the history
…56120)

Co-authored-by: Cody Tapscott <[email protected]>
  • Loading branch information
gbaraldi and topolarity authored Oct 17, 2024
1 parent 4329422 commit d32cc26
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Any
!!! compat "Julia 1.3"
This function is exported as of Julia 1.3.
"""
nonmissingtype(::Type{T}) where {T} = typesplit(T, Missing)
nonmissingtype(@nospecialize(T::Type)) = typesplit(T, Missing)

function nonmissingtype_checked(T::Type)
R = nonmissingtype(T)
Expand Down
2 changes: 1 addition & 1 deletion base/ryu/Ryu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ end
function Base.show(io::IO, x::T, forceuntyped::Bool=false, fromprint::Bool=false) where {T <: Base.IEEEFloat}
compact = get(io, :compact, false)::Bool
buf = Base.StringVector(neededdigits(T))
typed = !forceuntyped && !compact && Base.nonnothing_nonmissing_typeinfo(io) != typeof(x)
typed = !forceuntyped && !compact && Base.nonnothing_nonmissing_typeinfo(io) !== typeof(x)
pos = writeshortest(buf, 1, x, false, false, true, -1,
(x isa Float32 && !fromprint) ? UInt8('f') : UInt8('e'), false, UInt8('.'), typed, compact)
write(io, resize!(buf, pos - 1))
Expand Down
2 changes: 1 addition & 1 deletion base/some.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Some(::Type{T}) where {T} = Some{Type{T}}(T)

promote_rule(::Type{Some{T}}, ::Type{Some{S}}) where {T, S<:T} = Some{T}

nonnothingtype(::Type{T}) where {T} = typesplit(T, Nothing)
nonnothingtype(@nospecialize(T::Type)) = typesplit(T, Nothing)
promote_rule(T::Type{Nothing}, S::Type) = Union{S, Nothing}
function promote_rule(T::Type{>:Nothing}, S::Type)
R = nonnothingtype(T)
Expand Down

0 comments on commit d32cc26

Please sign in to comment.