Created
March 4, 2014 21:51
-
-
Save pchiusano/9356534 to your computer and use it in GitHub Desktop.
TypeTag sometimes prints qualified names, and other times not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> import scala.reflect.runtime.universe._ | |
| import scala.reflect.runtime.universe._ | |
| scala> typeTag[List[Double]] | |
| res0: reflect.runtime.universe.TypeTag[List[Double]] = TypeTag[scala.List[Double]] | |
| scala> typeTag[List[Double]].tpe.toString | |
| res1: String = scala.List[Double] | |
| scala> def foo[A,B](f: A => B)(implicit T: TypeTag[B]) = T.tpe.toString | |
| foo: [A, B](f: A => B)(implicit T: reflect.runtime.universe.TypeTag[B])String | |
| scala> foo((i: Double) => List(i)) | |
| res2: String = List[Double] // why is this just 'List[Double]', while typeTag[List[Double]] prints as `scala.List[Double]`? | |
| scala> foo((i: Double) => scala.List(i): scala.List[Double]) | |
| res4: String = scala.List[Double] // ?? |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related, it looks like
TypeTagdoes not do anything with type aliases.