Scala self-recursive types

One of the advantages of using a statically typed language is that you can use the type system to enforce some constraints. Scala provides self-recursive types, aka F-bounded polymorphic types that–along with self types–let you put powerful constraint to your type definitions. Self-recursive type definition Terminology apart, let me show you one of the use cases where this could be useful. Consider the following example which does not use a self-recursive type: