Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sealed trait Key[A] { type Inner = A }
- trait IntKey extends Key[Int]
- trait StringKey extends Key[String]
- // This should compile
- object Key {
- def work[A](m: Key[A]): m.Inner = m match {
- case i: IntKey => 1
- case s: StringKey => "1"
- }
- }
- // scala> Key work new IntKey{}
- // res0: Int = 1
- // scala> Key work new StringKey{}
- // res1: String = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement