Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate method signatures in specialized code #8431

Closed
scabug opened this issue Mar 19, 2014 · 7 comments · Fixed by scala/scala#7054
Closed

Duplicate method signatures in specialized code #8431

scabug opened this issue Mar 19, 2014 · 7 comments · Fixed by scala/scala#7054

Comments

@scabug
Copy link

scabug commented Mar 19, 2014

Extracted from spire:

import scala.{ specialized => spec }

trait EqProductFoo[@spec(Int) A] {
  def eqv(x0: A): Boolean = ???
}

trait OrderProductFoo[@spec(Int) A] extends EqProductFoo[A] {
  override def eqv(x0: A): Boolean = super.eqv(x0)
}

object Bar {
   def OrderProduct2[@spec(Int) A]: EqProductFoo[A] = {
    new OrderProductFoo[A] { }
  }
  OrderProduct2[Int]
}

object Test extends App {
  Bar
}

This compiles and runs fine with Scala 2.10.2 but fails with Scala 2.11.0-RC1:

java.lang.ClassFormatError: Duplicate method name&signature in class file foo/Bar$$anon$1
@scabug
Copy link
Author

scabug commented Mar 19, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8431?orig=1
Reporter: @gkossakowski
Affected Versions: 2.10.3, 2.11.0-RC1

@scabug
Copy link
Author

scabug commented Mar 19, 2014

@adriaanm said:
I'm sorry this regressed, but I'm going to be hard to convince anything this tricky related to specialization is a release blocker.

@scabug
Copy link
Author

scabug commented Mar 19, 2014

@adriaanm said (edited on Mar 19, 2014 11:49:51 PM UTC):
It regressed between 2.10.2 and 2.10.3. Bisecting is tricky, because, in this range, it both flailed between compiling and not-compiling and running and not-running. Another reason I don't think we should treat it as a blocker for 2.11.0.

g bisect start
g bisect good v2.10.2
g bisect bad v2.10.3
g bisect run scala-run-head /Users/adriaan/Desktop/Bugs/t8431.scala
504b5f3b157de639633c962ea21f7e89152da77f is the first bad commit
commit 504b5f3b157de639633c962ea21f7e89152da77f
Author: Vlad Ureche <vlad.ureche@gmail.com>
Date:   Mon Jul 8 13:32:40 2013 +0200

    SI-7638 Superaccessor lookup after specialization
    ...

I mean "regression" as in change in behavior. The above patch may very well be correct and an improvement (it compiles!), but likely revealed mixins was not prepared with the corner case in this ticket.

# scala-run-head
#!/bin/bash
rev=$(git rev-parse HEAD)
tmpBisect="$(mktemp -d -t bisect)"
cd "$tmpBisect" && RUNNER=scalac scala-hash $rev $@ || exit 0 # ignore compiler errors, which muddy the waters further in this case
scala-hash $rev Test

@scabug
Copy link
Author

scabug commented Mar 20, 2014

@retronym said:
Workaround is to avoid using super.xxxx from the specialized subclass.

import scala.{ specialized => spec }
 
trait EqProductFoo[@spec(Int) A] {
  def eqv(x0: A): Boolean = eqvEqProductFoo(x0)
  protected def eqvEqProductFoo(x0: A) = ???
}
 
trait OrderProductFoo[@spec(Int) A] extends EqProductFoo[A] {
  override def eqv(x0: A): Boolean = eqvEqProductFoo(x0)
}
 
object Bar {
   def OrderProduct2[@spec(Int) A]: EqProductFoo[A] = {
    new OrderProductFoo[A] { }
  }
  OrderProduct2[Int]
}
 
object Test extends App {
  Bar
}

@scabug
Copy link
Author

scabug commented Mar 20, 2014

@retronym said:
Slightly simpler test:

import scala.{ specialized => spec }
 
trait EqProductFoo[@spec(Int) A] {
  def eqv(x0: A): Boolean = ???
}
 
trait OrderProductFoo[@spec(Int) A] extends EqProductFoo[A] {
  override def eqv(x0: A): Boolean = super.eqv(x0)
}
 
class C extends OrderProductFoo[Int]

object Test {
  def main(args: Array[String]) {
    new C
  }
}

@scabug
Copy link
Author

scabug commented Aug 5, 2014

@gkossakowski said:
The 2.11.2 is out so I'm rescheduling the issue for 2.11.3.

@scabug
Copy link
Author

scabug commented Nov 4, 2014

@retronym said:
Updating fix-by version to 2.11.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants