@@ -6,7 +6,6 @@ import dotty.tools.dotc.core.Contexts._
66import dotty .tools .dotc .util .SourcePosition
77
88import java .util .regex .PatternSyntaxException
9- import scala .annotation .internal .sharable
109import scala .collection .mutable .ListBuffer
1110import scala .util .matching .Regex
1211
@@ -31,7 +30,7 @@ final case class WConf(confs: List[(List[MessageFilter], Action)]):
3130 case (filters, action) if filters.forall(_.matches(message)) => action
3231 }.getOrElse(Action .Warning )
3332
34- @ sharable object WConf :
33+ object WConf :
3534 import Action ._
3635 import MessageFilter ._
3736
@@ -49,38 +48,34 @@ final case class WConf(confs: List[(List[MessageFilter], Action)]):
4948 try Right (s.r)
5049 catch { case e : PatternSyntaxException => Left (s " invalid pattern ` $s`: ${e.getMessage}" ) }
5150
52- val splitter = raw " ([^=]+)=(.+) " .r
53-
54- def parseFilter (s : String ): Either [String , MessageFilter ] = s match {
55- case " any" => Right (Any )
56- case splitter(filter, conf) => filter match {
57- case " msg" => regex(conf).map(MessagePattern .apply)
58- case " cat" =>
59- conf match {
51+ def parseFilter (s : String ): Either [String , MessageFilter ] =
52+ val splitter = raw " ([^=]+)=(.+) " .r
53+ s match
54+ case " any" => Right (Any )
55+ case splitter(filter, conf) => filter match
56+ case " msg" => regex(conf).map(MessagePattern .apply)
57+ case " cat" => conf match
6058 case " deprecation" => Right (Deprecated )
6159 case " feature" => Right (Feature )
6260 case _ => Left (s " unknown category: $conf" )
63- }
64- case _ => Left (s " unknown filter: $filter" )
65- }
66- case _ => Left (s " unknown filter: $s" )
67- }
61+ case _ => Left (s " unknown filter: $filter" )
62+ case _ => Left (s " unknown filter: $s" )
6863
69- private var parsedCache : (List [String ], WConf ) = null
7064 def parsed (using Context ): WConf =
7165 val setting = ctx.settings.Wconf .value
72- if parsedCache == null || parsedCache._1 != setting then
66+ def cached = ctx.base.wConfCache
67+ if cached == null || cached._1 != setting then
7368 val conf = fromSettings(setting)
74- parsedCache = (setting, conf.getOrElse(WConf (Nil )))
69+ ctx.base.wConfCache = (setting, conf.getOrElse(WConf (Nil )))
7570 conf.swap.foreach(msgs =>
7671 val multiHelp =
77- if ( setting.sizeIs > 1 )
72+ if setting.sizeIs > 1 then
7873 """
7974 |Note: for multiple filters, use `-Wconf:filter1:action1,filter2:action2`
8075 | or alternatively `-Wconf:filter1:action1 -Wconf:filter2:action2`""" .stripMargin
8176 else " "
8277 report.warning(s " Failed to parse `-Wconf` configuration: ${ctx.settings.Wconf .value.mkString(" ," )}\n ${msgs.mkString(" \n " )}$multiHelp" ))
83- parsedCache ._2
78+ cached ._2
8479
8580 def fromSettings (settings : List [String ]): Either [List [String ], WConf ] =
8681 if (settings.isEmpty) Right (WConf (Nil ))
0 commit comments