@@ -6,7 +6,7 @@ import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
66 + , - , * , / , \ , diff, sum, cumsum, maximum, minimum, sort, sort!,
77 any, all, axes, isone, iterate, unique, allunique, permutedims, inv,
88 copy, vec, setindex!, count, == , reshape, _throw_dmrs, map, zero,
9- show, view, in, mapreduce, one, reverse, promote_op
9+ show, view, in, mapreduce, one, reverse, promote_op, promote_rule
1010
1111import LinearAlgebra: rank, svdvals!, tril, triu, tril!, triu!, diag, transpose, adjoint, fill!,
1212 dot, norm2, norm1, normInf, normMinusInf, normp, lmul!, rmul!, diagzero, AdjointAbsVec, TransposeAbsVec,
@@ -34,6 +34,7 @@ const AbstractFillVecOrMat{T} = Union{AbstractFillVector{T},AbstractFillMatrix{T
3434
3535== (a:: AbstractFill , b:: AbstractFill ) = axes (a) == axes (b) && getindex_value (a) == getindex_value (b)
3636
37+
3738@inline function _fill_getindex (F:: AbstractFill , kj:: Integer... )
3839 @boundscheck checkbounds (F, kj... )
3940 getindex_value (F)
@@ -273,6 +274,14 @@ for (Typ, funcs, func) in ((:Zeros, :zeros, :zero), (:Ones, :ones, :one))
273274 copy (F:: $Typ ) = F
274275
275276 getindex (F:: $Typ{T,0} ) where T = getindex_value (F)
277+
278+ promote_rule (:: Type{$Typ{T, N, Axes}} , :: Type{$Typ{V, N, Axes}} ) where {T,V,N,Axes} = $ Typ{promote_type (T,V),N,Axes}
279+ function convert (:: Type{$Typ{T,N,Axes}} , A:: $Typ{V,N,Axes} ) where {T,V,N,Axes}
280+ convert (T, getindex_value (A)) # checks that the types are convertible
281+ $ Typ {T,N,Axes} (axes (A))
282+ end
283+ convert (:: Type{$Typ{T,N}} , A:: $Typ{V,N,Axes} ) where {T,V,N,Axes} = convert ($ Typ{T,N,Axes}, A)
284+ convert (:: Type{$Typ{T}} , A:: $Typ{V,N,Axes} ) where {T,V,N,Axes} = convert ($ Typ{T,N,Axes}, A)
276285 end
277286end
278287
@@ -284,6 +293,8 @@ for TYPE in (:Fill, :AbstractFill, :Ones, :Zeros), STYPE in (:AbstractArray, :Ab
284293 end
285294end
286295
296+ promote_rule (:: Type{<:AbstractFill{T, N, Axes}} , :: Type{<:AbstractFill{V, N, Axes}} ) where {T,V,N,Axes} = Fill{promote_type (T,V),N,Axes}
297+
287298"""
288299 fillsimilar(a::AbstractFill, axes)
289300
0 commit comments