From e927ac5fc35fc1ed6ecbeec7a80390d70eec8345 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Thu, 9 Nov 2023 12:23:10 +0100 Subject: [PATCH] Scripting: ignore some diags if artefact is resolved The failure diagnostics from resolvers are ignored now if followed by a successful result from a following resolver. #KT-63352 fixed the commit is idirectly tested by the test MainKtsIT.testUseSlf4j from the followin commit "Scripting: ignore some diags if artefact is resolved", namely without these changes, additional two warnings are reported in this test. --- .../src/kotlin/script/experimental/api/errorHandling.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/scripting/common/src/kotlin/script/experimental/api/errorHandling.kt b/libraries/scripting/common/src/kotlin/script/experimental/api/errorHandling.kt index 0b64f7cdeb1..92607373821 100644 --- a/libraries/scripting/common/src/kotlin/script/experimental/api/errorHandling.kt +++ b/libraries/scripting/common/src/kotlin/script/experimental/api/errorHandling.kt @@ -310,12 +310,15 @@ fun ResultWithDiagnostics.valueOrThrow(): R = valueOr { class IterableResultsCollector { private val diagnostics = mutableListOf() + private val failureResults = mutableListOf>>() private val values = mutableListOf() fun add(result: ResultWithDiagnostics>) { - diagnostics.addAll(result.reports) if (result is ResultWithDiagnostics.Success) { + diagnostics.addAll(result.reports) values.addAll(result.value) + } else { + failureResults.add(result) } } @@ -329,7 +332,7 @@ class IterableResultsCollector { fun getResult(): ResultWithDiagnostics> { return if (values.isEmpty()) { - ResultWithDiagnostics.Failure(diagnostics) + ResultWithDiagnostics.Failure(diagnostics + failureResults.flatMap { it.reports }) } else { ResultWithDiagnostics.Success(values, diagnostics) }