Created
February 23, 2017 09:15
-
-
Save p-pavel/24e63bb9f40ea95fd988787a35ad4d80 to your computer and use it in GitHub Desktop.
path dependent types and unapply
This file contains 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
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