scalatypeshigher-kinded-typesf-bounded-polymorphism

Recursive DataType in Scala


Hi I was wondering if someone could explain this signature I found in the Spark codebase. It looks like a recursive datatype, it's used to build the query plan so it kind of makes sense. Does anyone have anymore detailed knowledge of this?

abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product 

Solution

  • It is F-Bounded Types (or self-recursive types). Not scala specific, e.g. equivalent in java

    public abstract class Enum<E extends Enum<E>> implements Comparable<E>
    

    You can read here or here