Skip to content

Instantly share code, notes, and snippets.

@p-pavel
Created February 23, 2017 09:15
Show Gist options
  • Save p-pavel/24e63bb9f40ea95fd988787a35ad4d80 to your computer and use it in GitHub Desktop.
Save p-pavel/24e63bb9f40ea95fd988787a35ad4d80 to your computer and use it in GitHub Desktop.
path dependent types and unapply
trait A {
type T
val t : T
}
object A {
def unapply(arg: A): Option[arg.T] = Some(arg.t)
}
def use(a : A) = a match {
case A(t) ⇒
val s: a.T = t // type mismatch.
// found t.type (with underlying type <unapply-selector>.T)
// required: a.T
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment