0

Basically I'm imagining the following.

trait A[T] {
  def get(idx: Int): U
}

The macro comes in the use. Ideally I want to be able to use get(0), get(1) as macros where the proper return type will be known. Is this possible?

A Question Asker
  • 3,339
  • 7
  • 31
  • 39

1 Answers1

1

Yes. Just specify the return type as Any and make your macro whitebox (http://docs.scala-lang.org/overviews/macros/blackbox-whitebox.html#blackbox_and_whitebox_macros). Whitebox macro expansions assume their actual type, not the declared type of the macro definition.

Eugene Burmako
  • 13,028
  • 1
  • 46
  • 59