-
Notifications
You must be signed in to change notification settings - Fork 21
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
Boom! you stepped on a bug with specialization and companion objects #5284
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5284?orig=1 |
Marc Millstone (splittingfield) said: |
@paulp said: object Run {
def main(args:Array[String]) {
println( Blarg(Array(1)) m ((x: Int) => x + 1) )
}
}
object Blarg {
def apply[T: Manifest](a: Array[T]) = new Blarg(a)
}
class Blarg[T](val a:Array[T]) {
// java.lang.NoSuchMethodError: Blarg.m$mIIc$sp(Lscala/Function1;)I
// at Run$.main(a.scala:6)
// at Run.main(a.scala)
def m[@specialized W >: T, @specialized S](f: W => S) = f(a(0))
} |
Marc Millstone (splittingfield) said: Thanks Paul. I am really deep into specialization and please let me know |
@paulp said: |
@axel22 said: I'm experimenting on what would happen if a method with a |
Marc Millstone (splittingfield) said: The only reason this code exists is due to issue #5281 is not specializing across the cross product of T and W. This was a workaround to force |
@axel22 said: Iulian, can you comment on this? Do you agree? |
@axel22 said: |
I came across the following situation.
When run, this throws the runtime exception
java.lang.RuntimeException: boom! you stepped on a bug. This method should never be called.
However, when we specialize the apply method as follows,
everything goes through as it should.
The type parameters used in m are a workaround for the lack
of specialization on result type I submitted earlier.
The text was updated successfully, but these errors were encountered: