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
8 changes: 5 additions & 3 deletions src/ZeroDimensionalArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ export
Box,
BoxConst

struct ZeroDimArray{T} <: AbstractArray{T, 0}
abstract type AbstractZeroDimensionalArray{T} <: AbstractArray{T, 0} end

struct ZeroDimArray{T} <: AbstractZeroDimensionalArray{T}
v::T
global function new_zero_dimensional_array_immutable(::Type{T}, v) where {T}
new{T}(v)
end
end

mutable struct Box{T} <: AbstractArray{T, 0}
mutable struct Box{T} <: AbstractZeroDimensionalArray{T}
v::T
global function new_zero_dimensional_array_mutable(::Type{T}, v) where {T}
new{T}(v)
Expand All @@ -22,7 +24,7 @@ mutable struct Box{T} <: AbstractArray{T, 0}
end
end

mutable struct BoxConst{T} <: AbstractArray{T, 0}
mutable struct BoxConst{T} <: AbstractZeroDimensionalArray{T}
const v::T
global function new_zero_dimensional_array_mutable_const_field(::Type{T}, v) where {T}
new{T}(v)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ using Aqua: Aqua
Aqua.test_all(ZeroDimensionalArrays)
end

@testset "common abstract supertype" begin
@test !(AbstractArray{<:Any, 0} <: typejoin(Box, BoxConst))
@test !(AbstractArray{<:Any, 0} <: typejoin(Box, ZeroDimArray))
@test !(AbstractArray{<:Any, 0} <: typejoin(BoxConst, ZeroDimArray))
end

@testset "all array types joined" begin
x = 0.3
for Arr ∈ (
Expand Down