Here is the simplified code:
class Value(val value: Int) extends AnyVal
val v = new Value(1)
val x = new { val f: Int = v.value }
println(x.f)
val y = new { val f: Value = v }
println(y.f)
Error: Result type in structural refinement may not refer to a user-defined value class
val y = new { val f: Value = v }
I don't understand. Since Int is also a value class, why Int can be used as member but my value class Value not? Why scala defines this limitation? How can I use user-defined value vlass in structural types?