Skip to content

Commit ab2210c

Browse files
committed
Changes after renaming to make compilation go through
1 parent e3de80b commit ab2210c

File tree

66 files changed

+304
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+304
-272
lines changed

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class GenBCode extends Phase {
5858

5959

6060
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] = {
61-
given CState = ctx.cstate
61+
given CState = currentContext.cstate
6262
try super.runOn(units)
6363
finally myOutput match {
6464
case jar: JarArchive =>

compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import scala.collection.immutable
3131
*
3232
* Inspired from the `scalac` compiler.
3333
*/
34-
class DottyPrimitives(ictx: Context, cs: CState) {
34+
class DottyPrimitives(ictx: Ctx, cs: CState) {
3535
import dotty.tools.backend.ScalaPrimitivesOps._
3636

3737
@threadUnsafe private lazy val primitives: immutable.Map[Symbol, Int] = init
@@ -120,7 +120,7 @@ class DottyPrimitives(ictx: Context, cs: CState) {
120120
/** Initialize the primitive map */
121121
private def init: immutable.Map[Symbol, Int] = {
122122

123-
given Context = ictx
123+
given Ctx = ictx
124124
given CState = cs
125125

126126
import Symbols.defn
@@ -399,7 +399,7 @@ class DottyPrimitives(ictx: Context, cs: CState) {
399399
}
400400

401401
def isPrimitive(fun: Tree): Boolean =
402-
given Context = ictx
402+
given Ctx = ictx
403403
given CState = cs
404404
primitives.contains(fun.symbol)
405405
|| (fun.symbol == NoSymbol // the only trees that do not have a symbol assigned are array.{update,select,length,clone}}

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class Compiler {
138138
runId += 1; runId
139139
}
140140

141-
def reset()(using Context): Unit = {
141+
def reset()(using Ctx): Unit = {
142142
ctx.base.reset()
143143
if (ctx.run != null) ctx.run.reset()
144144
}
@@ -147,9 +147,9 @@ class Compiler {
147147
reset()
148148
val rctx =
149149
if ctx.settings.Ysemanticdb.value
150-
ctx.addMode(Mode.ReadPositions)
150+
currentContext.addMode(Mode.ReadPositions)
151151
else
152-
ctx
152+
currentContext
153153
new Run(this, rctx)
154154
}
155155
}

compiler/src/dotty/tools/dotc/Driver.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Driver {
3232
protected def emptyReporter: Reporter = new StoreReporter(null)
3333

3434
protected def doCompile(compiler: Compiler, fileNames: List[String])(using Context): Reporter =
35-
given CState = ctx.cstate
35+
given CState = currentContext.cstate
3636
if (fileNames.nonEmpty)
3737
try
3838
val run = compiler.newRun
@@ -79,7 +79,7 @@ class Driver {
7979
if Feature.enabledBySetting(nme.Scala2Compat) && false then // TODO: enable
8080
report.warning("-language:Scala2Compat will go away; use -source 3.0-migration instead")
8181
val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)
82-
fromTastySetup(fileNames, ctx)
82+
fromTastySetup(fileNames, currentContext)
8383
}
8484
}
8585

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
174174
ctx.settings.Yskip.value, ctx.settings.YstopBefore.value, stopAfter, ctx.settings.Ycheck.value)
175175
ctx.base.usePhases(phases)
176176

177-
def runPhases(using Ctx, CState) = {
177+
def runPhases(using c: Context) = {
178+
given CState = c.cstate
178179
var lastPrintedTree: PrintedTree = NoPrintedTree
179180
val profiler = ctx.profiler
180181

@@ -203,7 +204,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
203204
runCtx.setProfiler(Profiler())
204205
unfusedPhases.foreach(_.initContext(runCtx))
205206
runPhases(using runCtx)
206-
if (!ctx.reporter.hasErrors) Rewrites.writeBack()
207+
if (!runCtx.reporter.hasErrors) Rewrites.writeBack()
207208
while (finalizeActions.nonEmpty) {
208209
val action = finalizeActions.remove(0)
209210
action()

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,11 +1245,11 @@ object Trees {
12451245
* innermost enclosing call for which the inlined version is currently
12461246
* processed.
12471247
*/
1248-
protected def inlineContext(call: Tree)(using Ctx, CState): Context = ctx
1248+
protected def inlineContext(call: Tree)(using Ctx, CState): Ctx = ctx
12491249

12501250
abstract class TreeMap(val cpy: TreeCopier = inst.cpy) { self =>
12511251
def transform(tree: Tree)(using Ctx, CState): Tree = {
1252-
inContext(
1252+
inCtx(
12531253
if tree.source != ctx.source && tree.source.exists
12541254
then ctx.withSource(tree.source)
12551255
else ctx
@@ -1313,11 +1313,11 @@ object Trees {
13131313
case AppliedTypeTree(tpt, args) =>
13141314
cpy.AppliedTypeTree(tree)(transform(tpt), transform(args))
13151315
case LambdaTypeTree(tparams, body) =>
1316-
inContext(localCtx) {
1316+
inCtx(localCtx) {
13171317
cpy.LambdaTypeTree(tree)(transformSub(tparams), transform(body))
13181318
}
13191319
case TermLambdaTypeTree(params, body) =>
1320-
inContext(localCtx) {
1320+
inCtx(localCtx) {
13211321
cpy.TermLambdaTypeTree(tree)(transformSub(params), transform(body))
13221322
}
13231323
case MatchTypeTree(bound, selector, cases) =>
@@ -1335,17 +1335,17 @@ object Trees {
13351335
case EmptyValDef =>
13361336
tree
13371337
case tree @ ValDef(name, tpt, _) =>
1338-
inContext(localCtx) {
1338+
inCtx(localCtx) {
13391339
val tpt1 = transform(tpt)
13401340
val rhs1 = transform(tree.rhs)
13411341
cpy.ValDef(tree)(name, tpt1, rhs1)
13421342
}
13431343
case tree @ DefDef(name, tparams, vparamss, tpt, _) =>
1344-
inContext(localCtx) {
1344+
inCtx(localCtx) {
13451345
cpy.DefDef(tree)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt), transform(tree.rhs))
13461346
}
13471347
case tree @ TypeDef(name, rhs) =>
1348-
inContext(localCtx) {
1348+
inCtx(localCtx) {
13491349
cpy.TypeDef(tree)(name, transform(rhs))
13501350
}
13511351
case tree @ Template(constr, parents, self, _) if tree.derived.isEmpty =>
@@ -1446,11 +1446,11 @@ object Trees {
14461446
case AppliedTypeTree(tpt, args) =>
14471447
this(this(x, tpt), args)
14481448
case LambdaTypeTree(tparams, body) =>
1449-
inContext(localCtx) {
1449+
inCtx(localCtx) {
14501450
this(this(x, tparams), body)
14511451
}
14521452
case TermLambdaTypeTree(params, body) =>
1453-
inContext(localCtx) {
1453+
inCtx(localCtx) {
14541454
this(this(x, params), body)
14551455
}
14561456
case MatchTypeTree(bound, selector, cases) =>
@@ -1466,15 +1466,15 @@ object Trees {
14661466
case UnApply(fun, implicits, patterns) =>
14671467
this(this(this(x, fun), implicits), patterns)
14681468
case tree @ ValDef(_, tpt, _) =>
1469-
inContext(localCtx) {
1469+
inCtx(localCtx) {
14701470
this(this(x, tpt), tree.rhs)
14711471
}
14721472
case tree @ DefDef(_, tparams, vparamss, tpt, _) =>
1473-
inContext(localCtx) {
1473+
inCtx(localCtx) {
14741474
this(this(vparamss.foldLeft(this(x, tparams))(apply), tpt), tree.rhs)
14751475
}
14761476
case TypeDef(_, rhs) =>
1477-
inContext(localCtx) {
1477+
inCtx(localCtx) {
14781478
this(x, rhs)
14791479
}
14801480
case tree @ Template(constr, parents, self, _) if tree.derived.isEmpty =>
@@ -1538,7 +1538,7 @@ object Trees {
15381538
}.asInstanceOf[tree.ThisTree[T]]
15391539

15401540
/** Delegate to FunProto or FunProtoTyped depending on whether the prefix is `untpd` or `tpd`. */
1541-
protected def FunProto(args: List[Tree], resType: Type)(using Context): ProtoTypes.FunProto
1541+
protected def FunProto(args: List[Tree], resType: Type)(using Ctx, CState): ProtoTypes.FunProto
15421542

15431543
/** Construct the application `$receiver.$method[$targs]($args)` using overloading resolution
15441544
* to find a matching overload of `$method` if necessary.
@@ -1549,41 +1549,41 @@ object Trees {
15491549
*/
15501550
def applyOverloaded(
15511551
receiver: tpd.Tree, method: TermName, args: List[Tree], targs: List[Type],
1552-
expectedType: Type)(using parentCtx: Context, cs: CState): tpd.Tree = {
1553-
given ctx as Context = parentCtx.retractMode(Mode.ImplicitsEnabled)
1554-
import dotty.tools.dotc.ast.tpd.TreeOps
1555-
1556-
val typer = ctx.typer
1557-
val proto = FunProto(args, expectedType)
1558-
val denot = receiver.tpe.member(method)
1559-
assert(denot.exists, i"no member $receiver . $method, members = ${receiver.tpe.decls}")
1560-
val selected =
1561-
if (denot.isOverloaded) {
1562-
def typeParamCount(tp: Type) = tp.widen match {
1563-
case tp: PolyType => tp.paramInfos.length
1564-
case _ => 0
1552+
expectedType: Type)(using parentCtx: Ctx, cs: CState): tpd.Tree =
1553+
withoutMode(Mode.ImplicitsEnabled) {
1554+
import dotty.tools.dotc.ast.tpd.TreeOps
1555+
1556+
val typer = ctx.typer
1557+
val proto = FunProto(args, expectedType)
1558+
val denot = receiver.tpe.member(method)
1559+
assert(denot.exists, i"no member $receiver . $method, members = ${receiver.tpe.decls}")
1560+
val selected =
1561+
if (denot.isOverloaded) {
1562+
def typeParamCount(tp: Type) = tp.widen match {
1563+
case tp: PolyType => tp.paramInfos.length
1564+
case _ => 0
1565+
}
1566+
val allAlts = denot.alternatives
1567+
.map(denot => TermRef(receiver.tpe, denot.symbol))
1568+
.filter(tr => typeParamCount(tr) == targs.length)
1569+
.filter { _.widen match {
1570+
case MethodTpe(_, _, x: MethodType) => !x.isImplicitMethod
1571+
case _ => true
1572+
}}
1573+
val alternatives = ctx.typer.resolveOverloaded(allAlts, proto)
1574+
assert(alternatives.size == 1,
1575+
i"${if (alternatives.isEmpty) "no" else "multiple"} overloads available for " +
1576+
i"$method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, %; expectedType: $expectedType." +
1577+
i"all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(", ")}\n" +
1578+
i"matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(", ")}.") // this is parsed from bytecode tree. there's nothing user can do about it
1579+
alternatives.head
15651580
}
1566-
val allAlts = denot.alternatives
1567-
.map(denot => TermRef(receiver.tpe, denot.symbol))
1568-
.filter(tr => typeParamCount(tr) == targs.length)
1569-
.filter { _.widen match {
1570-
case MethodTpe(_, _, x: MethodType) => !x.isImplicitMethod
1571-
case _ => true
1572-
}}
1573-
val alternatives = ctx.typer.resolveOverloaded(allAlts, proto)
1574-
assert(alternatives.size == 1,
1575-
i"${if (alternatives.isEmpty) "no" else "multiple"} overloads available for " +
1576-
i"$method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, %; expectedType: $expectedType." +
1577-
i"all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(", ")}\n" +
1578-
i"matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(", ")}.") // this is parsed from bytecode tree. there's nothing user can do about it
1579-
alternatives.head
1580-
}
1581-
else TermRef(receiver.tpe, denot.symbol)
1582-
val fun = receiver.select(selected).appliedToTypes(targs)
1581+
else TermRef(receiver.tpe, denot.symbol)
1582+
val fun = receiver.select(selected).appliedToTypes(targs)
15831583

1584-
val apply = untpd.Apply(fun, args)
1585-
typer.ApplyTo(apply, fun, selected, proto, expectedType)
1586-
}
1584+
val apply = untpd.Apply(fun, args)
1585+
typer.ApplyTo(apply, fun, selected, proto, expectedType)
1586+
}
15871587

15881588

15891589
def resolveConstructor(atp: Type, args: List[Tree])(using Ctx, CState): tpd.Tree = {

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13851385
.appliedToVarargs(trees, tpe)
13861386

13871387

1388-
protected def FunProto(args: List[Tree], resType: Type)(using Context) =
1388+
protected def FunProto(args: List[Tree], resType: Type)(using Ctx, CState) =
13891389
ProtoTypes.FunProtoTyped(args, resType)(ctx.typer, ApplyKind.Regular)
13901390
}

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
782782
acc(false, tree)
783783
}
784784

785-
protected def FunProto(args: List[Tree], resType: Type)(using Context) =
785+
protected def FunProto(args: List[Tree], resType: Type)(using Ctx, CState) =
786786
ProtoTypes.FunProto(args, resType)(ctx.typer, ApplyKind.Regular)
787787
}

compiler/src/dotty/tools/dotc/config/CompilerCommand.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ object CompilerCommand {
6565
* @return The list of files to compile.
6666
*/
6767
def checkUsage(summary: ArgsSummary, sourcesRequired: Boolean)(using Context): List[String] = {
68-
given CState = ctx.cstate
69-
val settings = ctx.settings
68+
given CState = currentContext.cstate
69+
val settings = currentContext.settings
7070

7171
/** Creates a help message for a subset of options based on cond */
7272
def availableOptionsMsg(cond: Setting[?] => Boolean): String = {

0 commit comments

Comments
 (0)