2
votes

I'm trying to create a value on a companion object based on the fields of a case class.

I'd like to do something like this:

case class A(
  val a: Int,
  val b: String
) extends MyTypeMacro

I'd like for this to add to add a value to its companion object...

object A { 
  //Generate...
  val c: B = //Code value derived from case class fields...
}

Because companion objects and classes have access to each other, shouldn't I be able to accomplish this by accessing the companion object from within the case class type macro?

Also... I'd like to add 'val c' whether object A is defined or not.

1

1 Answers

0
votes

Unfortunately that's not possible yet. We're playing with something along these lines, but it's very early stage, so I can't say anything definitive.