This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 8.6, “How to mark a Scala trait so it can only be subclassed by a certain type.”
You want to mark your trait so it can only be used by types that extend a given base type.
To make sure a trait named
MyTrait can only be mixed into a class that is a subclass of a type named
BaseType, begin your trait with a
this: BaseType => declaration, as shown here: