Skip to content

Commit f70fdd1

Browse files
committed
Make atPhase methods take arguments of implicit function type
1 parent 0beb659 commit f70fdd1

19 files changed

+34
-37
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
518518
* @see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.4
519519
*/
520520
def getGenericSignature(sym: Symbol, owner: Symbol): String = {
521-
ctx.atPhase(ctx.erasurePhase) { implicit ctx =>
521+
ctx.atPhase(ctx.erasurePhase) {
522522
val memberTpe =
523523
if (sym.is(Flags.Method)) sym.denot.info
524524
else owner.denot.thisType.memberInfo(sym)
@@ -533,7 +533,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
533533
// But for now, just like we did in mixin, we just avoid writing a wrong generic signature
534534
// (one that doesn't erase to the actual signature). See run/t3452b for a test case.
535535

536-
val memberTpe = ctx.atPhase(ctx.erasurePhase) { implicit ctx => moduleClass.denot.thisType.memberInfo(sym) }
536+
val memberTpe = ctx.atPhase(ctx.erasurePhase) { moduleClass.denot.thisType.memberInfo(sym) }
537537
val erasedMemberType = TypeErasure.erasure(memberTpe)
538538
if (erasedMemberType =:= sym.denot.info)
539539
getGenericSignature(sym, moduleClass, memberTpe).orNull
@@ -782,7 +782,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
782782

783783
private def definedClasses(phase: Phase) =
784784
if (sym.isDefinedInCurrentRun)
785-
ctx.atPhase(phase) { implicit ctx =>
785+
ctx.atPhase(phase) {
786786
toDenot(sym).info.decls.filter(_.isClass)
787787
}
788788
else Nil
@@ -835,13 +835,13 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
835835
* such objects.
836836
*/
837837
def isTopLevelModuleClass: Boolean = sym.isModuleClass &&
838-
ctx.atPhase(ctx.flattenPhase) { implicit ctx =>
838+
ctx.atPhase(ctx.flattenPhase) {
839839
toDenot(sym).owner.is(Flags.PackageClass)
840840
}
841841

842842
def addRemoteRemoteExceptionAnnotation: Unit = ()
843843

844-
def samMethod(): Symbol = ctx.atPhase(ctx.erasurePhase) { implicit ctx =>
844+
def samMethod(): Symbol = ctx.atPhase(ctx.erasurePhase) {
845845
toDenot(sym).info.abstractTermMembers.toList match {
846846
case x :: Nil => x.symbol
847847
case Nil => abort(s"${sym.show} is not a functional interface. It doesn't have abstract methods")

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
162162
val (cl1, cl2) =
163163
if (classSymbol.effectiveName.toString < dupClassSym.effectiveName.toString) (classSymbol, dupClassSym)
164164
else (dupClassSym, classSymbol)
165-
ctx.atPhase(ctx.typerPhase) { implicit ctx =>
166-
ctx.warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
165+
ctx.atPhase(ctx.typerPhase) {
166+
the[Context].warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
167167
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.sourcePos)
168168
}
169169
}
@@ -263,7 +263,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
263263

264264
// ----------- compiler and sbt's callbacks
265265

266-
val (fullClassName, isLocal) = ctx.atPhase(ctx.sbtExtractDependenciesPhase) { implicit ctx =>
266+
val (fullClassName, isLocal) = ctx.atPhase(ctx.sbtExtractDependenciesPhase) {
267267
(ExtractDependencies.classNameAsString(claszSymbol), claszSymbol.isLocal)
268268
}
269269

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ class JSCodeGen()(implicit ctx: Context) {
19621962
if (isStat) {
19631963
boxedResult
19641964
} else {
1965-
val tpe = ctx.atPhase(ctx.elimErasedValueTypePhase) { implicit ctx =>
1965+
val tpe = ctx.atPhase(ctx.elimErasedValueTypePhase) {
19661966
sym.info.finalResultType
19671967
}
19681968
unbox(boxedResult, tpe)
@@ -2578,13 +2578,13 @@ class JSCodeGen()(implicit ctx: Context) {
25782578
def paramNamesAndTypes(implicit ctx: Context): List[(Names.TermName, Type)] =
25792579
sym.info.paramNamess.flatten.zip(sym.info.paramInfoss.flatten)
25802580

2581-
val wereRepeated = ctx.atPhase(ctx.elimRepeatedPhase) { implicit ctx =>
2581+
val wereRepeated = ctx.atPhase(ctx.elimRepeatedPhase) {
25822582
val list = for ((name, tpe) <- paramNamesAndTypes)
25832583
yield (name -> tpe.isRepeatedParam)
25842584
list.toMap
25852585
}
25862586

2587-
val paramTypes = ctx.atPhase(ctx.elimErasedValueTypePhase) { implicit ctx =>
2587+
val paramTypes = ctx.atPhase(ctx.elimErasedValueTypePhase) {
25882588
paramNamesAndTypes.toMap
25892589
}
25902590

compiler/src/dotty/tools/backend/sjs/JSInterop.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object JSInterop {
1616
/** Is this symbol a JavaScript type? */
1717
def isJSType(sym: Symbol)(implicit ctx: Context): Boolean = {
1818
//sym.hasAnnotation(jsdefn.RawJSTypeAnnot)
19-
ctx.atPhase(ctx.erasurePhase) { implicit ctx =>
19+
ctx.atPhase(ctx.erasurePhase) {
2020
sym.derivesFrom(jsdefn.JSAnyClass)
2121
}
2222
}
@@ -32,7 +32,7 @@ object JSInterop {
3232
* much as *accessor* methods created for `val`s and `var`s.
3333
*/
3434
def isJSGetter(sym: Symbol)(implicit ctx: Context): Boolean = {
35-
sym.info.firstParamTypes.isEmpty && ctx.atPhase(ctx.erasurePhase) { implicit ctx =>
35+
sym.info.firstParamTypes.isEmpty && ctx.atPhase(ctx.erasurePhase) {
3636
sym.info.isParameterless
3737
}
3838
}

compiler/src/dotty/tools/dotc/core/Periods.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ abstract class Periods { self: Context =>
2121
op(ctx.fresh.setPeriod(pd))
2222

2323
/** Execute `op` at given phase id */
24-
def atPhase[T](pid: PhaseId)(op: Context => T): T =
25-
op(ctx.withPhase(pid))
24+
def atPhase[T](pid: PhaseId)(op: given Context => T): T =
25+
op given ctx.withPhase(pid)
2626

2727
/** The period containing the current period where denotations do not change.
2828
* We compute this by taking as first phase the first phase less or equal to

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ trait Phases {
3131
}
3232

3333
/** Execute `op` at given phase */
34-
def atPhase[T](phase: Phase)(op: Context => T): T =
34+
def atPhase[T](phase: Phase)(op: given Context => T): T =
3535
atPhase(phase.id)(op)
3636

37-
def atNextPhase[T](op: Context => T): T = atPhase(phase.next)(op)
37+
def atNextPhase[T](op: given Context => T): T = atPhase(phase.next)(op)
3838

39-
def atPhaseNotLaterThan[T](limit: Phase)(op: Context => T): T =
40-
if (!limit.exists || phase <= limit) op(this) else atPhase(limit)(op)
39+
def atPhaseNotLaterThan[T](limit: Phase)(op: given Context => T): T =
40+
if (!limit.exists || phase <= limit) op given this else atPhase(limit)(op)
4141

4242
def isAfterTyper: Boolean = base.isAfterTyper(phase)
4343
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ElimByName extends TransformByNameApply with InfoTransformer {
4242
private def applyIfFunction(tree: Tree, ftree: Tree)(implicit ctx: Context) =
4343
if (isByNameRef(ftree)) {
4444
val tree0 = transformFollowing(tree)
45-
ctx.atPhase(next) { implicit ctx => tree0.select(defn.Function0_apply).appliedToNone }
45+
ctx.atPhase(next) { tree0.select(defn.Function0_apply).appliedToNone }
4646
}
4747
else tree
4848

@@ -61,7 +61,7 @@ class ElimByName extends TransformByNameApply with InfoTransformer {
6161
}
6262

6363
override def transformValDef(tree: ValDef)(implicit ctx: Context): Tree =
64-
ctx.atPhase(next) { implicit ctx =>
64+
ctx.atPhase(next) {
6565
if (exprBecomesFunction(tree.symbol))
6666
cpy.ValDef(tree)(tpt = tree.tpt.withType(tree.symbol.info))
6767
else tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
112112
* Also transform trees inside method annotation
113113
*/
114114
override def transformDefDef(tree: DefDef)(implicit ctx: Context): Tree =
115-
ctx.atPhase(thisPhase) { implicit ctx =>
115+
ctx.atPhase(thisPhase) {
116116
if (tree.symbol.info.isVarArgsMethod && overridesJava(tree.symbol))
117117
addVarArgsBridge(tree)
118118
else

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ object ExplicitOuter {
131131

132132
/** Ensure that class `cls` has outer accessors */
133133
def ensureOuterAccessors(cls: ClassSymbol)(implicit ctx: Context): Unit =
134-
ctx.atPhase(ctx.explicitOuterPhase.next) { implicit ctx =>
134+
ctx.atPhase(ctx.explicitOuterPhase.next) {
135135
if (!hasOuter(cls))
136136
newOuterAccessors(cls).foreach(_.enteredAfter(ctx.explicitOuterPhase.asInstanceOf[DenotTransformer]))
137137
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ object ExtensionMethods {
217217

218218
/** Return the extension method that corresponds to given instance method `meth`. */
219219
def extensionMethod(imeth: Symbol)(implicit ctx: Context): TermSymbol =
220-
ctx.atPhase(ctx.extensionMethodsPhase.next) { implicit ctx =>
220+
ctx.atPhase(ctx.extensionMethodsPhase.next) {
221221
// FIXME use toStatic instead?
222222
val companion = imeth.owner.companionModule
223223
val companionInfo = companion.info

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ class FunctionalInterfaces extends MiniPhase {
3535

3636
if (defn.isSpecializableFunction(cls, implParamTypes, implResultType) &&
3737
!ctx.settings.scalajs.value) { // never do anything for Scala.js, but do this test as late as possible not to slow down Scala/JVM
38-
val names = ctx.atPhase(ctx.erasurePhase) {
39-
implicit ctx => cls.typeParams.map(_.name)
40-
}
38+
val names = ctx.atPhase(ctx.erasurePhase) { cls.typeParams.map(_.name) }
4139
val interfaceName = (functionName ++ implParamTypes.length.toString).specializedFor(implParamTypes ::: implResultType :: Nil, names, Nil, Nil)
4240

4341
// symbols loaded from classpath aren't defined in periods earlier than when they where loaded

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ object GenericSignatures {
119119
// a type parameter or similar) must go through here or the signature is
120120
// likely to end up with Foo<T>.Empty where it needs Foo<T>.Empty$.
121121
def fullNameInSig(sym: Symbol): Unit = {
122-
val name = ctx.atPhase(ctx.genBCodePhase) { implicit ctx => sanitizeName(sym.fullName).replace('.', '/') }
122+
val name = ctx.atPhase(ctx.genBCodePhase) { sanitizeName(sym.fullName).replace('.', '/') }
123123
builder.append('L').append(name)
124124
}
125125

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ object LambdaLift {
358358
}
359359

360360
// initialization
361-
ctx.atPhase(thisPhase) { implicit ctx =>
361+
ctx.atPhase(thisPhase) {
362362
(new CollectDependencies).traverse(ctx.compilationUnit.tpdTree)
363363
computeFreeVars()
364364
computeLiftedOwners()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
207207
}
208208

209209
def wasOneOf(sym: Symbol, flags: FlagSet) =
210-
ctx.atPhase(thisPhase) { implicit ctx => sym.isOneOf(flags) }
210+
ctx.atPhase(thisPhase) { sym.isOneOf(flags) }
211211

212212
def traitInits(mixin: ClassSymbol): List[Tree] = {
213213
var argNum = 0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class MixinOps(cls: ClassSymbol, thisPhase: DenotTransformer)(implicit ctx: Cont
4343
* The test is performed at phase `thisPhase`.
4444
*/
4545
def isCurrent(sym: Symbol): Boolean =
46-
ctx.atPhase(thisPhase) { implicit ctx =>
46+
ctx.atPhase(thisPhase) {
4747
cls.info.nonPrivateMember(sym.name).hasAltWith(_.symbol == sym)
4848
}
4949

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class TreeChecker extends Phase with SymTransformer {
5757

5858
def checkCompanion(symd: SymDenotation)(implicit ctx: Context): Unit = {
5959
val cur = symd.linkedClass
60-
val prev = ctx.atPhase(ctx.phase.prev) { implicit ctx =>
60+
val prev = ctx.atPhase(ctx.phase.prev) {
6161
symd.symbol.linkedClass
6262
}
6363

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ object ValueClasses {
2222
}
2323

2424
def isMethodWithExtension(sym: Symbol)(implicit ctx: Context): Boolean =
25-
ctx.atPhaseNotLaterThan(ctx.extensionMethodsPhase) { implicit ctx =>
25+
ctx.atPhaseNotLaterThan(ctx.extensionMethodsPhase) {
2626
val d = sym.denot
27-
d.validFor.containsPhaseId(ctx.phaseId) &&
27+
d.validFor.containsPhaseId(the[Context].phaseId) &&
2828
d.isRealMethod &&
2929
isDerivedValueClass(d.owner) &&
3030
!d.isConstructor &&

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ object RefChecks {
466466

467467
def hasJavaErasedOverriding(sym: Symbol): Boolean =
468468
!ctx.erasurePhase.exists || // can't do the test, assume the best
469-
ctx.atPhase(ctx.erasurePhase.next) { implicit ctx =>
469+
ctx.atPhase(ctx.erasurePhase.next) {
470470
clazz.info.nonPrivateMember(sym.name).hasAltWith { alt =>
471471
alt.symbol.is(JavaDefined, butNot = Deferred) &&
472472
!sym.owner.derivesFrom(alt.symbol.owner) &&

compiler/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ class ReplDriver(settings: Array[String],
291291
}
292292

293293

294-
ctx.atPhase(ctx.typerPhase.next) { implicit ctx =>
295-
294+
ctx.atPhase(ctx.typerPhase.next) {
296295
// Display members of wrapped module:
297296
tree.symbol.info.memberClasses
298297
.find(_.symbol.name == newestWrapper.moduleClassName)

0 commit comments

Comments
 (0)