Skip to content

Instantly share code, notes, and snippets.

@VladUreche
Created August 25, 2014 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VladUreche/c2ed812dbe87b1ce8e92 to your computer and use it in GitHub Desktop.
Save VladUreche/c2ed812dbe87b1ce8e92 to your computer and use it in GitHub Desktop.
Pattern matcher + ClassTags => incorrect trees
$ cat test.scala
class Worker {
def receive[Id: scala.reflect.ClassTag] =
(x: Any) => x match {
case source: Id =>
val src: Id = source
}
}
$ scalac test.scala -Xprint:patmat
...
def receive[Id](implicit evidence$1: ClassTag[Id]) = ((x: Any) => {
case <synthetic> val x1: Any = x;
case7(){
<synthetic> val o9: Option[Id] = evidence$1.unapply(x1);
if (o9.isEmpty.unary_!)
if (o9.get.isInstanceOf[Id]) // (1) redundant
matchEnd6({
val src: Id = x1; // (2) outright incorrect
// Ident(x1).tpe = Id, although x1.tpe = Any
()
})
...
@VladUreche
Copy link
Author

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