Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created April 9, 2014 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuwei-k/10245154 to your computer and use it in GitHub Desktop.
Save xuwei-k/10245154 to your computer and use it in GitHub Desktop.
class A[T]{
def foo(t: T): Unit = {}
}
class B extends A[Y] {
def foo(t: X): Unit = {}
}
class X
class Y extends X
object Main {
(new B).foo(new Y) // compile error. "ambiguous reference to overloaded definition"
(new B).foo(new Y: X) // success
}
error: ambiguous reference to overloaded definition,
both method foo in class B of type (t: X)Unit
and method foo in class A of type (t: Y)Unit
match argument types (Y)
(new B).foo(new Y)
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment