简体   繁体   中英

With scala.meta replacing scala.reflect, what will happen to ClassTags and TypeTags?

Or is this even relevant?

What I have in mind is using the ClassTag or TypeTag annotations, like so:

scala>
import scala.reflect.runtime.universe.TypeTag

def f[T : TypeTag](ls : List[T]) : String = {
  ???
}

results in :

f: [T](ls: List[T])(implicit evidence$1: reflect.runtime.universe.TypeTag[T])String

As you can see, the TypeTag is seen by the compiler which adds an implicit argument. Is there an equivalent in scala.meta ? How will this work, and will there be any changes in the way erasure is handled?

At the moment scala.meta does not provide runtime introspection, however, that's planned for future releases. APIs would be similar to scala.reflect (but in terms of scala.meta , eg different Abstract Syntax Trees , no exposed compiler internals, etc), and I really hope that end user wont see much difference.

So, functionality of ClassTag/TypeTag is not likely to disappear. Most probably, scala.meta will use a bridge ( paradise ) to get access to scalac internals (and that involves scala.reflect ).

Also note that scala.reflect will be supported in scala 2.x branch, but not in dotty .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM