@@ -165,46 +165,50 @@ private sealed trait WarningSettings:
165165
166166 val Whelp : Setting [Boolean ] = BooleanSetting (" -W" , " Print a synopsis of warning options." )
167167 val XfatalWarnings : Setting [Boolean ] = BooleanSetting (" -Werror" , " Fail the compilation if there are any warnings." , aliases = List (" -Xfatal-warnings" ))
168- val WvalueDiscard : Setting [Boolean ] = BooleanSetting (" -Wvalue-discard" , " Warn when non-Unit expression results are unused." )
169- val WNonUnitStatement = BooleanSetting (" -Wnonunit-statement" , " Warn when block statements are non-Unit expressions." )
170- val WenumCommentDiscard = BooleanSetting (" -Wenum-comment-discard" , " Warn when a comment ambiguously assigned to multiple enum cases is discarded." )
171- val Wunused : Setting [List [ChoiceWithHelp [String ]]] = MultiChoiceHelpSetting (
168+ val Wall : Setting [Boolean ] = BooleanSetting (" -Wall" , " Enable all warning settings." )
169+ private val WvalueDiscard : Setting [Boolean ] = BooleanSetting (" -Wvalue-discard" , " Warn when non-Unit expression results are unused." )
170+ private val WNonUnitStatement = BooleanSetting (" -Wnonunit-statement" , " Warn when block statements are non-Unit expressions." )
171+ private val WenumCommentDiscard = BooleanSetting (" -Wenum-comment-discard" , " Warn when a comment ambiguously assigned to multiple enum cases is discarded." )
172+ private val Wunused : Setting [List [ChoiceWithHelp [String ]]] = MultiChoiceHelpSetting (
172173 name = " -Wunused" ,
173174 helpArg = " warning" ,
174175 descr = " Enable or disable specific `unused` warnings" ,
175- choices = List (
176+ choices = List (
176177 ChoiceWithHelp (" nowarn" , " " ),
177- ChoiceWithHelp (" all" ," " ),
178+ ChoiceWithHelp (" all" , " " ),
178179 ChoiceWithHelp (
179180 name = " imports" ,
180181 description = " Warn if an import selector is not referenced.\n " +
181182 " NOTE : overrided by -Wunused:strict-no-implicit-warn" ),
182- ChoiceWithHelp (" privates" ," Warn if a private member is unused" ),
183- ChoiceWithHelp (" locals" ," Warn if a local definition is unused" ),
184- ChoiceWithHelp (" explicits" ," Warn if an explicit parameter is unused" ),
185- ChoiceWithHelp (" implicits" ," Warn if an implicit parameter is unused" ),
186- ChoiceWithHelp (" params" ," Enable -Wunused:explicits,implicits" ),
187- ChoiceWithHelp (" linted" ," Enable -Wunused:imports,privates,locals,implicits" ),
188- ChoiceWithHelp (
189- name = " strict-no-implicit-warn" ,
190- description = " Same as -Wunused:import, only for imports of explicit named members.\n " +
191- " NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all"
192- ),
193- // ChoiceWithHelp("patvars","Warn if a variable bound in a pattern is unused"),
194- ChoiceWithHelp (
195- name = " unsafe-warn-patvars" ,
196- description = " (UNSAFE) Warn if a variable bound in a pattern is unused.\n " +
197- " This warning can generate false positive, as warning cannot be\n " +
198- " suppressed yet."
199- )
183+ ChoiceWithHelp (" privates" , " Warn if a private member is unused" ),
184+ ChoiceWithHelp (" locals" , " Warn if a local definition is unused" ),
185+ ChoiceWithHelp (" explicits" , " Warn if an explicit parameter is unused" ),
186+ ChoiceWithHelp (" implicits" , " Warn if an implicit parameter is unused" ),
187+ ChoiceWithHelp (" params" , " Enable -Wunused:explicits,implicits" ),
188+ ChoiceWithHelp (" linted" , " Enable -Wunused:imports,privates,locals,implicits" ),
189+ ChoiceWithHelp (
190+ name = " strict-no-implicit-warn" ,
191+ description = " Same as -Wunused:import, only for imports of explicit named members.\n " +
192+ " NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all"
193+ ),
194+ // ChoiceWithHelp("patvars","Warn if a variable bound in a pattern is unused"),
195+ ChoiceWithHelp (
196+ name = " unsafe-warn-patvars" ,
197+ description = " (UNSAFE) Warn if a variable bound in a pattern is unused.\n " +
198+ " This warning can generate false positive, as warning cannot be\n " +
199+ " suppressed yet."
200+ )
200201 ),
201202 default = Nil
202203 )
203204 object WunusedHas :
204205 def isChoiceSet (s : String )(using Context ) = Wunused .value.pipe(us => us.contains(s))
205- def allOr (s : String )(using Context ) = Wunused .value.pipe(us => us.contains(" all" ) || us.contains(s))
206+ def allOr (s : String )(using Context ) = Wall .value || Wunused .value.pipe(us => us.contains(" all" ) || us.contains(s))
206207 def nowarn (using Context ) = allOr(" nowarn" )
207208
209+ // Is any choice set for -Wunused?
210+ def any (using Context ): Boolean = Wunused .value.nonEmpty
211+
208212 // overrided by strict-no-implicit-warn
209213 def imports (using Context ) =
210214 (allOr(" imports" ) || allOr(" linted" )) && ! (strictNoImplicitWarn)
@@ -278,6 +282,16 @@ private sealed trait WarningSettings:
278282 |to prevent the shell from expanding patterns. """ .stripMargin,
279283 )
280284
285+ private val WcheckInit : Setting [Boolean ] = BooleanSetting (" -Wsafe-init" , " Ensure safe initialization of objects." )
286+
287+ object Whas :
288+ def allOr (s : Setting [Boolean ])(using Context ): Boolean =
289+ Wall .value || s.value
290+ def valueDiscard (using Context ): Boolean = allOr(WvalueDiscard )
291+ def nonUnitStatement (using Context ): Boolean = allOr(WNonUnitStatement )
292+ def enumCommentDiscard (using Context ): Boolean = allOr(WenumCommentDiscard )
293+ def checkInit (using Context ): Boolean = allOr(WcheckInit )
294+
281295/** -X "Extended" or "Advanced" settings */
282296private sealed trait XSettings :
283297 self : SettingGroup =>
0 commit comments