-
Notifications
You must be signed in to change notification settings - Fork 53
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
1.9.8 regression: copy with different signature than constructor produces error #256
Comments
Hmmm, we might need a heuristic to pick the correct |
When there is a user provided https://www.scala-lang.org/files/archive/spec/3.4/05-classes-and-objects.html?utm_source=chatgpt.com
|
Hmmm, so this looks like a dotty or spec issue, because this compiles: //> using scala 3.nightly
//> using dep "com.softwaremill.quicklens::quicklens:1.9.9"
//> using options "-Xprint:typer"
import com.softwaremill.quicklens.*
object Main {
case class Frozen(state: String, ext: Int) {
def copy(state: Char): Frozen = Frozen(state.toString, ext)
}
def main(args: Array[String]): Unit = {
val f = Frozen("A", 0)
// f.modify(_.state).setTo("B")
f.copy('B')
f.copy("B", 2)
}
} Scala-cli one-liner: |
Interesting. Do you want to post this on scala3, or should I? Meanwhile, picking some particular copy when multiple are available sounds like a good choice. It would be best to mimic what Scala 3 compiler does, but as this seems not to be well specified, picking any should do. |
You can post it if it's not a problem 😄 |
They decided it is a spec issue, the behaviour is correct. Now as for quicklens, here is a bit different repro, with no synthetic methods at all. Again, having two object Main {
class Frozen(val state: String, val ext: Int) {
def copy(state: String = state, ext: Int = ext): Frozen = new Frozen(state, ext)
def copy(state: String): Frozen = new Frozen(state, ext)
}
def main(args: Array[String]): Unit = {
val f = new Frozen("A", 0)
f.modify(_.state).setTo("B")
}
} The error is a bit confusing:
If you remove the 2nd copy, it compiles fine. |
Following code fails with a compile error with 1.9.8 and 1.9.9 in Scala 3. It works fine with quicklens 1.9.7 or with Scala 2.
The error is:
My guess is the regression was caused by #236
The text was updated successfully, but these errors were encountered: