From 9dd9ef1cf03b12b75adb123a85c953813f776c35 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Tue, 12 Mar 2019 17:19:48 +0300 Subject: [PATCH] IR: Make Phaser complain about duplicate phase names (instead of silently throwing away all but the last phase with the same name) --- .../jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt index 0121d8a728a..90f8e59f582 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseConfig.kt @@ -6,7 +6,11 @@ import org.jetbrains.kotlin.config.CompilerConfigurationKey class PhaseConfig(private val compoundPhase: CompilerPhase<*, *, *>, config: CompilerConfiguration) { - val phases = compoundPhase.getNamedSubphases().map { (_, phase) -> phase }.associate { it.name to it } + val phases = compoundPhase.getNamedSubphases().fold(mutableMapOf()) { acc, (_, phase) -> + check(phase.name !in acc) { "Duplicate phase name '${phase.name}'"} + acc[phase.name] = phase + acc + } private val enabledMut = computeEnabled(config).toMutableSet() val enabled: Set get() = enabledMut