@@ -38,15 +38,15 @@ class FrontEnd extends Phase {
38
38
def stillToBeEntered (name : String ): Boolean =
39
39
remaining.exists(_.compilationUnit.toString.endsWith(name + " .scala" ))
40
40
41
- def monitor (doing : String )(body : => Unit )(implicit ctx : Context ): Unit =
41
+ def monitor (doing : String )(body : => Unit )(using Context ): Unit =
42
42
try body
43
43
catch {
44
44
case NonFatal (ex) =>
45
45
ctx.echo(s " exception occurred while $doing ${ctx.compilationUnit}" )
46
46
throw ex
47
47
}
48
48
49
- def parse (implicit ctx : Context ): Unit = monitor(" parsing" ) {
49
+ def parse (using Context ): Unit = monitor(" parsing" ) {
50
50
val unit = ctx.compilationUnit
51
51
52
52
unit.untpdTree =
@@ -65,13 +65,13 @@ class FrontEnd extends Phase {
65
65
unit.untpdTree.checkPos(nonOverlapping = ! unit.isJava && ! ctx.reporter.hasErrors)
66
66
}
67
67
68
- def enterSyms (implicit ctx : Context ): Unit = monitor(" indexing" ) {
68
+ def enterSyms (using Context ): Unit = monitor(" indexing" ) {
69
69
val unit = ctx.compilationUnit
70
70
ctx.typer.index(unit.untpdTree)
71
71
typr.println(" entered: " + unit.source)
72
72
}
73
73
74
- def typeCheck (implicit ctx : Context ): Unit = monitor(" typechecking" ) {
74
+ def typeCheck (using Context ): Unit = monitor(" typechecking" ) {
75
75
try
76
76
val unit = ctx.compilationUnit
77
77
if ! unit.suspended then
@@ -83,35 +83,34 @@ class FrontEnd extends Phase {
83
83
case ex : CompilationUnit .SuspendException =>
84
84
}
85
85
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 {
87
87
case PackageDef (_, defs) :: _ => firstTopLevelDef(defs)
88
88
case Import (_, _) :: defs => firstTopLevelDef(defs)
89
89
case (tree @ TypeDef (_, _)) :: _ => tree.symbol
90
90
case _ => NoSymbol
91
91
}
92
92
93
- protected def discardAfterTyper (unit : CompilationUnit )(implicit ctx : Context ): Boolean =
93
+ protected def discardAfterTyper (unit : CompilationUnit )(using Context ): Boolean =
94
94
unit.isJava || unit.suspended
95
95
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 _))
102
102
record(" parsedTrees" , ast.Trees .ntrees)
103
103
remaining = unitContexts
104
- while ( remaining.nonEmpty) {
105
- enterSyms(remaining.head)
104
+ while remaining.nonEmpty do
105
+ enterSyms(using remaining.head)
106
106
remaining = remaining.tail
107
- }
108
107
109
108
if (firstXmlPos.exists && ! defn.ScalaXmlPackageClass .exists)
110
109
ctx.error(""" To support XML literals, your project must depend on scala-xml.
111
110
|See https://github.com/scala/scala-xml for more information.""" .stripMargin,
112
111
firstXmlPos)
113
112
114
- unitContexts.foreach(typeCheck(_))
113
+ unitContexts.foreach(typeCheck(using _))
115
114
record(" total trees after typer" , ast.Trees .ntrees)
116
115
val newUnits = unitContexts.map(_.compilationUnit).filterNot(discardAfterTyper)
117
116
val suspendedUnits = ctx.run.suspendedUnits
@@ -132,7 +131,7 @@ class FrontEnd extends Phase {
132
131
newUnits
133
132
}
134
133
135
- def run (implicit ctx : Context ): Unit = unsupported(" run" )
134
+ def run (using Context ): Unit = unsupported(" run" )
136
135
}
137
136
138
137
object FrontEnd {
0 commit comments