diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 9f346f97e742..9dcb10e15d16 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -44,6 +44,7 @@ trait CommonScalaSettings { self: Settings.SettingGroup => /** Other settings */ val encoding: Setting[String] = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding")) val usejavacp: Setting[Boolean] = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.", aliases = List("--use-java-class-path")) + val scalajs: Setting[Boolean] = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs")) /** Plugin-related setting */ val plugin: Setting[List[String]] = MultiStringSetting ("-Xplugin", "paths", "Load a plugin from each classpath.") @@ -54,7 +55,7 @@ trait CommonScalaSettings { self: Settings.SettingGroup => val pluginOptions: Setting[List[String]] = MultiStringSetting ("-P", "plugin:opt", "Pass an option to a plugin, e.g. -P::") } -class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings { +trait AllScalaSettings extends CommonScalaSettings { self: Settings.SettingGroup => // Keep synchronized with `classfileVersion` in `BCodeIdiomatic` private val minTargetVersion = 8 private val maxTargetVersion = 17 @@ -80,7 +81,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings { val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature")) val release: Setting[String] = ChoiceSetting("-release", "release", "Compile code with classes specific to the given version of the Java platform available on the classpath and emit bytecode for this version.", supportedReleaseVersions, "", aliases = List("--release")) val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source")) - val scalajs: Setting[Boolean] = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs")) val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", aliases = List("--unchecked")) val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id")) val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language")) @@ -225,3 +225,5 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings { val wikiSyntax: Setting[Boolean] = BooleanSetting("-Xwiki-syntax", "Retains the Scala2 behavior of using Wiki Syntax in Scaladoc.") } + +class ScalaSettings extends Settings.SettingGroup with AllScalaSettings diff --git a/scaladoc/src/dotty/tools/scaladoc/DocContext.scala b/scaladoc/src/dotty/tools/scaladoc/DocContext.scala index c63fbf6f315f..9f44069fece1 100644 --- a/scaladoc/src/dotty/tools/scaladoc/DocContext.scala +++ b/scaladoc/src/dotty/tools/scaladoc/DocContext.scala @@ -66,6 +66,9 @@ extension (r: report.type) def warn(m: String, e: Throwable)(using CompilerContext): Unit = r.warning(s"$m: ${throwableToString(e)}") + def echo(m: String)(using CompilerContext): Unit = + r.echo(m) + case class NavigationNode(name: String, dri: DRI, nested: Seq[NavigationNode]) case class DocContext(args: Scaladoc.Args, compilerContext: CompilerContext): diff --git a/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala b/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala index 4365e7b06198..3b9c8e9b9624 100644 --- a/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala +++ b/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala @@ -9,7 +9,7 @@ import collection.immutable.ArraySeq import java.nio.file.Files import dotty.tools.dotc.config.Settings._ -import dotty.tools.dotc.config.CommonScalaSettings +import dotty.tools.dotc.config.{ CommonScalaSettings, AllScalaSettings } import dotty.tools.dotc.reporting.Reporter import dotty.tools.dotc.core.Contexts._ @@ -100,7 +100,15 @@ object Scaladoc: } val commonScalaSettings = (new SettingGroup with CommonScalaSettings).allSettings - allSettings.filter(commonScalaSettings.contains).foreach(setInGlobal) + val allScalaSettings = (new SettingGroup with AllScalaSettings).allSettings + + val (shared, other) = allSettings + .filter(s => !s.isDefaultIn(summary.sstate)) + .filter(allScalaSettings.contains) + .partition(commonScalaSettings.contains) + shared.foreach(setInGlobal) + + if !other.isEmpty then report.echo(s"Skipping unused scalacOptions: ${other.map(_.name).mkString(", ")}") def parseTastyRoots(roots: String) = roots.split(File.pathSeparatorChar).toList.map(new File(_)) diff --git a/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala b/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala index 119305a68ad2..8320a5d6c2f7 100644 --- a/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala +++ b/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala @@ -9,14 +9,14 @@ import collection.immutable.ArraySeq import java.nio.file.Files import dotty.tools.dotc.config.Settings._ -import dotty.tools.dotc.config.CommonScalaSettings +import dotty.tools.dotc.config.AllScalaSettings import dotty.tools.scaladoc.Scaladoc._ import dotty.tools.dotc.config.Settings.Setting.value import dotty.tools.dotc.config.Properties._ import dotty.tools.dotc.config.CliCommand import dotty.tools.dotc.core.Contexts._ -class ScaladocSettings extends SettingGroup with CommonScalaSettings: +class ScaladocSettings extends SettingGroup with AllScalaSettings: val unsupportedSettings = Seq( // Options that we like to support bootclasspath, extdirs, javabootclasspath, encoding, usejavacp,