expectActualUtil: add parameter useOnSelf to runOnExpectAndAllActuals

This commit is contained in:
Dmitry Gridin
2019-10-22 21:49:12 +07:00
parent 4285f63bcc
commit 9aa49e61fe
3 changed files with 9 additions and 6 deletions
@@ -133,7 +133,7 @@ fun KtDeclaration.isEffectivelyActual(checkConstructor: Boolean = true): Boolean
else -> false
}
fun KtDeclaration.runOnExpectAndAllActuals(checkExpect: Boolean = true, f: (KtDeclaration) -> Unit) {
fun KtDeclaration.runOnExpectAndAllActuals(checkExpect: Boolean = true, useOnSelf: Boolean = false, f: (KtDeclaration) -> Unit) {
if (hasActualModifier()) {
val expectElement = liftToExpected()
expectElement?.actualsForExpected()?.forEach {
@@ -145,6 +145,8 @@ fun KtDeclaration.runOnExpectAndAllActuals(checkExpect: Boolean = true, f: (KtDe
} else if (!checkExpect || isExpectDeclaration()) {
actualsForExpected().forEach { f(it) }
}
if (useOnSelf) f(this)
}
fun KtDeclaration.collectAllExpectAndActualDeclaration(): Set<KtDeclaration> = when {