Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/config/CliCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package config
import Settings.*
import core.Contexts.*
import printing.Highlighting
import reporting.NoExplanation

import dotty.tools.dotc.util.chaining.*
import scala.PartialFunction.cond
Expand Down Expand Up @@ -125,7 +126,8 @@ trait CliCommand:
*/
def checkUsage(summary: ArgsSummary, sourcesRequired: Boolean)(using settings: ConcreteSettings)(using SettingsState, Context): Option[List[String]] =
// Print all warnings encountered during arguments parsing
summary.warnings.foreach(report.warning(_))
for warning <- summary.warnings; message = NoExplanation(warning) do
report.configurationWarning(message)

if summary.errors.nonEmpty then
summary.errors foreach (report.error(_))
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ object PathResolver {
}
else inContext(ContextBase().initialCtx) {
val ArgsSummary(sstate, rest, errors, warnings) =
ctx.settings.processArguments(args.toList, true, ctx.settingsState)
ctx.settings.processArguments(args.toList, processAll = true, ctx.settingsState)
errors.foreach(println)
val pr = inContext(ctx.fresh.setSettings(sstate)) {
new PathResolver()
Expand Down
381 changes: 207 additions & 174 deletions compiler/src/dotty/tools/dotc/config/Settings.scala

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ object report:
private def issueWarning(warning: Warning)(using Context): Unit =
ctx.reporter.report(warning)

def configurationWarning(msg: Message, pos: SrcPos = NoSourcePosition)(using Context): Unit =
issueWarning(ConfigurationWarning(msg, pos.sourcePos))

def deprecationWarning(msg: Message, pos: SrcPos, origin: String = "")(using Context): Unit =
issueWarning(DeprecationWarning(msg, addInlineds(pos), origin))

Expand Down
6 changes: 6 additions & 0 deletions compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ object Diagnostic:
extends ConditionalWarning(msg, pos), OriginWarning(origin):
def enablingOption(using Context): Setting[Boolean] = ctx.settings.deprecation

class ConfigurationWarning(msg: Message, pos: SourcePosition) extends ConditionalWarning(msg, pos):
def enablingOption(using Context): Setting[Boolean] = ConfigurationWarning.setting
override def isSummarizedConditional(using Context): Boolean = false
object ConfigurationWarning:
private val setting = Setting.internal("-configuration", value = true)

class MigrationWarning(
msg: Message,
pos: SourcePosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ trait MessageRendering {
case _: UncheckedWarning => ("unchecked", "")
case w: DeprecationWarning => ("deprecation", w.origin)
case _: FeatureWarning => ("feature", "")
case _: ConfigurationWarning => ("configuration", "")
case _ => ("", "")
var entitled = false
def addHelp(what: String)(value: String): Unit =
Expand Down
9 changes: 4 additions & 5 deletions compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import dotty.tools.dotc.util.NoSourcePosition

import java.io.{BufferedReader, PrintWriter}
import scala.annotation.internal.sharable
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import core.Decorators.{em, toMessage}
import core.handleRecursive

Expand Down Expand Up @@ -235,14 +235,13 @@ abstract class Reporter extends interfaces.ReporterResult {
report(new Error("No warnings can be incurred under -Werror (or -Xfatal-warnings)", NoSourcePosition))

/** Summary of warnings and errors */
def summary: String = {
val b = new mutable.ListBuffer[String]
def summary: String =
val b = ListBuffer.empty[String]
if (warningCount > 0)
b += countString(warningCount, "warning") + " found"
if (errorCount > 0)
b += countString(errorCount, "error") + " found"
b.mkString("\n")
}

def summarizeUnreportedWarnings()(using Context): Unit =
for (settingName, count) <- unreportedWarnings do
Expand All @@ -253,7 +252,7 @@ abstract class Reporter extends interfaces.ReporterResult {
/** Print the summary of warnings and errors */
def printSummary()(using Context): Unit =
val s = summary
if (s != "") doReport(Warning(s.toMessage, NoSourcePosition))
if !s.isEmpty then doReport(Warning(s.toMessage, NoSourcePosition))

/** Returns a string meaning "n elements". */
protected def countString(n: Int, elements: String): String = n match {
Expand Down
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/WConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ enum MessageFilter:
import Diagnostic.*
this match
case Any => true
case Configuration => message.isInstanceOf[ConfigurationWarning]
case Deprecated => message.isInstanceOf[DeprecationWarning]
case Feature => message.isInstanceOf[FeatureWarning]
case Unchecked => message.isInstanceOf[UncheckedWarning]
case MessageID(errorId) => message.msg.errorId == errorId
case MessagePattern(pattern) =>
val noHighlight = message.msg.message.replaceAll("\\e\\[[\\d;]*[^\\d;]","")
val noHighlight = message.msg.message.replaceAll("\\e\\[[\\d;]*[^\\d;]", "")
pattern.findFirstIn(noHighlight).nonEmpty
case SourcePattern(pattern) =>
val source = message.position.orElse(NoSourcePosition).source()
Expand All @@ -39,7 +40,7 @@ enum MessageFilter:
case _ => false
case None => false

case Any, Deprecated, Feature, Unchecked, None
case Any, Configuration, Deprecated, Feature, Unchecked, None
case MessagePattern(pattern: Regex)
case MessageID(errorId: ErrorMessageID)
case SourcePattern(pattern: Regex)
Expand Down Expand Up @@ -98,6 +99,7 @@ object WConf:
catch case _: IllegalArgumentException => Left(s"unknown error message name: $conf")

case "cat" => conf match
case "configuration" => Right(Configuration)
case "deprecation" => Right(Deprecated)
case "feature" => Right(Feature)
case "unchecked" => Right(Unchecked)
Expand Down
Loading
Loading