Last active
August 29, 2015 14:08
-
-
Save xeno-by/ab10aabdea7c13e29ec6 to your computer and use it in GitHub Desktop.
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
object Test extends App { | |
trait Term | |
class If extends Term | |
trait AllowedTransformation[I, O] | |
implicit object term2Term extends AllowedTransformation[Term, Term] | |
class Foo[T] { | |
def filter[U <: T : scala.reflect.ClassTag](f: PartialFunction[U, Boolean]): Foo[U] = { | |
println(scala.reflect.classTag[U]) | |
null | |
} | |
def update[I <: T : scala.reflect.ClassTag, O <: T](f: PartialFunction[I, O])(implicit x: AllowedTransformation[I, O]): Foo[O] = { | |
println(scala.reflect.classTag[I]) | |
null | |
} | |
} | |
val foo1: Foo[Term] = new Foo[Term] | |
// WORKS | |
val foo2: Foo[If] = foo1.filter{ case _: If => true } | |
// DOESNT WORK | |
val foo3: Foo[If] = foo1.update{ case _: If => ??? : If } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment