-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
types and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch
Description
If I do this:
immutable Foo{T} end
=={T}(lhs::Foo{T},rhs::Foo{T}) = lhs===rhs
=={T}(lhs::Foo{T},rhs::Any) = false
=={T}(lhs::Any,rhs::Foo{T}) = false
I get this warning
Warning: New definition
==(Any,Foo{T}) at none:1
is ambiguous with:
==(Foo{T},Any) at none:1.
To fix, define
==(Foo{T},Foo{T})
before the new definition.
even though I have already defined ==(Foo{T},Foo{T}).
After a trying lots of alternatives it would seem that the solution is to do:
immutable Foo{T} end
=={T1,T2}(lhs::Foo{T1},rhs::Foo{T2}) = lhs===rhs
=={T}(lhs::Foo{T},rhs::Any) = false
=={T}(lhs::Any,rhs::Foo{T}) = false
So I think that the warning is misleading and should be changed to:
Warning: New definition
==(Any,Foo{T}) at none:1
is ambiguous with:
==(Foo{T},Any) at none:1.
To fix, define
==(Foo{T1},Foo{T2})
before the new definition.
Metadata
Metadata
Assignees
Labels
types and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch