Factory methods of case classes

Exactly. And, you could also do this:

case class Foo()(s: => String)

such that the by-value parameter does not participate in pattern matching. I am just wondering what happens if you pass a by-value parameter by value again, if you wanted to provide a convenience factory method:

object Foo:
  def apply(s: => String) = Foo()(s)

Oh no, this does not work:

Double definition:
def apply()(v: => String): Foo in object Foo at line 5 and
def apply(v: => String): Foo in object Foo at line 8
have the same type after erasure.

Consider adding a @targetName annotation to one of the conflicting definitions
for disambiguation.

darn type erasure…