密封性状中的方法给出了重复的字段名称和密钥。类文件中的签名

时间:2016-09-22 09:41:20

标签: scala scala-compiler

当我在process()上添加IntList时,它会提供运行时" Duplicate field name&signature in class file Cons$3..."。仅当在函数内定义sealed trait时才会发生这种情况。

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

1 个答案:

答案 0 :(得分:1)

证明是一个已知问题。在此处跟踪:https://issues.scala-lang.org/browse/SI-5252