{"action":"created","issue":{"url":"https://api.github.com/repos/lampepfl/dotty/issues/1240","repository_url":"https://api.github.com/repos/lampepfl/dotty","labels_url":"https://api.github.com/repos/lampepfl/dotty/issues/1240/labels{/name}","comments_url":"https://api.github.com/repos/lampepfl/dotty/issues/1240/comments","events_url":"https://api.github.com/repos/lampepfl/dotty/issues/1240/events","html_url":"https://github.com/lampepfl/dotty/issues/1240","id":151657373,"number":1240,"title":"Fun with overrides","user":{"login":"DarkDimius","id":1084930,"avatar_url":"https://avatars.githubusercontent.com/u/1084930?v=3","gravatar_id":"","url":"https://api.github.com/users/DarkDimius","html_url":"https://github.com/DarkDimius","followers_url":"https://api.github.com/users/DarkDimius/followers","following_url":"https://api.github.com/users/DarkDimius/following{/other_user}","gists_url":"https://api.github.com/users/DarkDimius/gists{/gist_id}","starred_url":"https://api.github.com/users/DarkDimius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DarkDimius/subscriptions","organizations_url":"https://api.github.com/users/DarkDimius/orgs","repos_url":"https://api.github.com/users/DarkDimius/repos","events_url":"https://api.github.com/users/DarkDimius/events{/privacy}","received_events_url":"https://api.github.com/users/DarkDimius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-04-28T14:31:54Z","updated_at":"2016-05-01T04:39:27Z","closed_at":null,"body":"Simple example. Fails in scalac\\javac, succeeds in Dotty.\r\n\r\n```scala\r\nclass A[T] {\r\n  def foo(x: T): T\r\n  def foo(x: Int): Int\r\n  new A[Int]().foo(1) // what foo should be called? scalac/javac issue an error here. Dotty calls the lexically-first one\r\n}\r\n```\r\n\r\nMore complicated example:\r\n```scala\r\nabstract class A {\r\n  type C[X]\r\n  def foo[B](x: C[B]): C[B]       = {println(\"A.C\"); x}\r\n  def foo[B](x: List[B]): List[B] = {println(\"A.List\"); x}\r\n  def give[X]: C[X]\r\n}\r\n\r\nclass B extends A {\r\n  type C[X] = List[X]\r\n  override def give[X] = Nil\r\n  override def foo[B](x: C[B]): C[B] =  {println(\"B.C\"); x} \r\n                                           // which method is overriden? \r\n                                           // should any bridges be generated?\r\n  val a: A = this\r\n  a.foo(a.give[Int]) // what method should be called here in runtime?\r\n}\r\n```\r\n\r\nIn this example neither scalac nor dotty generate bridges.\r\nPing @retronym @adriaanm "},"comment":{"url":"https://api.github.com/repos/lampepfl/dotty/issues/comments/216015718","html_url":"https://github.com/lampepfl/dotty/issues/1240#issuecomment-216015718","issue_url":"https://api.github.com/repos/lampepfl/dotty/issues/1240","id":216015718,"user":{"login":"retronym","id":65551,"avatar_url":"https://avatars.githubusercontent.com/u/65551?v=3","gravatar_id":"","url":"https://api.github.com/users/retronym","html_url":"https://github.com/retronym","followers_url":"https://api.github.com/users/retronym/followers","following_url":"https://api.github.com/users/retronym/following{/other_user}","gists_url":"https://api.github.com/users/retronym/gists{/gist_id}","starred_url":"https://api.github.com/users/retronym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/retronym/subscriptions","organizations_url":"https://api.github.com/users/retronym/orgs","repos_url":"https://api.github.com/users/retronym/repos","events_url":"https://api.github.com/users/retronym/events{/privacy}","received_events_url":"https://api.github.com/users/retronym/received_events","type":"User","site_admin":false},"created_at":"2016-05-01T04:39:27Z","updated_at":"2016-05-01T04:39:27Z","body":"@odersky I haven't thought too deeply about whether it would be sufficient to flag an error at call sites, rather than also preventing the clash at the point of inheritance\r\n\r\nHowever, this seems like an area where we ought to justify a deviation from javac.\r\n\r\nHere's the bug and test case that seems to have been the genesis of the checks in 2003 era Java by @gafter.\r\n\r\nhttps://bugs.openjdk.java.net/browse/JDK-4906586\r\nhttp://hg.openjdk.java.net/jdk9/jdk9/langtools/file/tip/test/tools/javac/Ambig3.java\r\nhttp://hg.openjdk.java.net/jdk9/jdk9/langtools/file/tip/test/tools/javac/Ambig3.out\r\n\r\nOne problem (perhaps not quite sufficient to motivate the \"same signature\" error) is that within such a class any attempt override the methods would be ambiguous.\r\n\r\nI'll thing about it a bit more and see if I can find an unsoundness that wouldn't be prevented by the call site check."}}