New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy method invisible to typer? #5122

Open
scabug opened this Issue Oct 28, 2011 · 3 comments

Comments

Projects
None yet
1 participant
@scabug
Copy link

scabug commented Oct 28, 2011

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

This comment has been minimized.

Copy link

scabug commented Oct 28, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5122?orig=1
Reporter: @viktorklang
Affected Versions: 2.9.1

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 28, 2011

@viktorklang said:
Of course: "copy in trait C of type" should be "copy in trait Currency of type" (expanded the type name for more context)

@scabug

This comment has been minimized.

Copy link

scabug commented Jul 5, 2012

@lrytz said:
it's a known limitation - at least known to me :-)

the solution is be to generate the method symbol for "copy" early, similar to what is done for "apply"

@scabug scabug added this to the Backlog milestone Apr 7, 2017

@scala scala deleted a comment from scabug Mar 3, 2018

@scala scala deleted a comment from scabug Mar 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment