Skip to content

Commit 88ea317

Browse files
committed
Refactor disambiguities
1 parent 8eb83f7 commit 88ea317

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/disambiguities.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,22 @@ for type in (Signed, Float64, Float32, Rational), op in (:flipsign, :copysign)
6464
return $(op)(x, ustrip(y))
6565
end
6666
end
67-
function Base.:*(l::Complex, r::AbstractRealQuantity)
68-
new_quantity(typeof(r), l * ustrip(r), dimension(r))
69-
end
70-
function Base.:*(l::AbstractRealQuantity, r::Complex)
71-
new_quantity(typeof(l), ustrip(l) * r, dimension(l))
67+
for type in (Complex, Complex{Bool})
68+
@eval begin
69+
function Base.:*(l::$type, r::AbstractRealQuantity)
70+
new_quantity(typeof(r), l * ustrip(r), dimension(r))
71+
end
72+
function Base.:*(l::AbstractRealQuantity, r::$type)
73+
new_quantity(typeof(l), ustrip(l) * r, dimension(l))
74+
end
75+
end
7276
end
7377
function Base.:/(l::Complex, r::AbstractRealQuantity)
7478
new_quantity(typeof(r), l / ustrip(r), inv(dimension(r)))
7579
end
7680
function Base.:/(l::AbstractRealQuantity, r::Complex)
7781
new_quantity(typeof(l), ustrip(l) / r, dimension(l))
7882
end
79-
function Base.:*(l::Complex{Bool}, r::AbstractRealQuantity)
80-
return new_quantity(typeof(r), l * ustrip(r), dimension(r))
81-
end
82-
function Base.:*(l::AbstractRealQuantity, r::Complex{Bool})
83-
return new_quantity(typeof(l), ustrip(l) * r, dimension(l))
84-
end
8583
for op in (:(==), :isequal), base_type in (AbstractIrrational, AbstractFloat)
8684
@eval begin
8785
function Base.$(op)(l::AbstractRealQuantity, r::$base_type)

0 commit comments

Comments
 (0)