-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
Milestone
Description
scala> trait Currency[T <: Currency[T]] {
def amount: BigDecimal
def copy(amount: BigDecimal): T
def +(other: T) = copy(amount + other.amount)
}
scala> case class SEK(amount: BigDecimal) extends Currency[SEK]
<console>:8: error: class SEK needs to be abstract, since method copy in trait Currency of type (amount: BigDecimal)SEK is not defined
case class SEK(amount: BigDecimal) extends Currency[SEK]
However:
scala> case class SEK(amount: BigDecimal)
defined class SEK
scala> :javap SEK
Compiled from "<console>"
public class SEK extends java.lang.Object implements scala.ScalaObject,scala.Product,scala.Serializable{
[snip]
public SEK copy(scala.math.BigDecimal);
[snip]
}