Created
February 5, 2014 23:33
-
-
Save paulp/8835608 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
trait Foo | |
class Ev[T] | |
case class Bar[A](xs: Ev[A], f: A => Unit) extends Foo | |
object Test { | |
def main(args: Array[String]) { | |
val foo: Foo = new Bar(new Ev[Int], println(_: Int)) | |
// This is disallowed. | |
// foo match { case x: Bar[a] => x.f(x.xs) } | |
// This isn't. | |
foo match { case Bar(xs, f) => f(xs) } | |
} | |
} | |
// java.lang.ClassCastException: Ev cannot be cast to java.lang.Integer | |
// at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:105) | |
// at Test$$anonfun$1.apply(a.scala:7) | |
// at Test$.main(a.scala:12) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment