summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/macros
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-01-28 12:05:34 +0300
committerEugene Burmako <xeno.by@gmail.com>2014-02-14 14:09:17 +0100
commitada0252d4494611904c15cc5da72654c1a180a8f (patch)
tree662e972fdf295e57bdb5bcc6b47aafec7a242ea8 /src/reflect/scala/reflect/macros
parentb0176294060c9ce8b86d71e7bc8a7a13cef15b1e (diff)
downloadscala-ada0252d4494611904c15cc5da72654c1a180a8f.tar.gz
scala-ada0252d4494611904c15cc5da72654c1a180a8f.tar.bz2
scala-ada0252d4494611904c15cc5da72654c1a180a8f.zip
SI-8194 adds Universe.symbolOf[T]
A very frequent use for a result of typeOf is obtaining an underlying type symbol. Another thing that comes up occasionally at stack overflow is a request to add facilities for reification of symbols. This naturally suggests that our reflection API would benefit from a method called symbolOf that can take a term or type argument and return an underlying symbol. While an API to extract a term symbol from an expression needs some time to be designed and then implemented robustly (we don’t have untyped macros so we’ll have to account for various desugarings), meaning that we probably won’t have time for that in 2.11, a type symbol extractor seems to be a very low-hanging fruit.
Diffstat (limited to 'src/reflect/scala/reflect/macros')
-rw-r--r--src/reflect/scala/reflect/macros/Aliases.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/macros/Aliases.scala b/src/reflect/scala/reflect/macros/Aliases.scala
index 8651661c63..bd918bbe56 100644
--- a/src/reflect/scala/reflect/macros/Aliases.scala
+++ b/src/reflect/scala/reflect/macros/Aliases.scala
@@ -126,4 +126,9 @@ trait Aliases {
* Type of `x` as derived from a type tag.
*/
def typeOf[T: TypeTag](x: => T): Type = typeOf[T]
+
+ /**
+ * Type symbol of `x` as derived from a type tag.
+ */
+ def symbolOf[T: WeakTypeTag]: universe.TypeSymbol = universe.symbolOf[T]
}