Implement CommonizerTarget.allLeaves

This commit is contained in:
sebastian.sellmair
2021-03-26 10:46:14 +01:00
parent a78645e858
commit 46a20c81cc
2 changed files with 27 additions and 0 deletions
@@ -111,6 +111,10 @@ public fun CommonizerTarget.withAllAncestors(): Set<CommonizerTarget> {
}
}
public fun CommonizerTarget.allLeaves(): Set<LeafCommonizerTarget> {
return withAllAncestors().filterIsInstance<LeafCommonizerTarget>().toSet()
}
public infix fun CommonizerTarget.isAncestorOf(other: CommonizerTarget): Boolean {
if (this is SharedCommonizerTarget) {
return targets.any { it == other } || targets.any { it.isAncestorOf(other) }