IR: Make Phaser complain about duplicate phase names

(instead of silently throwing away all but the last phase
with the same name)
This commit is contained in:
Anton Bannykh
2019-03-12 17:19:48 +03:00
parent bb1660c688
commit 9dd9ef1cf0
@@ -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<String, AnyNamedPhase>()) { 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<AnyNamedPhase> get() = enabledMut