Skip to content

Commit 19809c9

Browse files
committed
fix invalidations due to convert(Nothing, ::Any)
Before this PR: ```julia julia> using SnoopCompileCore julia> struct A end julia> @Snoopr (::Type{<:A})(::AbstractVector) = 1 14-element Vector{Any}: MethodInstance for convert(::Type{Union{}}, ::AbstractArray) 1 MethodInstance for convert(::Type{Nothing}, ::Any) 2 MethodInstance for Union{}(::AbstractArray) "jl_method_table_insert" MethodInstance for Core.Compiler.convert(::Type{V} where V<:Core.Compiler.BitArray{1}, ::Vector{var"#s122"} where var"#s122"<:Union{Float32, Float64}) 1 MethodInstance for Core.Compiler.convert(::Type{T}, ::Vector{var"#s122"} where var"#s122"<:Union{Float32, Float64}) where T<:(Vector{T} where T) 1 MethodInstance for Union{}(::Vector{var"#s122"} where var"#s122"<:Union{Float32, Float64}) "jl_method_table_insert" (::Type{var"#s3"} where var"#s3"<:A)(::AbstractVector{T} where T) in Main at REPL[3]:1 "jl_method_table_insert" ``` After: ```julia julia> using SnoopCompileCore julia> struct A end julia> @Snoopr (::Type{<:A})(::AbstractVector) = 1 Any[] ``` This was causing invalidations in StaticArrays.
1 parent 5cd1e3e commit 19809c9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

base/some.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ end
3434

3535
convert(::Type{T}, x::T) where {T>:Nothing} = x
3636
convert(::Type{T}, x) where {T>:Nothing} = convert(nonnothingtype_checked(T), x)
37+
convert(::Type{Nothing}, x) = throw(MethodError(convert, (Nothing, x)))
38+
convert(::Type{Nothing}, x::T) where {T>:Nothing} = throw(MethodError(convert, (Nothing, x)))
39+
convert(::Type{Nothing}, ::Nothing) = nothing
3740
convert(::Type{Some{T}}, x::Some{T}) where {T} = x
3841
convert(::Type{Some{T}}, x::Some) where {T} = Some{T}(convert(T, x.value))
3942

0 commit comments

Comments
 (0)