Github user bhlx3lyx7 commented on a diff in the pull request:

    https://github.com/apache/incubator-griffin/pull/396#discussion_r210843748
  
    --- Diff: 
measure/src/main/scala/org/apache/griffin/measure/step/builder/dsl/expr/TreeNode.scala
 ---
    @@ -18,28 +18,42 @@ under the License.
     */
     package org.apache.griffin.measure.step.builder.dsl.expr
     
    +import scala.reflect.ClassTag
    +
     trait TreeNode extends Serializable {
     
       var children = Seq[TreeNode]()
     
       def addChild(expr: TreeNode) = { children :+= expr }
       def addChildren(exprs: Seq[TreeNode]) = { children ++= exprs }
     
    -  def preOrderTraverseDepthFirst[T, A <: TreeNode](z: T)(seqOp: (A, T) => 
T, combOp: (T, T) => T): T = {
    -    if (this.isInstanceOf[A]) {
    -      val tv = seqOp(this.asInstanceOf[A], z)
    -      children.foldLeft(combOp(z, tv)) { (ov, tn) =>
    -        combOp(ov, tn.preOrderTraverseDepthFirst(z)(seqOp, combOp))
    +  def preOrderTraverseDepthFirst[T, A <: TreeNode](z: T)(seqOp: (A, T) => 
T, combOp: (T, T) => T)(implicit tag: ClassTag[A]): T = {
    +
    +    val clazz = tag.runtimeClass
    +
    +    this.getClass match {
    +      case `clazz` => {
    --- End diff --
    
    The code means this.getClass and T must be the same class. But in the 
usage, it traverses among different types of tree nodes, their concrete classes 
can't be matched to their parent class, which is not what we want.
    I doubt the modification of this file will destroy the process, I suggest 
you write a unit test for this.


---

Reply via email to