Starting with Scala 2.11
, you can simply use:
yourGenericType.typeArgs.head
See the macros changelog point number 14.
More Related Contents:
- Generating a class from string and instantiating it in Scala 2.10
- How do I access default parameter values via Scala reflection?
- How to get ClassTag form TypeTag, or both at same time?
- Creating a method definition tree from a method symbol and a body
- Scala 2.10 reflection, how do I extract the field values from a case class, i.e. field list from case class
- What is a TypeTag and how do I use it?
- Scala’s “postfix ops”
- Get companion object instance with new Scala reflection API
- I want to get the type of a variable at runtime
- Pattern matching on generic type in Scala
- What’s the easiest way to use reify (get an AST of) an expression in Scala?
- Use case of scala.concurrent.blocking
- How to access parameter list of case class in a dotty macro
- Get a TypeTag from a Type?
- Static return type of Scala macros
- Scala generic method – No ClassTag available for T
- How to know if an object is an instance of a TypeTag’s type?
- error in if return in Scala
- How do I get around type erasure on Scala? Or, why can’t I get the type parameter of my collections?
- Call by name vs call by value in Scala, clarification needed
- What does the `#` operator mean in Scala?
- How to save DataFrame directly to Hive?
- Scala underscore – ERROR: missing parameter type for expanded function
- Setting up sbt to use Java 7 for compilation?
- How to use Column.isin with list?
- Is there a generic way to memoize in Scala?
- How to pattern match into an uppercase variable?
- How do I parse command line arguments in Scala? [closed]
- Futures / Success race
- Why does one select Scala type members with a hash instead of a dot?