Implicit conversion causes stack overflow

Posted by user44242 on Stack Overflow See other posts from Stack Overflow or by user44242
Published on 2011-01-16T13:13:00Z Indexed on 2011/01/16 16:53 UTC
Read the original article Hit count: 110

Filed under:

The following code snippet worked perfectly, then after some code changes in different files, I've started getting stack overflows resulting from recursive invocation of the implicit conversion. Has this ever happened to anyone, and if so what's the fix.

implicit def comparable2ordered[A <: Comparable[_]](x: A): Ordered[A] =
new Ordered[A] with Proxy {
  val self = x

  def compare(y: A): Int = {
    self.compareTo(y)
  }
} 

© Stack Overflow or respective owner

Related posts about scala