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

Scala 3: wrongly accepted modify does nothing #258

Open
OndrejSpanel opened this issue Nov 29, 2024 · 4 comments
Open

Scala 3: wrongly accepted modify does nothing #258

OndrejSpanel opened this issue Nov 29, 2024 · 4 comments

Comments

@OndrejSpanel
Copy link
Contributor

Following code does not compile in Scala 2 and it should not compile in Scala 3. It is accepted instead, but the modify does nothing at all:

import com.softwaremill.quicklens._

object Main {
  case class Content(x: String)
  class A(val c: Content) {
    override def toString = s"x:${c.x}"
    def copy(x: String = c.x): A = new A(Content(x))
  }

  def main(args: Array[String]): Unit = {
    val a = new A(Content("A"))
    val am = a.modify(_.c).setTo(Content("B"))
    println(am)
  }
}

There is no copy accepting c parameter, therefore modify(_.c) is impossible to implement.

Result when running this in Scala 3 is:

x:A

@OndrejSpanel
Copy link
Contributor Author

Looking at #257, it is very likely it will fix this one as well. Staying tuned...

@OndrejSpanel
Copy link
Contributor Author

.. or not. In this case there is only one copy method. But the work from #257 should be possible to use to check if the one and only copy is suitable.

@OndrejSpanel
Copy link
Contributor Author

I will try to get my hands dirty here.

@OndrejSpanel
Copy link
Contributor Author

It is almost fixed with 1.9.10, only the error message is a bit confusing:

A has no member named copy

I will check if I am able to improve that, at least I will learn something if any similar issues should surface again.

OndrejSpanel added a commit to OndrejSpanel/quicklens that referenced this issue Dec 1, 2024
OndrejSpanel added a commit to OndrejSpanel/quicklens that referenced this issue Dec 1, 2024
OndrejSpanel added a commit to OndrejSpanel/quicklens that referenced this issue Dec 4, 2024
OndrejSpanel added a commit to OndrejSpanel/quicklens that referenced this issue Dec 4, 2024
OndrejSpanel added a commit to OndrejSpanel/quicklens that referenced this issue Dec 4, 2024
OndrejSpanel added a commit to OndrejSpanel/quicklens that referenced this issue Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant