Skip to content

copy method invisible to typer? #5122

@scabug

Description

@scabug
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]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions