Skip to content

Instantly share code, notes, and snippets.

@adriaanm
Created February 23, 2012 14:43
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 adriaanm/1893135 to your computer and use it in GitHub Desktop.
Save adriaanm/1893135 to your computer and use it in GitHub Desktop.
breaking virtpatmat with skolems
// exploring skolems/existentials that stem from scrutinee.tpe/unapply-type-params,
// and how they break virtpatmat
object Test {
object UnBounded {
def unapply[A](xs: UnBounded[A]): Option[A] = Some(xs.el)
}
class UnBounded[T](val el: T)
object Bounded {
def unapply[A <: Ord[A]](xs: Bounded[A]): Option[A] = Some(xs.el)
}
class Bounded[T <: Ord[T]](val el: T)
class Ord[T]
class IntO extends Ord[IntO]
object Exist {
def unapply(xs: Exist[_]): Option[_] = Some(xs.el)
}
class Exist[T](val el: T)
val s: PartialFunction[Any, Any] = {
case UnBounded(x) => x
case Exist(x) => x
}
abstract class I {
type x <: Ord[x]
type B = Bounded[x]
}
val t : PartialFunction[I#B, Any] = {
case Bounded(x) => x
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment