Skip to content

Commit d1df8db

Browse files
committed
Introduce -Yreporter
1 parent e583d6a commit d1df8db

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

compiler/src/dotty/tools/dotc/Driver.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,26 @@ class Driver {
8484
MacroClassLoader.init(ictx)
8585
Positioned.init(using ictx)
8686

87-
inContext(ictx) {
87+
inContext(ictx):
8888
if !ctx.settings.XdropComments.value || ctx.settings.XreadComments.value then
8989
ictx.setProperty(ContextDoc, new ContextDocstrings)
9090
val fileNamesOrNone = command.checkUsage(summary, sourcesRequired)(using ctx.settings)(using ctx.settingsState)
9191
fileNamesOrNone.map: fileNames =>
9292
val files = fileNames.map(ctx.getFile)
9393
(files, fromTastySetup(files))
9494
.tap: _ =>
95-
if ctx.settings.YnoReporter.value then
96-
ictx.setReporter(Reporter.SilentReporter())
97-
}
95+
if !ctx.settings.Yreporter.isDefault then
96+
ctx.settings.Yreporter.value match
97+
case "help" =>
98+
case reporterClassName =>
99+
try
100+
Class.forName(reporterClassName).getDeclaredConstructor().newInstance() match
101+
case userReporter: Reporter =>
102+
ictx.setReporter(userReporter)
103+
case badReporter => report.error:
104+
em"Not a reporter: ${ctx.settings.Yreporter.value}"
105+
catch case e: ReflectiveOperationException => report.error:
106+
em"Could not create reporter ${ctx.settings.Yreporter.value}: ${e}"
98107
}
99108

100109
/** Setup extra classpath of tasty and jar files */

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ private sealed trait YSettings:
397397
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting(ForkSetting, "YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
398398
val YnoStdlibPatches: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-stdlib-patches", "Do not patch stdlib files (temporary and only to be used for the stdlib migration)", false)
399399

400-
val YnoReporter: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-reporter", "Diagnostics are silently consumed")
400+
val Yreporter: Setting[String] = StringSetting(ForkSetting, name = "Yreporter", helpArg = "<class>", descr = "Specify a dotty.tools.dotc.reporting.Reporter", default = "dotty.tools.dotc.reporting.ConsoleReporter")
401401

402402
val Yscala2Unpickler: Setting[String] = StringSetting(ForkSetting, "Yscala2-unpickler", "", "Control where we may get Scala 2 symbols from. This is either \"always\", \"never\", or a classpath.", "always")
403403

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object Reporter {
3030
override def report(dia: Diagnostic)(using Context): Unit = ()
3131
}
3232

33-
/** A reporter for -Yno-reporter [sic] */
33+
/** A silent reporter for testing */
3434
class SilentReporter extends Reporter:
3535
def doReport(dia: Diagnostic)(using Context): Unit = ()
3636

compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class SemanticdbTests:
144144
"-Xignore-scala2-macros",
145145
"-usejavacp",
146146
"-Wunused:all",
147-
"-Yno-reporter",
147+
"-Yreporter:dotty.tools.dotc.reporting.Reporter$SilentReporter",
148148
) ++ inputFiles().map(_.toString)
149149
val exit = Main.process(args)
150150
assertFalse(s"dotc errors: ${exit.errorCount}", exit.hasErrors)

0 commit comments

Comments
 (0)