Skip to content

Commit 4667128

Browse files
committed
Refactor some promotion rules
1 parent 0e41261 commit 4667128

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/utils.jl

+4-8
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@ end
3535
function Base.promote_rule(::Type{Dimensions{R1}}, ::Type{Dimensions{R2}}) where {R1,R2}
3636
return Dimensions{promote_type(R1,R2)}
3737
end
38-
function Base.promote_rule(::Type{<:GenericQuantity{T1,D1}}, ::Type{<:GenericQuantity{T2,D2}}) where {T1,T2,D1,D2}
39-
return GenericQuantity{promote_type(T1,T2),promote_type(D1,D2)}
40-
end
41-
function Base.promote_rule(::Type{<:Quantity{T1,D1}}, ::Type{<:Quantity{T2,D2}}) where {T1,T2,D1,D2}
42-
return Quantity{promote_type(T1,T2),promote_type(D1,D2)}
43-
end
44-
function Base.promote_rule(::Type{<:RealQuantity{T1,D1}}, ::Type{<:RealQuantity{T2,D2}}) where {T1,T2,D1,D2}
45-
return RealQuantity{promote_type(T1,T2),promote_type(D1,D2)}
38+
for (_, _, concrete_type) in ABSTRACT_QUANTITY_TYPES
39+
@eval function Base.promote_rule(::Type{<:$concrete_type{T1,D1}}, ::Type{<:$concrete_type{T2,D2}}) where {T1,T2,D1,D2}
40+
return $concrete_type{promote_type(T1,T2),promote_type(D1,D2)}
41+
end
4642
end
4743

4844
function Base.promote_rule(::Type{<:Quantity{T1,D1}}, ::Type{<:GenericQuantity{T2,D2}}) where {T1,T2,D1,D2}

0 commit comments

Comments
 (0)