On Wed, Oct 12, 2016 at 2:41 PM, Mauro <mauro...@runbox.com> wrote: > On Wed, 2016-10-12 at 20:03, Yichao Yu <yyc1...@gmail.com> wrote: > > On Wed, Oct 12, 2016 at 1:22 PM, esproff <espr...@gmail.com> wrote: > > > >> Consider the code: > >> > >> abstract AbstractFoo > >> > >> type Foo <: AbstractFoo > >> end > >> > >> f(x::AbstractFoo, y::Integer) = "method 1" > >> f(x::Foo, y::Real) = "method 2" > >> > >> foo = Foo() > >> f(foo, 1) > >> > >> This code results in an ambiguity error, since both methods contain one > >> argument with a more specific type declaration than the other. Now > >> consider this code: > >> > >> abstract AbstractFoo > >> > >> type Foo <: AbstractFoo > >> end > >> > >> f(x::AbstractFoo, y::Integer) = "method 1" > >> f{T<:Real}(x::Foo, y::T) = "method 2" > >> > >> foo = Foo() > >> f(foo, 1) > >> > >> This code, in my opinion, should work, since the second method spawns a > >> bunch of sub-methods, one for each concrete subtype of Real in the > second > >> argument, and thus one of these sub-methods should be > >> > > > > No the set of signature the second method matches in the second case is > the > > same as that in the first case. > > However, somewhat similar, this does not error: > > julia> g(x) = 1 > g (generic function with 1 method) > > julia> g{X}(x::X) = 2 > g (generic function with 2 methods) > > julia> g(4) > 2 > > So here the parameterized method does seem more specific. >
This is missing method overwite. i.e. a bug.