Created
February 2, 2013 07:24
-
-
Save xeno-by/4696431 to your computer and use it in GitHub Desktop.
This file contains 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
import scala.reflect.runtime.universe._ | |
import scala.reflect.api.{TypeCreator, Universe} | |
object Test extends App { | |
def foo[T: TypeTag] = TypeTag(typeTag[T].mirror, new TypeCreator { | |
override def apply[U <: Universe with Singleton](m: scala.reflect.api.Mirror[U]): U # Type = { | |
typeTag[T].in(m).tpe match { | |
case TypeRef(_, _, argHead :: Nil) => argHead.asInstanceOf[U#Type] | |
} | |
} | |
}) | |
println(foo[List[Int]]) | |
} | |
08:23 ~/Projects/Kepler_snippet00/sandbox (topic/snippet00)$ scalac Test.scala && scala Test | |
TypeTag[Int] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment