Make wrong phase name an error
This commit is contained in:
@@ -18,20 +18,20 @@ fun createPhaseConfig(
|
|||||||
arguments: CommonCompilerArguments,
|
arguments: CommonCompilerArguments,
|
||||||
messageCollector: MessageCollector
|
messageCollector: MessageCollector
|
||||||
): PhaseConfig {
|
): PhaseConfig {
|
||||||
fun warn(message: String) = messageCollector.report(CompilerMessageSeverity.WARNING, message)
|
fun report(message: String) = messageCollector.report(CompilerMessageSeverity.ERROR, message)
|
||||||
|
|
||||||
val phases = compoundPhase.toPhaseMap()
|
val phases = compoundPhase.toPhaseMap()
|
||||||
val enabled = computeEnabled(phases, arguments.disablePhases, ::warn).toMutableSet()
|
val enabled = computeEnabled(phases, arguments.disablePhases, ::report).toMutableSet()
|
||||||
val verbose = phaseSetFromArguments(phases, arguments.verbosePhases, ::warn)
|
val verbose = phaseSetFromArguments(phases, arguments.verbosePhases, ::report)
|
||||||
|
|
||||||
val beforeDumpSet = phaseSetFromArguments(phases, arguments.phasesToDumpBefore, ::warn)
|
val beforeDumpSet = phaseSetFromArguments(phases, arguments.phasesToDumpBefore, ::report)
|
||||||
val afterDumpSet = phaseSetFromArguments(phases, arguments.phasesToDumpAfter, ::warn)
|
val afterDumpSet = phaseSetFromArguments(phases, arguments.phasesToDumpAfter, ::report)
|
||||||
val bothDumpSet = phaseSetFromArguments(phases, arguments.phasesToDump, ::warn)
|
val bothDumpSet = phaseSetFromArguments(phases, arguments.phasesToDump, ::report)
|
||||||
val toDumpStateBefore = beforeDumpSet + bothDumpSet
|
val toDumpStateBefore = beforeDumpSet + bothDumpSet
|
||||||
val toDumpStateAfter = afterDumpSet + bothDumpSet
|
val toDumpStateAfter = afterDumpSet + bothDumpSet
|
||||||
val beforeValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidateBefore, ::warn)
|
val beforeValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidateBefore, ::report)
|
||||||
val afterValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidateAfter, ::warn)
|
val afterValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidateAfter, ::report)
|
||||||
val bothValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidate, ::warn)
|
val bothValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidate, ::report)
|
||||||
val toValidateStateBefore = beforeValidateSet + bothValidateSet
|
val toValidateStateBefore = beforeValidateSet + bothValidateSet
|
||||||
val toValidateStateAfter = afterValidateSet + bothValidateSet
|
val toValidateStateAfter = afterValidateSet + bothValidateSet
|
||||||
|
|
||||||
@@ -55,22 +55,22 @@ fun createPhaseConfig(
|
|||||||
private fun computeEnabled(
|
private fun computeEnabled(
|
||||||
phases: MutableMap<String, AnyNamedPhase>,
|
phases: MutableMap<String, AnyNamedPhase>,
|
||||||
namesOfDisabled: Array<String>?,
|
namesOfDisabled: Array<String>?,
|
||||||
warn: (String) -> Unit
|
report: (String) -> Unit
|
||||||
): Set<AnyNamedPhase> {
|
): Set<AnyNamedPhase> {
|
||||||
val disabledPhases = phaseSetFromArguments(phases, namesOfDisabled, warn)
|
val disabledPhases = phaseSetFromArguments(phases, namesOfDisabled, report)
|
||||||
return phases.values.toSet() - disabledPhases
|
return phases.values.toSet() - disabledPhases
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun phaseSetFromArguments(
|
private fun phaseSetFromArguments(
|
||||||
phases: MutableMap<String, AnyNamedPhase>,
|
phases: MutableMap<String, AnyNamedPhase>,
|
||||||
names: Array<String>?,
|
names: Array<String>?,
|
||||||
warn: (String) -> Unit
|
report: (String) -> Unit
|
||||||
): Set<AnyNamedPhase> {
|
): Set<AnyNamedPhase> {
|
||||||
if (names == null) return emptySet()
|
if (names == null) return emptySet()
|
||||||
if ("ALL" in names) return phases.values.toSet()
|
if ("ALL" in names) return phases.values.toSet()
|
||||||
return names.mapNotNull {
|
return names.mapNotNull {
|
||||||
phases[it] ?: run {
|
phases[it] ?: run {
|
||||||
warn("no phase named $it, ignoring")
|
report("no phase named $it")
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}.toSet()
|
}.toSet()
|
||||||
|
|||||||
+3
-3
@@ -1,3 +1,3 @@
|
|||||||
warning: no phase named qz, ignoring
|
error: no phase named qz
|
||||||
warning: no phase named qq, ignoring
|
error: no phase named qq
|
||||||
OK
|
COMPILATION_ERROR
|
||||||
|
|||||||
Reference in New Issue
Block a user