Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions ext/OffsetArraysAdaptExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ using OffsetArrays, Adapt
import Adapt
Adapt.adapt_structure(to, O::OffsetArray) = OffsetArrays.parent_call(x -> Adapt.adapt(to, x), O)

@static if isdefined(Adapt, :parent_type)
# To support Adapt 3.0 which doesn't have parent_type defined
Adapt.parent_type(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA
end

end
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,10 @@ end
s_arr = adapt(SMatrix{3,3}, arr)
@test parent(s_arr) isa SArray
@test arr == adapt(Array, s_arr)

if isdefined(Adapt, :parent_type)
@test Adapt.parent_type(typeof(arr)) == typeof(arr.parent)
end
end

@testset "Pointer" begin
Expand Down
Loading