Created
October 24, 2013 16:33
-
-
Save ryanlecompte/7140499 to your computer and use it in GitHub Desktop.
scala 2.10 type erasure
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
scala> class Foo[+A,+B](a: A, b: B) | |
scala> def hi[A: ClassTag, B: ClassTag](f: Foo[Any,Any]) = f match { case _: Foo[Int,Int] => println("hi"); case _ => println("bye") } | |
<console>:9: warning: non-variable type argument Int in type pattern Foo[Int,Int] is unchecked since it is eliminated by erasure | |
def hi[A: ClassTag,B: ClassTag](f: Foo[Any,Any]) = f match { case _: Foo[Int,Int] => println("hi"); case _ => println("bye") } | |
^ | |
hi: [A, B](f: Foo[Any,Any])(implicit evidence$1: scala.reflect.ClassTag[A], implicit evidence$2: scala.reflect.ClassTag[B])Unit | |
scala> hi(new Foo("a","b")) | |
hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you are not using A and B here