Skip to content

Commit 6625b40

Browse files
gbaralditopolarity
authored andcommitted
Improve type inference of nonmissingtype, nonnothingtype and of Ryu (#56120)
Co-authored-by: Cody Tapscott <84105208+topolarity@users.noreply.github.com>
1 parent 0f0a20b commit 6625b40

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

base/missing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Any
3636
!!! compat "Julia 1.3"
3737
This function is exported as of Julia 1.3.
3838
"""
39-
nonmissingtype(::Type{T}) where {T} = typesplit(T, Missing)
39+
nonmissingtype(@nospecialize(T::Type)) = typesplit(T, Missing)
4040

4141
function nonmissingtype_checked(T::Type)
4242
R = nonmissingtype(T)

base/ryu/Ryu.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ end
112112
function Base.show(io::IO, x::T, forceuntyped::Bool=false, fromprint::Bool=false) where {T <: Base.IEEEFloat}
113113
compact = get(io, :compact, false)::Bool
114114
buf = Base.StringVector(neededdigits(T))
115-
typed = !forceuntyped && !compact && Base.nonnothing_nonmissing_typeinfo(io) != typeof(x)
115+
typed = !forceuntyped && !compact && Base.nonnothing_nonmissing_typeinfo(io) !== typeof(x)
116116
pos = writeshortest(buf, 1, x, false, false, true, -1,
117117
(x isa Float32 && !fromprint) ? UInt8('f') : UInt8('e'), false, UInt8('.'), typed, compact)
118118
write(io, resize!(buf, pos - 1))

base/some.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Some(::Type{T}) where {T} = Some{Type{T}}(T)
1616

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

19-
nonnothingtype(::Type{T}) where {T} = typesplit(T, Nothing)
19+
nonnothingtype(@nospecialize(T::Type)) = typesplit(T, Nothing)
2020
promote_rule(T::Type{Nothing}, S::Type) = Union{S, Nothing}
2121
function promote_rule(T::Type{>:Nothing}, S::Type)
2222
R = nonnothingtype(T)

0 commit comments

Comments
 (0)