Method in sealed trait gives Duplicate field name & signature in class file

65 views
Skip to first unread message

Dimitris Kouzis - Loukas

unread,
Sep 25, 2016, 8:28:15 PM9/25/16
to scala-internals
Hello,

I don't know exactly how to accurate describe this, but I think it should be working and it doesn't. It fails on every Scala version I've tried certainly  2.10.5 and 2.11.7 (see here). I've also talked about it in SO.

scala>   def t4() = {
     |
     |     sealed trait IntList {
     |       def process (baseCase: Int, f: (Int, Int) => Int): Int =
     |         this match {
     |           case End => baseCase
     |           case Cons(hd, tl) => f( hd, tl.process(baseCase, f))
     |         }
     |
     |     }
     |
     |     final case object End extends IntList
     |
     |     final case class Cons ( hd: Int, tl: IntList) extends IntList
     |
     |     val l1: IntList = Cons(1, Cons(3, Cons(5, End)))
     | }
t4: ()Unit

scala> t4()
java.lang.ClassFormatError: Duplicate field name&signature in class file Cons$3
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
  at scala.reflect.internal.util.AbstractFileClassLoader.findClass(AbstractFileC
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at Cons$4$.apply(<console>:24)
  at .t4(<console>:26)
  ... 32 elided


Lukas Rytz

unread,
Sep 26, 2016, 5:37:21 AM9/26/16
to scala-i...@googlegroups.com
Hi Dimitris





--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-internals+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dimitris Kouzis - Loukas

unread,
Sep 26, 2016, 7:24:28 AM9/26/16
to scala-i...@googlegroups.com
Thanks a lot! I will update SO

--
You received this message because you are subscribed to a topic in the Google Groups "scala-internals" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-internals/hwOaMrvWT2Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-internals+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages