Skip to content

Scala 3: wrongly accepted modify does nothing #258

Description

@OndrejSpanel

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions