Skip to content

Commit 7366f5c

Browse files
committed
Convert transform classes (2)
1 parent 1ae90ec commit 7366f5c

16 files changed

+363
-363
lines changed

compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ object GenericSignatures {
3131
* @param info The type of the symbol
3232
* @return The signature if it could be generated, `None` otherwise.
3333
*/
34-
def javaSig(sym0: Symbol, info: Type)(implicit ctx: Context): Option[String] =
34+
def javaSig(sym0: Symbol, info: Type)(using Context): Option[String] =
3535
// Avoid generating a signature for local symbols.
3636
if (sym0.isLocal) None
3737
else javaSig0(sym0, info)(using ctx.withPhase(ctx.erasurePhase))
3838

3939
@noinline
40-
private final def javaSig0(sym0: Symbol, info: Type)(implicit ctx: Context): Option[String] = {
40+
private final def javaSig0(sym0: Symbol, info: Type)(using Context): Option[String] = {
4141
val builder = new StringBuilder(64)
4242
val isTraitSignature = sym0.enclosingClass.is(Trait)
4343

@@ -247,7 +247,7 @@ object GenericSignatures {
247247

248248
case mtpe: MethodType =>
249249
// erased method parameters do not make it to the bytecode.
250-
def effectiveParamInfoss(t: Type)(implicit ctx: Context): List[List[Type]] = t match {
250+
def effectiveParamInfoss(t: Type)(using Context): List[List[Type]] = t match {
251251
case t: MethodType if t.isErasedMethod => effectiveParamInfoss(t.resType)
252252
case t: MethodType => t.paramInfos :: effectiveParamInfoss(t.resType)
253253
case _ => Nil
@@ -319,7 +319,7 @@ object GenericSignatures {
319319
* not Object, the dominator is Tc. <--- @PP: "which is not Object" not in spec.
320320
* - Otherwise, the dominator is the first element of the span.
321321
*/
322-
private def intersectionDominator(parents: List[Type])(implicit ctx: Context): Type =
322+
private def intersectionDominator(parents: List[Type])(using Context): Type =
323323
if (parents.isEmpty) defn.ObjectType
324324
else {
325325
val psyms = parents map (_.typeSymbol)
@@ -342,7 +342,7 @@ object GenericSignatures {
342342
/* Drop redundant types (ones which are implemented by some other parent) from the immediate parents.
343343
* This is important on Android because there is otherwise an interface explosion.
344344
*/
345-
private def minimizeParents(cls: Symbol, parents: List[Type])(implicit ctx: Context): List[Type] = if (parents.isEmpty) parents else {
345+
private def minimizeParents(cls: Symbol, parents: List[Type])(using Context): List[Type] = if (parents.isEmpty) parents else {
346346
// val requiredDirect: Symbol => Boolean = requiredDirectInterfaces.getOrElse(cls, Set.empty)
347347
var rest = parents.tail
348348
var leaves = collection.mutable.ListBuffer.empty[Type] += parents.head
@@ -364,7 +364,7 @@ object GenericSignatures {
364364
leaves.toList
365365
}
366366

367-
private def hiBounds(bounds: TypeBounds)(implicit ctx: Context): List[Type] = bounds.hi.widenDealias match {
367+
private def hiBounds(bounds: TypeBounds)(using Context): List[Type] = bounds.hi.widenDealias match {
368368
case AndType(tp1, tp2) => hiBounds(tp1.bounds) ::: hiBounds(tp2.bounds)
369369
case tp => tp :: Nil
370370
}
@@ -374,7 +374,7 @@ object GenericSignatures {
374374
// * higher-order type parameters
375375
// * type parameters appearing in method parameters
376376
// * type members not visible in an enclosing template
377-
private def isTypeParameterInSig(sym: Symbol, initialSymbol: Symbol)(implicit ctx: Context) =
377+
private def isTypeParameterInSig(sym: Symbol, initialSymbol: Symbol)(using Context) =
378378
!sym.maybeOwner.isTypeParam &&
379379
sym.isTypeParam && (
380380
sym.isContainedIn(initialSymbol.topLevelClass) ||
@@ -390,13 +390,13 @@ object GenericSignatures {
390390
// included (use pre.baseType(cls.owner)).
391391
//
392392
// This requires that cls.isClass.
393-
private def rebindInnerClass(pre: Type, cls: Symbol)(implicit ctx: Context): Type = {
393+
private def rebindInnerClass(pre: Type, cls: Symbol)(using Context): Type = {
394394
val owner = cls.owner
395395
if (owner.is(PackageClass) || owner.isTerm) pre else cls.owner.info /* .tpe_* */
396396
}
397397

398398
private object RefOrAppliedType {
399-
def unapply(tp: Type)(implicit ctx: Context): Option[(Symbol, Type, List[Type])] = tp match {
399+
def unapply(tp: Type)(using Context): Option[(Symbol, Type, List[Type])] = tp match {
400400
case TypeParamRef(_, _) =>
401401
Some((tp.typeSymbol, tp, Nil))
402402
case TermParamRef(_, _) =>
@@ -411,12 +411,12 @@ object GenericSignatures {
411411
}
412412
}
413413

414-
private def needsJavaSig(tp: Type, throwsArgs: List[Type])(implicit ctx: Context): Boolean = !ctx.settings.YnoGenericSig.value && {
414+
private def needsJavaSig(tp: Type, throwsArgs: List[Type])(using Context): Boolean = !ctx.settings.YnoGenericSig.value && {
415415
def needs(tp: Type) = (new NeedsSigCollector).apply(false, tp)
416416
needs(tp) || throwsArgs.exists(needs)
417417
}
418418

419-
private class NeedsSigCollector(implicit ctx: Context) extends TypeAccumulator[Boolean] {
419+
private class NeedsSigCollector(using Context) extends TypeAccumulator[Boolean] {
420420
override def apply(x: Boolean, tp: Type): Boolean =
421421
if (!x)
422422
tp match {

compiler/src/dotty/tools/dotc/transform/Getters.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Getters extends MiniPhase with SymTransformer { thisPhase =>
6262

6363
override def phaseName: String = Getters.name
6464

65-
override def transformSym(d: SymDenotation)(implicit ctx: Context): SymDenotation = {
65+
override def transformSym(d: SymDenotation)(using Context): SymDenotation = {
6666
def noGetterNeeded =
6767
d.isOneOf(NoGetterNeededFlags) ||
6868
d.isAllOf(PrivateLocal) && !d.owner.is(Trait) && !isDerivedValueClass(d.owner) && !d.is(Lazy) ||
@@ -100,7 +100,7 @@ class Getters extends MiniPhase with SymTransformer { thisPhase =>
100100
info = MethodType(sym.info.widenExpr :: Nil, defn.UnitType)
101101
).enteredAfter(thisPhase)
102102

103-
override def transformValDef(tree: ValDef)(implicit ctx: Context): Tree =
103+
override def transformValDef(tree: ValDef)(using Context): Tree =
104104
val sym = tree.symbol
105105
if !sym.is(Method) then return tree
106106
val getterDef = DefDef(sym.asTerm, tree.rhs).withSpan(tree.span)
@@ -110,7 +110,7 @@ class Getters extends MiniPhase with SymTransformer { thisPhase =>
110110
val setterDef = DefDef(sym.setter.asTerm, unitLiteral)
111111
Thicket(getterDef, setterDef)
112112

113-
override def transformAssign(tree: Assign)(implicit ctx: Context): Tree =
113+
override def transformAssign(tree: Assign)(using Context): Tree =
114114
val lsym = tree.lhs.symbol.asTerm
115115
if (lsym.is(Method))
116116
ensureSetter(lsym)

compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class HoistSuperArgs extends MiniPhase with IdentityDenotTransformer { thisPhase
5454
* parent super calls and constructor definitions.
5555
* Hoisted superarg methods are collected in `superArgDefs`
5656
*/
57-
class Hoister(cls: Symbol)(implicit ctx: Context) {
57+
class Hoister(cls: Symbol)(using Context) {
5858
val superArgDefs: mutable.ListBuffer[DefDef] = new mutable.ListBuffer
5959

6060
/** If argument is complex, hoist it out into its own method and refer to the
@@ -197,7 +197,7 @@ class HoistSuperArgs extends MiniPhase with IdentityDenotTransformer { thisPhase
197197
}
198198
}
199199

200-
override def transformTypeDef(tdef: TypeDef)(implicit ctx: Context): Tree =
200+
override def transformTypeDef(tdef: TypeDef)(using Context): Tree =
201201
tdef.rhs match {
202202
case impl @ Template(cdef, superCall :: others, _, _) =>
203203
val hoist = new Hoister(tdef.symbol)

compiler/src/dotty/tools/dotc/transform/Instrumentation.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ class Instrumentation extends MiniPhase { thisPhase =>
2424

2525
override def phaseName: String = "instrumentation"
2626

27-
override def isEnabled(implicit ctx: Context) =
27+
override def isEnabled(using Context) =
2828
ctx.settings.YinstrumentClosures.value ||
2929
ctx.settings.YinstrumentAllocations.value
3030

3131
private var consName: TermName = _
3232
private var consEqName: TermName = _
3333

34-
override def prepareForUnit(tree: Tree)(implicit ctx: Context): Context = {
34+
override def prepareForUnit(tree: Tree)(using Context): Context = {
3535
consName = "::".toTermName
3636
consEqName = "+=".toTermName
3737
ctx
3838
}
3939

40-
private def record(category: String, tree: Tree)(implicit ctx: Context): Tree = {
40+
private def record(category: String, tree: Tree)(using Context): Tree = {
4141
val key = Literal(Constant(s"$category${tree.sourcePos.show}"))
4242
ref(defn.Stats_doRecord).appliedTo(key, Literal(Constant(1)))
4343
}
4444

45-
override def transformApply(tree: Apply)(implicit ctx: Context): Tree = tree.fun match {
45+
override def transformApply(tree: Apply)(using Context): Tree = tree.fun match {
4646
case Select(nu: New, _) =>
4747
cpy.Block(tree)(record(i"alloc/${nu.tpe}@", tree) :: Nil, tree)
4848
case Select(_, name) if name == consName || name == consEqName =>
@@ -51,7 +51,7 @@ class Instrumentation extends MiniPhase { thisPhase =>
5151
tree
5252
}
5353

54-
override def transformBlock(tree: Block)(implicit ctx: Context): Block = tree.expr match {
54+
override def transformBlock(tree: Block)(using Context): Block = tree.expr match {
5555
case _: Closure =>
5656
cpy.Block(tree)(record("closure/", tree) :: tree.stats, tree.expr)
5757
case _ =>

compiler/src/dotty/tools/dotc/transform/InterceptedMethods.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ class InterceptedMethods extends MiniPhase {
2828
override def phaseName: String = InterceptedMethods.name
2929

3030
// this should be removed if we have guarantee that ## will get Apply node
31-
override def transformSelect(tree: tpd.Select)(implicit ctx: Context): Tree =
31+
override def transformSelect(tree: tpd.Select)(using Context): Tree =
3232
transformRefTree(tree)
3333

34-
override def transformIdent(tree: tpd.Ident)(implicit ctx: Context): Tree =
34+
override def transformIdent(tree: tpd.Ident)(using Context): Tree =
3535
transformRefTree(tree)
3636

37-
private def transformRefTree(tree: RefTree)(implicit ctx: Context): Tree =
37+
private def transformRefTree(tree: RefTree)(using Context): Tree =
3838
if (tree.symbol.isTerm && (defn.Any_## eq tree.symbol)) {
3939
val qual = tree match {
4040
case id: Ident => tpd.desugarIdentPrefix(id)
@@ -47,7 +47,7 @@ class InterceptedMethods extends MiniPhase {
4747
else tree
4848

4949
// TODO: add missing cases from scalac
50-
private def poundPoundValue(tree: Tree)(implicit ctx: Context) = {
50+
private def poundPoundValue(tree: Tree)(using Context) = {
5151
val s = tree.tpe.widen.typeSymbol
5252

5353
def staticsCall(methodName: TermName): Tree =
@@ -60,7 +60,7 @@ class InterceptedMethods extends MiniPhase {
6060
else staticsCall(nme.anyHash)
6161
}
6262

63-
override def transformApply(tree: Apply)(implicit ctx: Context): Tree = {
63+
override def transformApply(tree: Apply)(using Context): Tree = {
6464
lazy val qual = tree.fun match {
6565
case Select(qual, _) => qual
6666
case ident @ Ident(_) =>

compiler/src/dotty/tools/dotc/transform/IsInstanceOfEvaluator.scala.disabled

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class IsInstanceOfEvaluator extends MiniPhase {
3838
/** Transforms a [TypeApply](dotty.tools.dotc.ast.Trees.TypeApply) in order to
3939
* evaluate an `isInstanceOf` check according to the rules defined above.
4040
*/
41-
override def transformTypeApply(tree: TypeApply)(implicit ctx: Context): Tree = {
41+
override def transformTypeApply(tree: TypeApply)(using Context): Tree = {
4242
val defn = ctx.definitions
4343

4444
/** Handles the four cases of statically known `isInstanceOf`s and gives

0 commit comments

Comments
 (0)