diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt index a223fe66091..b98b5f9791c 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt @@ -115,12 +115,15 @@ class TestConfigurationBuilder { artifactKind: TestArtifactKind, init: HandlersStepBuilder.() -> Unit ): HandlersStepBuilder { - val step = handlersStep(artifactKind, init) - val previouslyContainedStep = namedSteps.put(name, step) - if (previouslyContainedStep != null) { - error { "Step with name \"$name\" already registered" } + val previouslyContainedStep = namedStepOfType(name) + if (previouslyContainedStep == null) { + val step = handlersStep(artifactKind, init) + namedSteps[name] = step + return step + } else { + configureNamedHandlersStep(name, artifactKind, init) + return previouslyContainedStep } - return step } inline fun > configureNamedHandlersStep( @@ -128,11 +131,14 @@ class TestConfigurationBuilder { artifactKind: TestArtifactKind, init: HandlersStepBuilder.() -> Unit ) { - val step = namedSteps[name] ?: error { "Step \"$name\" not found" } - require(step is HandlersStepBuilder<*>) { "Step '$name' is not a handlers step" } + val step = namedStepOfType(name) ?: error { "Step \"$name\" not found" } require(step.artifactKind == artifactKind) { "Step kind: ${step.artifactKind}, passed kind is $artifactKind" } + step.apply(init) + } + + fun > namedStepOfType(name: String): HandlersStepBuilder? { @Suppress("UNCHECKED_CAST") - (step as HandlersStepBuilder).apply(init) + return namedSteps[name] as HandlersStepBuilder? } fun useSourcePreprocessor(vararg preprocessors: Constructor, needToPrepend: Boolean = false) {