Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update type mutability check in IO.jl #409

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,21 @@ function _evenlydistribute!(t, wrkrs)
end
end

_ismutabletype = if VERSION < v"1.7"
function ismutabletype(@nospecialize(t::Type))
t = unwrap_unionall(t)
return isa(t, DataType) && t.name.flags & 0x2 == 0x2
end
else
Base.ismutabletype
end

deserialize(io::AbstractSerializer, DT::Type{DNDSparse{K,V}}) where {K,V} = _deser(io, DT)
deserialize(io::AbstractSerializer, DT::Type{DIndexedTable{T,K}}) where {T,K} = _deser(io, DT)
function _deser(io::AbstractSerializer, t)
nf = fieldcount(t)
x = ccall(:jl_new_struct_uninit, Any, (Any,), t)
t.mutable && Serialization.deserialize_cycle(io, x)
_ismutabletype(t) && Serialization.deserialize_cycle(io, x)
for i in 1:nf
tag = Int32(read(io.io, UInt8)::UInt8)
if tag != Serialization.UNDEFREF_TAG
Expand Down