@@ -38,15 +38,15 @@ class FrontEnd extends Phase {
3838 def stillToBeEntered (name : String ): Boolean =
3939 remaining.exists(_.compilationUnit.toString.endsWith(name + " .scala" ))
4040
41- def monitor (doing : String )(body : => Unit )(implicit ctx : Context ): Unit =
41+ def monitor (doing : String )(body : => Unit )(using Context ): Unit =
4242 try body
4343 catch {
4444 case NonFatal (ex) =>
4545 ctx.echo(s " exception occurred while $doing ${ctx.compilationUnit}" )
4646 throw ex
4747 }
4848
49- def parse (implicit ctx : Context ): Unit = monitor(" parsing" ) {
49+ def parse (using Context ): Unit = monitor(" parsing" ) {
5050 val unit = ctx.compilationUnit
5151
5252 unit.untpdTree =
@@ -65,13 +65,13 @@ class FrontEnd extends Phase {
6565 unit.untpdTree.checkPos(nonOverlapping = ! unit.isJava && ! ctx.reporter.hasErrors)
6666 }
6767
68- def enterSyms (implicit ctx : Context ): Unit = monitor(" indexing" ) {
68+ def enterSyms (using Context ): Unit = monitor(" indexing" ) {
6969 val unit = ctx.compilationUnit
7070 ctx.typer.index(unit.untpdTree)
7171 typr.println(" entered: " + unit.source)
7272 }
7373
74- def typeCheck (implicit ctx : Context ): Unit = monitor(" typechecking" ) {
74+ def typeCheck (using Context ): Unit = monitor(" typechecking" ) {
7575 try
7676 val unit = ctx.compilationUnit
7777 if ! unit.suspended then
@@ -83,35 +83,34 @@ class FrontEnd extends Phase {
8383 case ex : CompilationUnit .SuspendException =>
8484 }
8585
86- private def firstTopLevelDef (trees : List [tpd.Tree ])(implicit ctx : Context ): Symbol = trees match {
86+ private def firstTopLevelDef (trees : List [tpd.Tree ])(using Context ): Symbol = trees match {
8787 case PackageDef (_, defs) :: _ => firstTopLevelDef(defs)
8888 case Import (_, _) :: defs => firstTopLevelDef(defs)
8989 case (tree @ TypeDef (_, _)) :: _ => tree.symbol
9090 case _ => NoSymbol
9191 }
9292
93- protected def discardAfterTyper (unit : CompilationUnit )(implicit ctx : Context ): Boolean =
93+ protected def discardAfterTyper (unit : CompilationUnit )(using Context ): Boolean =
9494 unit.isJava || unit.suspended
9595
96- override def runOn (units : List [CompilationUnit ])(implicit ctx : Context ): List [CompilationUnit ] = {
97- val unitContexts = for (unit <- units) yield {
98- ctx.inform( s " compiling ${ unit.source} " )
99- ctx.fresh.setCompilationUnit( unit)
100- }
101- unitContexts.foreach(parse(_))
96+ override def runOn (units : List [CompilationUnit ])(using Context ): List [CompilationUnit ] = {
97+ val unitContexts =
98+ for unit <- units yield
99+ ctx.inform( s " compiling ${ unit.source} " )
100+ ctx.fresh.setCompilationUnit(unit)
101+ unitContexts.foreach(parse(using _))
102102 record(" parsedTrees" , ast.Trees .ntrees)
103103 remaining = unitContexts
104- while ( remaining.nonEmpty) {
105- enterSyms(remaining.head)
104+ while remaining.nonEmpty do
105+ enterSyms(using remaining.head)
106106 remaining = remaining.tail
107- }
108107
109108 if (firstXmlPos.exists && ! defn.ScalaXmlPackageClass .exists)
110109 ctx.error(""" To support XML literals, your project must depend on scala-xml.
111110 |See https://github.com/scala/scala-xml for more information.""" .stripMargin,
112111 firstXmlPos)
113112
114- unitContexts.foreach(typeCheck(_))
113+ unitContexts.foreach(typeCheck(using _))
115114 record(" total trees after typer" , ast.Trees .ntrees)
116115 val newUnits = unitContexts.map(_.compilationUnit).filterNot(discardAfterTyper)
117116 val suspendedUnits = ctx.run.suspendedUnits
@@ -132,7 +131,7 @@ class FrontEnd extends Phase {
132131 newUnits
133132 }
134133
135- def run (implicit ctx : Context ): Unit = unsupported(" run" )
134+ def run (using Context ): Unit = unsupported(" run" )
136135}
137136
138137object FrontEnd {
0 commit comments