From 0f4e95574081bd9a945fb5b32d157a32af840cd3 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 28 Jan 2014 17:29:58 +0300 Subject: adds Type.typeArgs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s very probable that this is the single most requested method in the entire reflection API of Scala 2.10. --- src/reflect/scala/reflect/api/Types.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala index e524af583b..0944171482 100644 --- a/src/reflect/scala/reflect/api/Types.scala +++ b/src/reflect/scala/reflect/api/Types.scala @@ -231,6 +231,21 @@ trait Types { */ def dealias: Type + /******* popular methods from subclasses *******/ + + /** List of type arguments ingrained in this type reference. + * Depending on your use case you might or might not want to call `dealias` first. + * scala> type T = List[Int] + * defined type alias T + * + * scala> typeOf[T].typeArgs + * res0: List[reflect.runtime.universe.Type] = List() + * + * scala> typeOf[T].dealias.typeArgs + * res1: List[reflect.runtime.universe.Type] = List(scala.Int) + */ + def typeArgs: List[Type] + /******************* helpers *******************/ /** Provides an alternate if type is NoType. -- cgit v1.2.3