Skip to content

Commit a0418f6

Browse files
author
Andy Ferris
committed
Fixed some subtyping issues
1 parent a000ab2 commit a0418f6

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/MArray.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Construct a statically-sized, mutable array of dimensions `S` (expressed as a `T
1717
using the data from `a`. The `S` parameter is mandatory since the size of `a` is unknown to
1818
the compiler (the element type may optionally also be specified).
1919
"""
20-
type MArray{S, T, N, L} <: StaticArray{S, T, N}
20+
type MArray{S <: Tuple, T, N, L} <: StaticArray{S, T, N}
2121
data::NTuple{L,T}
2222

2323
function (::Type{MArray{S,T,N,L}}){S,T,N,L}(x::NTuple{L,T})
@@ -91,14 +91,14 @@ function getindex(v::MArray, i::Int)
9191
v.data[i]
9292
end
9393

94-
@propagate_inbounds setindex!{S,T}(v::MArray{S,T}, val, i::Int) = setindex!(v, convert(T, val), i)
95-
@inline function setindex!{S,T}(v::MArray{S,T}, val::T, i::Int)
94+
@inline function setindex!(v::MArray, val, i::Int)
9695
@boundscheck if i < 1 || i > length(v)
9796
throw(BoundsError())
9897
end
9998

99+
T = eltype(v)
100100
if isbits(T)
101-
unsafe_store!(Base.unsafe_convert(Ptr{T}, Base.data_pointer_from_objref(v)), val, i)
101+
unsafe_store!(Base.unsafe_convert(Ptr{T}, Base.data_pointer_from_objref(v)), convert(T, val), i)
102102
else
103103
# This one is unsafe (#27)
104104
# unsafe_store!(Base.unsafe_convert(Ptr{Ptr{Void}}, Base.data_pointer_from_objref(v.data)), Base.data_pointer_from_objref(val), i)

src/SArray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Construct a statically-sized array of dimensions `S` (expressed as a `Tuple{...}
1515
the data from `a`. The `S` parameter is mandatory since the size of `a` is unknown to the
1616
compiler (the element type may optionally also be specified).
1717
"""
18-
immutable SArray{S, T, N, L} <: StaticArray{S, T, N}
18+
immutable SArray{S <: Tuple, T, N, L} <: StaticArray{S, T, N}
1919
data::NTuple{L,T}
2020

2121
function (::Type{SArray{S, T, N, L}}){S, T, N, L}(x::NTuple{L,T})

src/SizedArray.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ array may be reshaped.
99
1010
(Also, `Size(dims...)(array)` acheives the same thing)
1111
"""
12-
immutable SizedArray{S,T,N,M} <: StaticArray{S,T,N}
13-
data::Array{T,M}
12+
immutable SizedArray{S <: Tuple, T, N, M} <: StaticArray{S, T, N}
13+
data::Array{T, M}
1414

15-
function (::Type{SizedArray{S,T,N,M}}){S,T,N,M}(a::Array)
15+
function (::Type{SizedArray{S, T, N, M}}){S, T, N, M}(a::Array)
1616
if length(a) != tuple_prod(S)
1717
error("Dimensions $(size(a)) don't match static size $S")
1818
end
1919
new{S,T,N,M}(a)
2020
end
2121

22-
function (::Type{SizedArray{S,T,N,M}}){S,T,N,M}()
23-
new{S,T,N,M}(Array{T,M}(S))
22+
function (::Type{SizedArray{S, T, N, M}}){S, T, N, M}()
23+
new{S, T, N, M}(Array{T, M}(S))
2424
end
2525
end
2626

test/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
@testset "reshape" begin
6464
@test @inferred(reshape(SVector(1,2,3,4), Size(2,2))) === SMatrix{2,2}(1,2,3,4)
65-
@test @inferred(reshape([1,2,3,4], Size(2,2)))::SizedArray{(2,2),Int,2,1} == [1 3; 2 4]
65+
@test @inferred(reshape([1,2,3,4], Size(2,2)))::SizedArray{Tuple{2,2},Int,2,1} == [1 3; 2 4]
6666

6767
@test @inferred(vec(SMatrix{2, 2}([1 2; 3 4])))::SVector{4,Int} == [1, 3, 2, 4]
6868
end

0 commit comments

Comments
 (0)