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
f(x::Foo, y::Int) = "method 2"
which then eliminates the ambiguity, but it doesn't behave this way, why is that?