How do I eliminated the following compiler error:
type mismatch;
found : org.public_domain.Test
required: Object
Note that Test extends Any, not AnyRef.
Such types can participate in value classes, but instances
cannot appear in singleton types or in reference comparisons.
Test(value)
Occurring on the following code:
object Test extends (Double => Test) {
def apply(value: Double): Test =
new Test(value)
}
final case class Test private(value: Double) extends AnyVal {
//@annotation.unused
private def readResolve(): Object =
Test(value)
}
val t = Test(10d)
println(s"t=$t")
Here’s the code and error on Scastie: