Skip to content
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
Open

copy method invisible to typer? #5122

scabug opened this issue Oct 28, 2011 · 3 comments

Comments

@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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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"

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

No branches or pull requests

1 participant