Created
August 25, 2014 14:50
-
-
Save VladUreche/c2ed812dbe87b1ce8e92 to your computer and use it in GitHub Desktop.
Pattern matcher + ClassTags => incorrect trees
This file contains hidden or 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
$ 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 | |
() | |
}) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussion: https://groups.google.com/forum/#!topic/scala-internals/OICw8rXLyiI