Dmytro Mitin's answer is a good one if you need to exclude one out of many. If, on the other hand, you need to restrict inclusion to a few, out of the many, here's one way to do it.
sealed trait A {val id: Int}
class W extends A {val id = 13}
class X extends A {val id = 17}
class Y extends A {val id = 18}
class Z extends A {val id = 21}
trait Contra[-X]
type Union[A,B] = {
type Check[Z] = Contra[Contra[Z]] <:< Contra[Contra[A] with Contra[B]]
}
def myStrictFunc[T <: A : Union[X,Y]#Check](t: T): Int = t.id
myStrictFunc(new X) //res0: Int = 17
myStrictFunc(new Y) //res1: Int = 18
myStrictFunc(new Z) //won't compile
myStrictFunc(new W) //won't compile
The Union
type can be expanded to 3, 4, or more types, but the code gets a little verbose.