goggles icon indicating copy to clipboard operation
goggles copied to clipboard

Can't access fields on varargs case class

Open kenbot opened this issue 8 years ago • 2 comments

If a case class field is marked as varargs, then "get" and "set" expressions cannot recognise the expected copy method.

Once #3 is resolved, "get" shouldn't be a problem at least.

scala> case class Foo(ns: Int*)
defined class Foo

scala> get"$res1.ns"
<console>:26: error: Can't update 'ns', because no 'copy' method found on Foo
       get"$res1.ns"
       ^

scala> set"$res1.ns" := Nil
<console>:26: error: Can't update 'ns', because no 'copy' method found on Foo
       set"$res1.ns" := Nil
       ^

kenbot avatar Jan 24 '17 21:01 kenbot

A copy method actually doesn't get generated for varargs case classes. Our options are:

  • Leave the (essentially accurate) error message as is
  • Produce a custom error message explaining the situation with varargs case classes
  • Put in a special case that can modify varargs case classes using the companion object or constructor, rather than copy.

kenbot avatar Feb 15 '17 07:02 kenbot

It can wait until after 1.0.

kenbot avatar Feb 15 '17 11:02 kenbot