Skip to content

Commit 8205e49

Browse files
committed
Refactor disambiguities
1 parent 0f6dd0c commit 8205e49

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/disambiguities.jl

+8-12
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ end
4747
# Assorted calls found by Aqua: ################################################
4848
################################################################################
4949

50-
function Complex(q::AbstractRealQuantity)
51-
@assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead."
52-
return Complex(ustrip(q))
53-
end
54-
function Complex{T}(q::AbstractRealQuantity) where {T<:Real}
55-
@assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead."
56-
return Complex{T}(ustrip(q))
57-
end
58-
function Bool(q::AbstractRealQuantity)
59-
@assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead."
60-
return Bool(ustrip(q))
61-
end
6250
for type in (Signed, Float64, Float32, Rational), op in (:flipsign, :copysign)
6351
@eval function Base.$(op)(x::$type, y::AbstractRealQuantity)
6452
return $(op)(x, ustrip(y))
@@ -72,8 +60,16 @@ for type in (Complex, Complex{Bool})
7260
function Base.:*(l::AbstractRealQuantity, r::$type)
7361
new_quantity(typeof(l), ustrip(l) * r, dimension(l))
7462
end
63+
function $type(q::AbstractRealQuantity) where {T<:Real}
64+
@assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead."
65+
return $type(ustrip(q))
66+
end
7567
end
7668
end
69+
function Bool(q::AbstractRealQuantity)
70+
@assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead."
71+
return Bool(ustrip(q))
72+
end
7773
function Base.:/(l::Complex, r::AbstractRealQuantity)
7874
new_quantity(typeof(r), l / ustrip(r), inv(dimension(r)))
7975
end

0 commit comments

Comments
 (0)