def inject[T](implicit tt: TypeTag[T], nn: Not[T =:= Nothing]) = tt.toString inject // :11: error: Argument does not satisfy constraints: Not =:=[T,Nothing] // inject // ^ inject[Nothing] // :11: error: Argument does not satisfy constraints: Not =:=[Nothing,Nothing] // inject[Nothing] // ^ val foo: String = inject // :10: error: Argument does not satisfy constraints: Not =:=[T,Nothing] // val foo: String = inject // ^ inject[String] // res3: String = TypeTag[String] inject[Int] // res4: String = TypeTag[Int] def union1[T](t: T)(implicit c: (T =:= String) Or (T =:= Int)) = t match { case s: String => println(s"Some nice string: $s") case i: Int => println(s"Some int: $i") } type V[A, B] = {type l[T] = (T <:< A) Or (T <:< B)} def union[T: (String V Int)#l](t: T) = t match { case s: String => println(s"Some nice string: $s") case i: Int => println(s"Some int: $i") } union("Test") // Some nice string: Test union(265) // Some int: 265 union(2.0) // :11: error: Argument does not satisfy constraints: =:=[Double,String] Or =:=[Double,Int] // union(2.0) // ^ def sort[T: Ordering](list: List[T])(implicit c: Not[(T =:= String) Or Numeric[T]]) = list.sorted sealed trait Color case object Red extends Color case object Green extends Color case object Blue extends Color case object Yellow extends Color case object Magenta extends Color def printColor1[T](t: T)(implicit c: (T =:= Red.type) Or (T =:= Green.type) Or (T =:= Magenta.type)) = println(t) def printColor[T](t: T)(implicit c: (T <:< Color) And Not[T =:= Color] And Not[(T =:= Yellow.type) Or (T =:= Blue.type)]) = println(t) printColor(Yellow) // :11: error: Argument does not satisfy constraints: And[<:<[Yellow.type,Color],Not[=:=[Yellow.type,Color]]] And Not[Or[=:=[Yellow.type,Yellow.type],=:=[Yellow.type,Blue.type]]] // printColor(Yellow) // ^ val c: Color = Magenta // c: Color = Magenta printColor(c) // :12: error: Argument does not satisfy constraints: And[<:<[Color,Color],Not[=:=[Color,Color]]] And Not[Or[=:=[Color,Yellow.type],=:=[Color,Blue.type]]] // printColor(c) // ^ printColor(Magenta) // Magenta