title: Method in sealed trait gives Duplicate field name & signature in class file
body: <p>When I add <code>process()</code> on <code>IntList</code> it gives a runtime "<code>Duplicate field name&amp;signature in class file Cons$3...</code>". This happens only when the <code>sealed trait</code> is defined inside a function.</p>
  
  <pre><code>scala&gt;   def t4() = {
       |
       |     sealed trait IntList {
       |       def process (baseCase: Int, f: (Int, Int) =&gt; Int): Int =
       |         this match {
       |           case End =&gt; baseCase
       |           case Cons(hd, tl) =&gt; 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&gt; t4()
  java.lang.ClassFormatError: Duplicate field name&amp;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(&lt;console&gt;:24)
    at .t4(&lt;console&gt;:26)
    ... 32 elided
  </code></pre>