Skip to content

Instantly share code, notes, and snippets.

@xeno-by
Last active August 29, 2015 14:08
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 xeno-by/ab10aabdea7c13e29ec6 to your computer and use it in GitHub Desktop.
Save xeno-by/ab10aabdea7c13e29ec6 to your computer and use it in GitHub Desktop.
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