Skip to content

Commit e5e094c

Browse files
authored
fix method ambiguities in testhelpers/Furlongs.jl (#34480)
1 parent e0740fe commit e5e094c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/testhelpers/Furlongs.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ export Furlong
1111
struct Furlong{p,T<:Number} <: Number
1212
val::T
1313
Furlong{p,T}(v::Number) where {p,T} = new(v)
14-
Furlong{p,T}(x::Furlong{p}) where {p,T} = new(x.val)
1514
end
1615
Furlong(x::T) where {T<:Number} = Furlong{1,T}(x)
16+
Furlong(x::Furlong) = x
1717
(::Type{T})(x::Furlong) where {T<:Number} = T(x.val)
1818
Furlong{p}(v::Number) where {p} = Furlong{p,typeof(v)}(v)
19-
Furlong{p,T}(x::Furlong{p,S}) where {T,p,S} = Furlong{p,T}(T(x.val))
19+
Furlong{p}(x::Furlong{q}) where {p,q} = (@assert(p==q); Furlong{p,typeof(x.val)}(x.val))
20+
Furlong{p,T}(x::Furlong{q}) where {T,p,q} = (@assert(p==q); Furlong{p,T}(T(x.val)))
2021

2122
Base.promote_type(::Type{Furlong{p,T}}, ::Type{Furlong{p,S}}) where {p,T,S} =
2223
(Base.@_pure_meta; Furlong{p,promote_type(T,S)})
@@ -70,6 +71,8 @@ for (op,eop) in ((:*, :_plus), (:/, :_minus), (://, :_minus), (:div, :_minus))
7071
$op(x::S, y::Furlong{p}) where {p,S<:Number} = $op(Furlong{0,S}(x),y)
7172
end
7273
end
74+
# to fix an ambiguity
75+
//(x::Furlong, y::Complex) = x // Furlong{0,typeof(y)}(y)
7376
for op in (:rem, :mod)
7477
@eval begin
7578
$op(x::Furlong{p}, y::Furlong) where {p} = Furlong{p}($op(x.val, y.val))

0 commit comments

Comments
 (0)