Scala案例类复制方法在2.9和2.10之间的差异

Scala案例类复制方法在2.9和2.10之间的差异,scala,scala-2.10,case-class,Scala,Scala 2.10,Case Class,在Scala 2.9.1中编译以下代码: scala> case class Foo(a: String)(val b: Int = 1) defined class Foo scala> val foo = Foo("some")(2) foo: Foo = Foo(some) scala> foo.copy("another")() res1: Foo = Foo(another) 但在2.10.3中,我们得到以下错误: scala> foo.copy("ano

在Scala 2.9.1中编译以下代码:

scala> case class Foo(a: String)(val b: Int = 1)
defined class Foo

scala> val foo = Foo("some")(2)
foo: Foo = Foo(some)

scala> foo.copy("another")()
res1: Foo = Foo(another)
但在2.10.3中,我们得到以下错误:

scala> foo.copy("another")()
<console>:11: error: not enough arguments for method copy: (b: Int)Foo.
Unspecified value parameter b.
          foo.copy("another")()
scala>foo.copy(“另一个”)()
:11:错误:没有足够的参数用于方法复制:(b:Int)Foo。
未指定值参数b。
foo.copy(“另一个”)()

有人能解释为什么会改变吗?我还想知道,除了foo.copy(“另一个”)(foo.b)

之外,是否还有其他聪明的方法可以做到这一点,不幸的是,这是出于设计:


像这样的case类上的辅助param块通常只用于隐式。它们的用途有限,因为它们不参与模式匹配或(正如您所看到的)复制操作。

看起来像是回归,请报告它。编译器发出更好的错误消息,或者甚至在
Foo
的定义处发出警告都很好。