The scala code is simple:
case class X(id: Option[String] = None, username: Option[String])
object X {
def create(x: X): X = {
x.copy(id = Some("111"))
}
}
class Test {
def test() {
val x = X.create(X(
username = Some("Hello, world!")))
val id = x.id.get // !!! reports: recursive value x needs type
}
}
Please note the line:
val id = x.id.get
Why it reports recursive value x needs type
?
If I change the variable name, as:
val dd = x.id.get
It will be OK.
PS: scala version is: 2.9.1.final
Removing the default argument for id
in the definition of case class X
also fixes the problem which suggests that this is an instance of SI-5091.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With