module A
import Base: convert
export Foo
type Foo
a::Float64
b::Float64
end
function convert(::Type{Foo}, a::Tuple{Float64,Float64})
Foo(a[1], a[2])
end
end
module B
using A
export Bar
type Bar
x1 :: Foo
x2 :: Foo
function Bar(a::Foo, b::Foo) new(a,b) end
end
end
The test code in a separated file
using B
b = Bar((1.0,2.0), (1.0,2.0))
println(b)
ERROR: LoadError: MethodError: no method matching B.Bar(::Tuple{Float64,Float64}, ::Tuple{Float64,Float64})
Closest candidates are:
B.Bar{T}(::Any) at sysimg.jl:53
When I remove the internal constructor everything works as expected.
I was hoping somebody could explain why that is.
I can fix it by creating an external constructor which matches on Tuples.
Thank you.