-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Closed
Copy link
Labels
types and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch
Description
A separate issue for @mbauman's #6383 (comment) which is distinct from the ambiguity problem.
julia> struct Foo{A<:Real} end
julia> f(x::Foo{A}) where A = 1
f (generic function with 1 method)
julia> f(x::Foo, y...) = 2
f (generic function with 2 methods)
julia> f(Foo{Int}())
2
The second method's 1-arg form appears (unless you're an Expert) as if it is less specific than the first. However, Foo
is treated as Foo{T} where T<:Real
, while the compiler puts a type bound of Any
on A
.
I think it would make sense if Foo{A} where A
was treated as Foo{A} where A<:Real
, at least in method definitions.
Metadata
Metadata
Assignees
Labels
types and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch