The code loos like this. I can't figure out why the planType in this brackets .And I also write some tests to conquer it, but no value.
abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanType] {}
The code loos like this. I can't figure out why the planType in this brackets .And I also write some tests to conquer it, but no value.
abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanType] {}
The writer of this abstract class wants the child classes to be only able to use PlanType which are of the type QueryPlan[PlanType] or its subtypes.
This is also termed Type-Narrowing in scala documentation. The QueryPlan[PlanType] is the upper-type bound in this example.
So, the class QueryPlan[PlanType <: QueryPlan[PlanType]] cannot have all the PlanTypes that are inherited from its parent TreeNode[PlanType]
In the example below, the type on left is narrowest, while Any on the right will be the widest type
QueryPlan[PlanType] <: TreeNode[PlanType] <: ParentPlanType <: Any