Skip to content

Commit ac2f60e

Browse files
committed
Fix inference on 1.6/1.7
1 parent 5efcdaa commit ac2f60e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/FieldArray.jl

+9-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function similar_type(::Type{A}, ::Type{T}, S::Size) where {T,A<:FieldArray}
131131
# FieldArrays with parametric `eltype` would be adapted to the new `eltype` automatically.
132132
A′ = Base.typeintersect(base_type(A), StaticArray{Tuple{Tuple(S)...},T,length(S)})
133133
# But extra parameters are disallowed here. Also we check `fieldtypes` to make sure the result is valid.
134-
isconcretetype(A′) && fieldtypes(A′) === ntuple(Returns(T), Val(prod(S))) && return A′
134+
isconcretetype(A′) && fieldtypes(A′) === ntuple(_ -> T, Val(prod(S))) && return A′
135135
# Otherwise, we fallback to `S/MArray` based on it's mutability.
136136
if ismutabletype(A)
137137
return mutable_similar_type(T, S, length_val(S))
@@ -141,7 +141,12 @@ function similar_type(::Type{A}, ::Type{T}, S::Size) where {T,A<:FieldArray}
141141
end
142142

143143
# return `Union{}` for Union Type. Otherwise return the constructor with no parameters.
144-
@pure base_type(@nospecialize(T::Type)) = (T′ = Base.unwrap_unionall(T); T′ isa DataType ? T′.name.wrapper : Union{})
145-
if VERSION < v"1.7"
146-
@pure ismutabletype(@nospecialize(T::Type)) = (T′ = Base.unwrap_unionall(T); T′ isa DataType && T′.mutable)
144+
@pure base_type(@nospecialize(T::Type)) = (T′ = Base.unwrap_unionall(T);
145+
T′ isa DataType ? T′.name.wrapper : Union{})
146+
if VERSION < v"1.8"
147+
fieldtypes(::Type{T}) where {T} = ntuple(i -> fieldtype(T, i), Val(fieldcount(T)))
148+
@eval @pure function ismutabletype(@nospecialize(T::Type))
149+
T′ = Base.unwrap_unionall(T)
150+
T′ isa DataType && $(VERSION < v"1.7" ? :(T′.mutable) : :(T′.name.flags & 0x2 == 0x2))
151+
end
147152
end

0 commit comments

Comments
 (0)