diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed4c0912..a778411a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,8 +16,8 @@ jobs: matrix: version: - '1.0' - - '1.5' - '1' + - 'nightly' os: [ubuntu-latest, windows-latest, macos-latest] # adjust according to need, e.g. os: [ubuntu-latest] if testing only on linux arch: - x64 diff --git a/src/backwards_compatibility.jl b/src/backwards_compatibility.jl index 7f525c50..412f0300 100644 --- a/src/backwards_compatibility.jl +++ b/src/backwards_compatibility.jl @@ -22,3 +22,16 @@ function read_array(f::JLDFile, dataspace::ReadDataspace, v = read_array(f, dataspace, rrv, data_length, filter_id, NULL_REFERENCE, attributes) String(v) end + + +@static if VERSION < v"1.7" + # Location of `mutable` flag is moved from datatype to typename in julia v1.7 + # Switch to using accessor function added in v1.7 + + # Borrowed from julia base + function ismutabletype(@nospecialize(t::Type)) + t = unwrap_unionall(t) + # TODO: what to do for `Union`? + return isa(t, DataType) && t.mutable + end +end \ No newline at end of file diff --git a/src/data/reconstructing_datatypes.jl b/src/data/reconstructing_datatypes.jl index 97315c54..61148d55 100644 --- a/src/data/reconstructing_datatypes.jl +++ b/src/data/reconstructing_datatypes.jl @@ -514,7 +514,7 @@ jlconvert(::ReadRepresentation{Core.TypeofBottom,nothing}, f::JLDFile, ptr::Ptr, # For bits types, we should always inline, because otherwise we'll just # pass a lot of crap around in registers push!(args, Expr(:meta, :inline)) - elseif T.mutable + elseif ismutabletype(T) push!(args, quote obj = $(Expr(:new, T)) track_weakref!(f, header_offset, obj) @@ -527,7 +527,7 @@ jlconvert(::ReadRepresentation{Core.TypeofBottom,nothing}, f::JLDFile, ptr::Ptr, rtype = types[i] odr = odrs[i] - if !T.mutable + if !ismutabletype(T) fsym = Symbol("field_", fn[i]) push!(fsyms, fsym) end @@ -538,12 +538,12 @@ jlconvert(::ReadRepresentation{Core.TypeofBottom,nothing}, f::JLDFile, ptr::Ptr, # Type is not stored or single instance if T.types[i] == Union{} # This cannot be defined - @assert !T.mutable + @assert !ismutabletype(T) push!(args, Expr(:return, Expr(:new, T, fsyms[1:i-1]...))) return blk else newi = Expr(:new, T.types[i]) - if T.mutable + if ismutabletype(T) fni = QuoteNode(fn[i]) push!(args, :(setfield!(obj, $fni, $newi))) else @@ -557,7 +557,7 @@ jlconvert(::ReadRepresentation{Core.TypeofBottom,nothing}, f::JLDFile, ptr::Ptr, $(if T <: Tuple || i <= T.ninitialized # Reference must always be initialized :(throw(UndefinedFieldException(T,$(QuoteNode(fn[i]))))) - elseif T.mutable + elseif ismutabletype(T) # Reference could be uninitialized :(return obj) else @@ -574,7 +574,7 @@ jlconvert(::ReadRepresentation{Core.TypeofBottom,nothing}, f::JLDFile, ptr::Ptr, else ttype = T.types[i] fni = QuoteNode(fn[i]) - if T.mutable + if ismutabletype(T) push!(args, :(setfield!(obj, $fni, convert($ttype, jlconvert($rr, f, ptr+$offset, NULL_REFERENCE)::$rtype)::$ttype))) else @@ -584,7 +584,7 @@ jlconvert(::ReadRepresentation{Core.TypeofBottom,nothing}, f::JLDFile, ptr::Ptr, end end - push!(args, T.mutable ? (:obj) : T <: Tuple ? Expr(:tuple, fsyms...) : Expr(:new, T, fsyms...)) + push!(args, ismutabletype(T) ? (:obj) : T <: Tuple ? Expr(:tuple, fsyms...) : Expr(:new, T, fsyms...)) blk end diff --git a/src/data/writing_datatypes.jl b/src/data/writing_datatypes.jl index b2c16253..d4e59736 100644 --- a/src/data/writing_datatypes.jl +++ b/src/data/writing_datatypes.jl @@ -21,7 +21,7 @@ odr_sizeof(::ReadRepresentation{T,S}) where {T,S} = odr_sizeof(S) T = T::DataType T in encounteredtypes && return true push!(encounteredtypes, T) - (T.mutable || T <: Type) && return true + (ismutabletype(T) || T <: Type) && return true hasdata(T, encounteredtypes) end @@ -68,7 +68,7 @@ fieldnames(@nospecialize x) = collect(Base.fieldnames(x)) elseif isa(T, DataType) if isbitstype(T) return :(odr(T)) - elseif !T.mutable + elseif !ismutabletype(T) return :(initialized ? odr(T) : RelOffset) end end @@ -83,7 +83,7 @@ end if isconcretetype(T) if !hasfielddata(T) return nothing - elseif isbitstype(T) || (isa(initialized, Type{Type{Val{true}}}) && !T.mutable) + elseif isbitstype(T) || (isa(initialized, Type{Type{Val{true}}}) && !ismutabletype(T)) return quote @lookup_committed f T $(if isempty(T.types) @@ -511,7 +511,7 @@ end newstruct(T) = ccall(:jl_new_struct_uninit, Any, (Any,), T) function newstruct(T, fields) - if !T.mutable + if !ismutabletype(T) return ccall(:jl_new_structv, Any, (Any,Ptr{Cvoid},UInt32), T, fields, length(fields)) else # Manual inline of newstruct! to work around bug