Skip to content

Instantly share code, notes, and snippets.

@pchiusano
Created March 4, 2014 21:51
Show Gist options
  • Select an option

  • Save pchiusano/9356534 to your computer and use it in GitHub Desktop.

Select an option

Save pchiusano/9356534 to your computer and use it in GitHub Desktop.
TypeTag sometimes prints qualified names, and other times not.
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] // ??
@pchiusano
Copy link
Copy Markdown
Author

Related, it looks like TypeTag does not do anything with type aliases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment