I am trying to call a specialized collections library like FastUtil or Trove from generic Scala code. I would like to implement something like
def openHashMap[@specialized K, @specialized V]: ${K}2${V}OpenHashMap =
new ${K}2${V}OpenHashMap()
Where the ${X}
is clearly not valid Scala, but just my meta notation for text substitution,
so that openHashMap[Long, Double]
would return a Long2DoubleOpenHashMap
the type would be known at compile time. Is this possible with Scala macros. If so, which flavour? I know there are def macros, implicit macros, fundep materialization, macro annotations, type macros (now discontinued) ... and I think these are different in plain Scala-2.10, 2.10 macro paradise and Scala-2.11. Which, if any, of these are appropriate for this?
Or is there something else that can do this like byte code manipulation, language virtualization, ...? However, I do not believe the alternative I just mentioned can.