softwaremill / softwaremill/quicklens

Scala 3: wrongly accepted `modify` does nothing

Open
#258 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
852
Forks
53
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source files or tests; start by compiling the provided Main example under Scala 3 and comparing its behavior with Scala 2. Trace the modify(_.c) entry point and the copy-parameter handling. Done means Scala 3 rejects this case and a regression test covers it.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.