This page is no longer maintained — Please continue to the home page at www.scala-lang.org

@specialized breaks polymorphic dispatch

2 replies
Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.

I just tracked down a subtle bug [1] with overriding and
specialization. It's a silent killer: beware!

For those that don't know, specialization was enabled by default in
2.8.0.RC1. You can disable it with the compiler flag:
-no-specialization

-jason

[1] https://lampsvn.epfl.ch/trac/scala/ticket/3434

class F extends Function0[Double] {
def apply: Double = 0.0
}

object G extends F {
override def apply: Double = 1.0
}

val result = (G: F).apply

println(result) // 0.0!

ijuma
Joined: 2008-08-20,
User offline. Last seen 22 weeks 2 days ago.
Re: @specialized breaks polymorphic dispatch

On Thu, May 13, 2010 at 11:13 AM, Jason Zaugg wrote:
> I just tracked down a subtle bug [1] with overriding and
> specialization. It's a silent killer: beware!

Nicely spotted. And... ouch.

Ismael

Iulian Dragos 2
Joined: 2009-02-10,
User offline. Last seen 42 years 45 weeks ago.
Re: @specialized breaks polymorphic dispatch
Indeed, ouch! It's fixed now.

On Thu, May 13, 2010 at 12:18 PM, Ismael Juma <mlists [at] juma [dot] me [dot] uk> wrote:
On Thu, May 13, 2010 at 11:13 AM, Jason Zaugg <jzaugg [at] gmail [dot] com> wrote:
> I just tracked down a subtle bug [1] with overriding and
> specialization. It's a silent killer: beware!

Nicely spotted. And... ouch.

Ismael



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland