Skip to content

Commit

Permalink
fixed a bug in parent methods resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
nikololiahim committed Mar 5, 2022
1 parent fbf8008 commit 891f4e3
Showing 1 changed file with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import cats.data.{EitherNel, NonEmptyList => Nel}
import cats.syntax.align._
import cats.syntax.apply._
import cats.syntax.either._
import cats.syntax.foldable._
import cats.syntax.functor._
import cats.syntax.parallel._
import higherkindness.droste.data.Fix
Expand Down Expand Up @@ -241,30 +240,22 @@ object Inliner {
}

def resolveParentsForInlining(objs: Map[EONamedBnd, CompleteObjectTree]): Map[EONamedBnd, ObjectTreeForInlining] = {
objs.fmap {
subTree =>
ObjectTree(
info = subTree.info.copy(
parentInfo = subTree.info.parentInfo.map(_ =>
ParentInfoForInlining(accumulateMethods(objs)(subTree))
)
),
children = resolveParentsForInlining(subTree.children)
)
def recurse(currentLevel: Map[EONamedBnd, CompleteObjectTree]): Map[EONamedBnd, ObjectTreeForInlining] = {
currentLevel.fmap {
subTree =>
ObjectTree(
info = subTree.info.copy(
parentInfo = subTree.info.parentInfo.map(_ =>
ParentInfoForInlining(accumulateMethods(objs)(subTree))
)
),
children = recurse(subTree.children)
)
}
}
}

def collectIndirectMethods(objs: Map[EONamedBnd, ObjectTreeForAnalysis]
): Vector[Map[EONamedBnd, MethodInfoForAnalysis]] = {
recurse(objs)

def collectIndirectMethodsFromSubTree(cur: ObjectTreeForAnalysis
): Vector[Map[EONamedBnd, MethodInfoForAnalysis]] = {
cur.info.indirectMethods +: collectIndirectMethods(cur.children)
}

objs.toList.foldMapK {
case (_, node) => collectIndirectMethodsFromSubTree(node)
}
}

type AnalysisInfo = ObjectInfoForAnalysis[ParentInfo[MethodInfo, ObjectInfoForAnalysis], MethodInfo]
Expand Down

0 comments on commit 891f4e3

Please sign in to comment.