Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.reflect.runtime.universe._
- case class B[T](thing: Option[T])
- object Factory {
- def get: B[_] = B(Some(0))
- }
- class Blah {
- // Type info lost here
- val someB = Factory.get
- }
- def checkType[T: TypeTag](in: T) = {
- println(typeOf[T])
- typeOf[T] match {
- case o if o =:= typeOf[Option[Int]] => "hit!!"
- }
- }
- def process(in: Blah) = {
- in.someB match {
- case b: B[_] => checkType(b.thing)
- }
- }
- process(new Blah)
Add Comment
Please, Sign In to add comment