Created
April 9, 2014 09:10
-
-
Save xuwei-k/10245154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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