Created
June 11, 2012 13:45
-
-
Save jliszka/2910155 to your computer and use it in GitHub Desktop.
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
class !<:<[A, B] | |
implicit def any[A, B]: A !<:< B = new !<:<[A, B] | |
implicit def sub1[A, B >: A]: A !<:< B = new !<:<[A, B] | |
implicit def sub2[A, B >: A]: A !<:< B = new !<:<[A, B] | |
sealed trait ShardKeyNotSpecified | |
sealed trait ShardAware | |
trait Sharded | |
class ShardingOk[M, S](a: String) { override def toString = a } | |
implicit def sharded[M <: Sharded, State <: ShardAware]: ShardingOk[M, State] = new ShardingOk("a") | |
implicit def unsharded[M, State](implicit ev: M !<:< Sharded): ShardingOk[M, State] = new ShardingOk("b") | |
class A extends Sharded | |
class B | |
implicitly[ShardingOk[A, ShardKeyNotSpecified]] // Should fail | |
implicitly[ShardingOk[A, ShardAware]] // Should succeed | |
implicitly[ShardingOk[B, ShardKeyNotSpecified]] // Should succeed | |
/* | |
Sharded => ShardAware | |
~Sharded v ShardAware | |
~(Sharded & ~ShardAware) | |
~ShardAware => ~Sharded | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment