-
Notifications
You must be signed in to change notification settings - Fork 21
Case Class Factory Constructor Inlining Fails to Invoke Companion Constructor #5304
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5304?orig=1 |
@lrytz said: bq. The new |
@adriaanm said: |
@som-snytt said: case class Shu(value: Int) { Shu } Less cheap: case class Ma(value: Int)(implicit dummy: Ma.type = Ma) I noticed that the transform is done in RefChecks, and it's so simple and clean that you want to spec it and say Test(42) is a sweetened new Test(42). But I also see that simple sugars are unhealthy: case class Zi private (value: Int)
object Test {
//val z2 = new Zi(19) // obviously not
val z = Zi(17) // error: constructor Zi in class Zi cannot be accessed in object Test
} I see I can't supply a custom non-synthetic apply to short-circuit the optimization either; the spec does say that you can roll your own copy method. |
@magarciaEPFL said:
Now, let's turn this around. Instead of having me show the above is per-spec, can you provide a counter-argument? Which place in the spec mentions the above should behave differently? |
@djspiewak said: |
@retronym said:
|
@retronym said: |
@retronym said:
|
another, related example in #8666 (which I'm closing, let's consolidate here) |
another, related example in #9115 (which I'm closing, let's consolidate here) |
This use case is fixed in dotty (constructor proxy) but 9115 is not (nested static class init). |
I've reopened #9115. |
See the following paste. It appears that the inlining of case class constructors/deconstructors fails to invoke the constructor for the companion object, which is counter to the specification.
The text was updated successfully, but these errors were encountered: