From abd875a6a019c8d87603d07edfd183f292b28ec9 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Tue, 3 Dec 2024 20:23:56 +0100 Subject: [PATCH 1/5] Add `-Wall` [Cherry-picked 5727187a647dbce044ddb0e577c07f5710585997][modified] --- .../tools/dotc/config/ScalaSettings.scala | 64 +++++++++++-------- .../src/dotty/tools/dotc/core/Symbols.scala | 2 +- .../dotty/tools/dotc/parsing/Parsers.scala | 2 +- .../tools/dotc/transform/CheckUnused.scala | 2 +- .../tools/dotc/transform/init/Checker.scala | 5 +- .../src/dotty/tools/dotc/typer/Typer.scala | 4 +- 6 files changed, 47 insertions(+), 32 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 9a66d77b70df..140b4d3c2b5c 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -165,46 +165,50 @@ private sealed trait WarningSettings: val Whelp: Setting[Boolean] = BooleanSetting("-W", "Print a synopsis of warning options.") val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Werror", "Fail the compilation if there are any warnings.", aliases = List("-Xfatal-warnings")) - val WvalueDiscard: Setting[Boolean] = BooleanSetting("-Wvalue-discard", "Warn when non-Unit expression results are unused.") - val WNonUnitStatement = BooleanSetting("-Wnonunit-statement", "Warn when block statements are non-Unit expressions.") - val WenumCommentDiscard = BooleanSetting("-Wenum-comment-discard", "Warn when a comment ambiguously assigned to multiple enum cases is discarded.") - val Wunused: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting( + val Wall: Setting[Boolean] = BooleanSetting("-Wall", "Enable all warning settings.") + private val WvalueDiscard: Setting[Boolean] = BooleanSetting("-Wvalue-discard", "Warn when non-Unit expression results are unused.") + private val WNonUnitStatement = BooleanSetting("-Wnonunit-statement", "Warn when block statements are non-Unit expressions.") + private val WenumCommentDiscard = BooleanSetting("-Wenum-comment-discard", "Warn when a comment ambiguously assigned to multiple enum cases is discarded.") + private val Wunused: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting( name = "-Wunused", helpArg = "warning", descr = "Enable or disable specific `unused` warnings", - choices = List( + choices = List( ChoiceWithHelp("nowarn", ""), - ChoiceWithHelp("all",""), + ChoiceWithHelp("all", ""), ChoiceWithHelp( name = "imports", description = "Warn if an import selector is not referenced.\n" + "NOTE : overrided by -Wunused:strict-no-implicit-warn"), - ChoiceWithHelp("privates","Warn if a private member is unused"), - ChoiceWithHelp("locals","Warn if a local definition is unused"), - ChoiceWithHelp("explicits","Warn if an explicit parameter is unused"), - ChoiceWithHelp("implicits","Warn if an implicit parameter is unused"), - ChoiceWithHelp("params","Enable -Wunused:explicits,implicits"), - ChoiceWithHelp("linted","Enable -Wunused:imports,privates,locals,implicits"), - ChoiceWithHelp( - name = "strict-no-implicit-warn", - description = "Same as -Wunused:import, only for imports of explicit named members.\n" + - "NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all" - ), - // ChoiceWithHelp("patvars","Warn if a variable bound in a pattern is unused"), - ChoiceWithHelp( - name = "unsafe-warn-patvars", - description = "(UNSAFE) Warn if a variable bound in a pattern is unused.\n" + - "This warning can generate false positive, as warning cannot be\n" + - "suppressed yet." - ) + ChoiceWithHelp("privates", "Warn if a private member is unused"), + ChoiceWithHelp("locals", "Warn if a local definition is unused"), + ChoiceWithHelp("explicits", "Warn if an explicit parameter is unused"), + ChoiceWithHelp("implicits", "Warn if an implicit parameter is unused"), + ChoiceWithHelp("params", "Enable -Wunused:explicits,implicits"), + ChoiceWithHelp("linted", "Enable -Wunused:imports,privates,locals,implicits"), + ChoiceWithHelp( + name = "strict-no-implicit-warn", + description = "Same as -Wunused:import, only for imports of explicit named members.\n" + + "NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all" + ), + // ChoiceWithHelp("patvars","Warn if a variable bound in a pattern is unused"), + ChoiceWithHelp( + name = "unsafe-warn-patvars", + description = "(UNSAFE) Warn if a variable bound in a pattern is unused.\n" + + "This warning can generate false positive, as warning cannot be\n" + + "suppressed yet." + ) ), default = Nil ) object WunusedHas: def isChoiceSet(s: String)(using Context) = Wunused.value.pipe(us => us.contains(s)) - def allOr(s: String)(using Context) = Wunused.value.pipe(us => us.contains("all") || us.contains(s)) + def allOr(s: String)(using Context) = Wall.value || Wunused.value.pipe(us => us.contains("all") || us.contains(s)) def nowarn(using Context) = allOr("nowarn") + // Is any choice set for -Wunused? + def any(using Context): Boolean = Wunused.value.nonEmpty + // overrided by strict-no-implicit-warn def imports(using Context) = (allOr("imports") || allOr("linted")) && !(strictNoImplicitWarn) @@ -278,6 +282,16 @@ private sealed trait WarningSettings: |to prevent the shell from expanding patterns.""".stripMargin, ) + private val WcheckInit: Setting[Boolean] = BooleanSetting("-Wsafe-init", "Ensure safe initialization of objects.") + + object Whas: + def allOr(s: Setting[Boolean])(using Context): Boolean = + Wall.value || s.value + def valueDiscard(using Context): Boolean = allOr(WvalueDiscard) + def nonUnitStatement(using Context): Boolean = allOr(WNonUnitStatement) + def enumCommentDiscard(using Context): Boolean = allOr(WenumCommentDiscard) + def checkInit(using Context): Boolean = allOr(WcheckInit) + /** -X "Extended" or "Advanced" settings */ private sealed trait XSettings: self: SettingGroup => diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index eb60d76c77c4..893392794a51 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -80,7 +80,7 @@ object Symbols extends SymUtils { ctx.settings.YretainTrees.value || denot.owner.isTerm || // no risk of leaking memory after a run for these denot.isOneOf(InlineOrProxy) || // need to keep inline info - ctx.settings.YcheckInit.value // initialization check + ctx.settings.Whas.checkInit // initialization check /** The last denotation of this symbol */ private var lastDenot: SymDenotation = _ diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index a7f4cbd0952b..8778c099c5aa 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3923,7 +3923,7 @@ object Parsers { if (in.token == COMMA) { in.nextToken() val ids = commaSeparated(() => termIdent()) - if ctx.settings.WenumCommentDiscard.value then + if ctx.settings.Whas.enumCommentDiscard then in.getDocComment(start).foreach: comm => warning( em"""Ambiguous Scaladoc comment on multiple cases is ignored. diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index 337e41cf92de..d647d50560d3 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala @@ -58,7 +58,7 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke override def isRunnable(using Context): Boolean = super.isRunnable && - ctx.settings.Wunused.value.nonEmpty && + ctx.settings.WunusedHas.any && !ctx.isJava // ========== SETUP ============ diff --git a/compiler/src/dotty/tools/dotc/transform/init/Checker.scala b/compiler/src/dotty/tools/dotc/transform/init/Checker.scala index 0b6b80a6d83b..92f55f30edff 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Checker.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Checker.scala @@ -29,7 +29,7 @@ class Checker extends Phase: override val runsAfter = Set(Pickler.name) override def isEnabled(using Context): Boolean = - super.isEnabled && ctx.settings.YcheckInit.value + super.isEnabled && ctx.settings.Whas.checkInit def traverse(traverser: InitTreeTraverser)(using Context): Boolean = monitor(phaseName): val unit = ctx.compilationUnit @@ -46,7 +46,8 @@ class Checker extends Phase: cancellable { val classes = traverser.getClasses() - Semantic.checkClasses(classes)(using checkCtx) + if ctx.settings.Whas.checkInit then + Semantic.checkClasses(classes)(using checkCtx) } units0 diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 497a8cc454aa..f2d6cf0715ad 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -4196,7 +4196,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer // so will take the code path that decides on inlining val tree1 = adapt(tree, WildcardType, locked) checkStatementPurity(tree1)(tree, ctx.owner, isUnitExpr = true) - if (!ctx.isAfterTyper && !tree.isInstanceOf[Inlined] && ctx.settings.WvalueDiscard.value && !isThisTypeResult(tree)) { + if (!ctx.isAfterTyper && !tree.isInstanceOf[Inlined] && ctx.settings.Whas.valueDiscard && !isThisTypeResult(tree)) { report.warning(ValueDiscarding(tree.tpe), tree.srcPos) } return tpd.Block(tree1 :: Nil, unitLiteral) @@ -4498,7 +4498,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer && !isJavaApplication(t) // Java methods are inherently side-effecting // && !treeInfo.hasExplicitUnit(t) // suppressed by explicit expr: Unit // TODO Should explicit `: Unit` be added as warning suppression? ) - if ctx.settings.WNonUnitStatement.value && !ctx.isAfterTyper && checkInterestingShapes(t) then + if ctx.settings.Whas.nonUnitStatement && !ctx.isAfterTyper && checkInterestingShapes(t) then val where = t match { case Block(_, res) => res case If(_, thenpart, Literal(Constant(()))) => From ed97ccde7fc4d96e67bd0f6e0103d5a2d4654e0c Mon Sep 17 00:00:00 2001 From: Yichen Xu Date: Mon, 10 Jun 2024 18:25:07 +0100 Subject: [PATCH 2/5] Add test cases for `-Wall` [Cherry-picked d9e5fd4440e91af32672064e9dcfaa822add501a] --- tests/warn/i18559a.check | 12 ++++++++++++ tests/warn/i18559a.scala | 15 +++++++++++++++ tests/warn/i18559b.check | 12 ++++++++++++ tests/warn/i18559b.scala | 9 +++++++++ tests/warn/i18559c.check | 4 ++++ tests/warn/i18559c.scala | 15 +++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 tests/warn/i18559a.check create mode 100644 tests/warn/i18559a.scala create mode 100644 tests/warn/i18559b.check create mode 100644 tests/warn/i18559b.scala create mode 100644 tests/warn/i18559c.check create mode 100644 tests/warn/i18559c.scala diff --git a/tests/warn/i18559a.check b/tests/warn/i18559a.check new file mode 100644 index 000000000000..9652a4d97ac8 --- /dev/null +++ b/tests/warn/i18559a.check @@ -0,0 +1,12 @@ +-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:4:28 --------------------------------------------------------- +4 | import collection.mutable.Set // warn + | ^^^ + | unused import +-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:8:8 ---------------------------------------------------------- +8 | val x = 1 // warn + | ^ + | unused local definition +-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:11:26 -------------------------------------------------------- +11 | import SomeGivenImports.given // warn + | ^^^^^ + | unused import diff --git a/tests/warn/i18559a.scala b/tests/warn/i18559a.scala new file mode 100644 index 000000000000..24f1cae449b8 --- /dev/null +++ b/tests/warn/i18559a.scala @@ -0,0 +1,15 @@ +//> using options -Wall +// This test checks that -Wall turns on -Wunused:all if -Wunused is not set +object FooImportUnused: + import collection.mutable.Set // warn + +object FooUnusedLocal: + def test(): Unit = + val x = 1 // warn + +object FooGivenUnused: + import SomeGivenImports.given // warn + +object SomeGivenImports: + given Int = 0 + given String = "foo" diff --git a/tests/warn/i18559b.check b/tests/warn/i18559b.check new file mode 100644 index 000000000000..710df8234a9a --- /dev/null +++ b/tests/warn/i18559b.check @@ -0,0 +1,12 @@ +-- Warning: tests/warn/i18559b.scala:8:6 ------------------------------------------------------------------------------- +8 | val localFile: String = s"${url.##}.tmp" // warn + | ^ + | Access non-initialized value localFile. Calling trace: + | ├── class RemoteFile(url: String) extends AbstractFile: [ i18559b.scala:7 ] + | │ ^ + | ├── abstract class AbstractFile: [ i18559b.scala:3 ] + | │ ^ + | ├── val extension: String = name.substring(4) [ i18559b.scala:5 ] + | │ ^^^^ + | └── def name: String = localFile [ i18559b.scala:9 ] + | ^^^^^^^^^ diff --git a/tests/warn/i18559b.scala b/tests/warn/i18559b.scala new file mode 100644 index 000000000000..dac6e8c57c83 --- /dev/null +++ b/tests/warn/i18559b.scala @@ -0,0 +1,9 @@ +//> using options -Wall +// This test checks that -Wall turns on -Wsafe-init +abstract class AbstractFile: + def name: String + val extension: String = name.substring(4) + +class RemoteFile(url: String) extends AbstractFile: + val localFile: String = s"${url.##}.tmp" // warn + def name: String = localFile diff --git a/tests/warn/i18559c.check b/tests/warn/i18559c.check new file mode 100644 index 000000000000..7fd42a48db0c --- /dev/null +++ b/tests/warn/i18559c.check @@ -0,0 +1,4 @@ +-- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:8:8 ---------------------------------------------------------- +8 | val x = 1 // warn + | ^ + | unused local definition diff --git a/tests/warn/i18559c.scala b/tests/warn/i18559c.scala new file mode 100644 index 000000000000..3ca0c8893a66 --- /dev/null +++ b/tests/warn/i18559c.scala @@ -0,0 +1,15 @@ +//> using options -Wall -Wunused:locals +// This test checks that -Wall leaves -Wunused:... untouched if it is already set +object FooImportUnused: + import collection.mutable.Set // not warn + +object FooUnusedLocal: + def test(): Unit = + val x = 1 // warn + +object FooGivenUnused: + import SomeGivenImports.given // not warn + +object SomeGivenImports: + given Int = 0 + given String = "foo" From 0c269cb91c78b2c59448797270374bded31a8571 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Tue, 3 Dec 2024 20:24:51 +0100 Subject: [PATCH 3/5] Make `WcheckInit` public This is needed to make ScalaSettingsTests.scala compile [Cherry-picked 81f2c8e4d267f29f9d5aff72144759a2810ac288][modified] --- compiler/src/dotty/tools/dotc/config/ScalaSettings.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 140b4d3c2b5c..fa849cfd9614 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -282,7 +282,7 @@ private sealed trait WarningSettings: |to prevent the shell from expanding patterns.""".stripMargin, ) - private val WcheckInit: Setting[Boolean] = BooleanSetting("-Wsafe-init", "Ensure safe initialization of objects.") + val WcheckInit: Setting[Boolean] = BooleanSetting("-Wsafe-init", "Ensure safe initialization of objects.") object Whas: def allOr(s: Setting[Boolean])(using Context): Boolean = From 1879cb738649e38fb470f46e606ab9402d945ad6 Mon Sep 17 00:00:00 2001 From: Yichen Xu Date: Tue, 2 Jul 2024 02:47:05 +0200 Subject: [PATCH 4/5] Let `-Wall` override `-Wunused` [Cherry-picked af0412ced6ae8eca55a682ef3f8d42229cbd8782] --- compiler/src/dotty/tools/dotc/config/ScalaSettings.scala | 2 +- tests/warn/i18559c.check | 8 ++++++++ tests/warn/i18559c.scala | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index fa849cfd9614..28df97feb1c3 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -207,7 +207,7 @@ private sealed trait WarningSettings: def nowarn(using Context) = allOr("nowarn") // Is any choice set for -Wunused? - def any(using Context): Boolean = Wunused.value.nonEmpty + def any(using Context): Boolean = Wall.value || Wunused.value.nonEmpty // overrided by strict-no-implicit-warn def imports(using Context) = diff --git a/tests/warn/i18559c.check b/tests/warn/i18559c.check index 7fd42a48db0c..1c1bd86bf15f 100644 --- a/tests/warn/i18559c.check +++ b/tests/warn/i18559c.check @@ -1,4 +1,12 @@ +-- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:4:28 --------------------------------------------------------- +4 | import collection.mutable.Set // warn + | ^^^ + | unused import -- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:8:8 ---------------------------------------------------------- 8 | val x = 1 // warn | ^ | unused local definition +-- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:11:26 -------------------------------------------------------- +11 | import SomeGivenImports.given // warn + | ^^^^^ + | unused import diff --git a/tests/warn/i18559c.scala b/tests/warn/i18559c.scala index 3ca0c8893a66..34576cd831b0 100644 --- a/tests/warn/i18559c.scala +++ b/tests/warn/i18559c.scala @@ -1,14 +1,14 @@ //> using options -Wall -Wunused:locals -// This test checks that -Wall leaves -Wunused:... untouched if it is already set +// This test checks that -Wall overrides -Wunused:... if it is already set object FooImportUnused: - import collection.mutable.Set // not warn + import collection.mutable.Set // warn object FooUnusedLocal: def test(): Unit = val x = 1 // warn object FooGivenUnused: - import SomeGivenImports.given // not warn + import SomeGivenImports.given // warn object SomeGivenImports: given Int = 0 From f372d14cf96f533a0a4d311d6f9b4d1f016d302f Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Tue, 3 Dec 2024 20:58:47 +0100 Subject: [PATCH 5/5] Fix compilation --- .../dotty/tools/dotc/config/ScalaSettings.scala | 5 ++--- .../pos-with-compiler-cc/dotc/core/Symbols.scala | 2 +- .../dotc/transform/init/Checker.scala | 2 +- tests/warn/i18559b.check | 16 ++++++++-------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 28df97feb1c3..99568d2eee19 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -282,7 +282,7 @@ private sealed trait WarningSettings: |to prevent the shell from expanding patterns.""".stripMargin, ) - val WcheckInit: Setting[Boolean] = BooleanSetting("-Wsafe-init", "Ensure safe initialization of objects.") + val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects.") object Whas: def allOr(s: Setting[Boolean])(using Context): Boolean = @@ -290,7 +290,7 @@ private sealed trait WarningSettings: def valueDiscard(using Context): Boolean = allOr(WvalueDiscard) def nonUnitStatement(using Context): Boolean = allOr(WNonUnitStatement) def enumCommentDiscard(using Context): Boolean = allOr(WenumCommentDiscard) - def checkInit(using Context): Boolean = allOr(WcheckInit) + def checkInit(using Context): Boolean = allOr(YcheckInit) /** -X "Extended" or "Advanced" settings */ private sealed trait XSettings: @@ -429,7 +429,6 @@ private sealed trait YSettings: // Experimental language features val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Disable kind polymorphism.") val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.") - val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects.") val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation.") val YrecheckTest: Setting[Boolean] = BooleanSetting("-Yrecheck-test", "Run basic rechecking (internal test only).") val YccDebug: Setting[Boolean] = BooleanSetting("-Ycc-debug", "Used in conjunction with captureChecking language import, debug info for captured references.") diff --git a/tests/pos-with-compiler-cc/dotc/core/Symbols.scala b/tests/pos-with-compiler-cc/dotc/core/Symbols.scala index e4fa93b5bf05..1f0a9ad6595c 100644 --- a/tests/pos-with-compiler-cc/dotc/core/Symbols.scala +++ b/tests/pos-with-compiler-cc/dotc/core/Symbols.scala @@ -83,7 +83,7 @@ object Symbols { ctx.settings.YretainTrees.value || denot.owner.isTerm || // no risk of leaking memory after a run for these denot.isOneOf(InlineOrProxy) || // need to keep inline info - ctx.settings.YcheckInit.value // initialization check + ctx.settings.Whas.checkInit // initialization check /** The last denotation of this symbol */ private var lastDenot: SymDenotation = _ diff --git a/tests/pos-with-compiler-cc/dotc/transform/init/Checker.scala b/tests/pos-with-compiler-cc/dotc/transform/init/Checker.scala index 1efb3c88149e..94df04d8754d 100644 --- a/tests/pos-with-compiler-cc/dotc/transform/init/Checker.scala +++ b/tests/pos-with-compiler-cc/dotc/transform/init/Checker.scala @@ -28,7 +28,7 @@ class Checker extends Phase: override val runsAfter = Set(Pickler.name) override def isEnabled(using Context): Boolean = - super.isEnabled && ctx.settings.YcheckInit.value + super.isEnabled && ctx.settings.Whas.checkInit override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] = val checkCtx = ctx.fresh.setPhase(this.start) diff --git a/tests/warn/i18559b.check b/tests/warn/i18559b.check index 710df8234a9a..a270c231e515 100644 --- a/tests/warn/i18559b.check +++ b/tests/warn/i18559b.check @@ -2,11 +2,11 @@ 8 | val localFile: String = s"${url.##}.tmp" // warn | ^ | Access non-initialized value localFile. Calling trace: - | ├── class RemoteFile(url: String) extends AbstractFile: [ i18559b.scala:7 ] - | │ ^ - | ├── abstract class AbstractFile: [ i18559b.scala:3 ] - | │ ^ - | ├── val extension: String = name.substring(4) [ i18559b.scala:5 ] - | │ ^^^^ - | └── def name: String = localFile [ i18559b.scala:9 ] - | ^^^^^^^^^ + | -> class RemoteFile(url: String) extends AbstractFile: [ i18559b.scala:7 ] + | ^ + | -> abstract class AbstractFile: [ i18559b.scala:3 ] + | ^ + | -> val extension: String = name.substring(4) [ i18559b.scala:5 ] + | ^^^^ + | -> def name: String = localFile [ i18559b.scala:9 ] + | ^^^^^^^^^