Skip to content

Instantly share code, notes, and snippets.

@igstan
Created April 4, 2014 17:02
Show Gist options
  • Save igstan/9978741 to your computer and use it in GitHub Desktop.
Save igstan/9978741 to your computer and use it in GitHub Desktop.
trait Fn[A,B] {
// AA is contravariant; BB is covariant
// Similar to Function1[-AA, +BB]
def apply[AA >: A, BB <: B](t: AA): BB
}
class Sup
class Sub extends Sup
def test[S >: Sub](a: Sub): Fn[S,S] =
new Fn[S,S] {
override def apply[AA >: S, BB <: S](b: AA): BB = if (true) a else b
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment