Skip to content

Commit cd9f05d

Browse files
committed
Move individual phases to Phases
1 parent da6829b commit cd9f05d

Some content is hidden

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

41 files changed

+123
-106
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import dotty.tools.dotc.transform.Erasure
2020
import dotty.tools.dotc.transform.SymUtils._
2121
import dotty.tools.dotc.util.Spans._
2222
import dotty.tools.dotc.core.Contexts.{inContext, atPhase}
23+
import dotty.tools.dotc.core.Phases._
2324

2425
/*
2526
*
@@ -1461,7 +1462,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
14611462
// TODO specialization
14621463
val constrainedType = new MethodBType(lambdaParamTypes.map(p => toTypeKind(p)), toTypeKind(lambdaTarget.info.resultType)).toASMType
14631464

1464-
val abstractMethod = atPhase(ctx.erasurePhase) {
1465+
val abstractMethod = atPhase(erasurePhase) {
14651466
val samMethods = toDenot(functionalInterface).info.possibleSamMethods.toList
14661467
samMethods match {
14671468
case x :: Nil => x.symbol

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import dotty.tools.dotc.ast.Trees
1414
import dotty.tools.dotc.core.Annotations._
1515
import dotty.tools.dotc.core.Constants._
1616
import dotty.tools.dotc.core.Contexts.{Context, atPhase}
17+
import dotty.tools.dotc.core.Phases._
1718
import dotty.tools.dotc.core.Decorators._
1819
import dotty.tools.dotc.core.Flags._
1920
import dotty.tools.dotc.core.Names.Name
@@ -360,7 +361,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
360361
val narg = normalizeArgument(arg)
361362
// Transformation phases are not run on annotation trees, so we need to run
362363
// `constToLiteral` at this point.
363-
val t = constToLiteral(narg)(using ctx.withPhase(ctx.erasurePhase))
364+
val t = atPhase(erasurePhase)(constToLiteral(narg))
364365
t match {
365366
case Literal(const @ Constant(_)) =>
366367
const.tag match {
@@ -478,7 +479,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
478479
* @see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.4
479480
*/
480481
def getGenericSignature(sym: Symbol, owner: Symbol): String = {
481-
atPhase(ctx.erasurePhase) {
482+
atPhase(erasurePhase) {
482483
val memberTpe =
483484
if (sym.is(Method)) sym.denot.info
484485
else owner.denot.thisType.memberInfo(sym)
@@ -913,7 +914,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
913914
// But for now, just like we did in mixin, we just avoid writing a wrong generic signature
914915
// (one that doesn't erase to the actual signature). See run/t3452b for a test case.
915916

916-
val memberTpe = atPhase(ctx.erasurePhase) { moduleClass.denot.thisType.memberInfo(sym) }
917+
val memberTpe = atPhase(erasurePhase) { moduleClass.denot.thisType.memberInfo(sym) }
917918
val erasedMemberType = TypeErasure.erasure(memberTpe)
918919
if (erasedMemberType =:= sym.denot.info)
919920
getGenericSignatureHelper(sym, moduleClass, memberTpe).orNull

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import scala.collection.generic.Clearable
99

1010
import dotty.tools.dotc.core.Flags._
1111
import dotty.tools.dotc.core.Contexts.{inContext, atPhase}
12+
import dotty.tools.dotc.core.Phases._
1213
import dotty.tools.dotc.core.Symbols._
1314
import dotty.tools.dotc.core.Phases.Phase
1415
import dotty.tools.dotc.transform.SymUtils._
@@ -203,12 +204,12 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
203204
/** For currently compiled classes: All locally defined classes including local classes.
204205
* The empty list for classes that are not currently compiled.
205206
*/
206-
private def getNestedClasses(sym: Symbol): List[Symbol] = definedClasses(sym, ctx.flattenPhase)
207+
private def getNestedClasses(sym: Symbol): List[Symbol] = definedClasses(sym, flattenPhase)
207208

208209
/** For currently compiled classes: All classes that are declared as members of this class
209210
* (but not inherited ones). The empty list for classes that are not currently compiled.
210211
*/
211-
private def getMemberClasses(sym: Symbol): List[Symbol] = definedClasses(sym, ctx.lambdaLiftPhase)
212+
private def getMemberClasses(sym: Symbol): List[Symbol] = definedClasses(sym, lambdaLiftPhase)
212213

213214
private def definedClasses(sym: Symbol, phase: Phase) =
214215
if (sym.isDefinedInCurrentRun)
@@ -229,11 +230,11 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
229230
// After lambdalift (which is where we are), the rawowoner field contains the enclosing class.
230231
val enclosingClassSym = {
231232
if (innerClassSym.isClass) {
232-
atPhase(ctx.flattenPhase.prev) {
233+
atPhase(flattenPhase.prev) {
233234
toDenot(innerClassSym).owner.enclosingClass
234235
}
235236
}
236-
else innerClassSym.enclosingClass(using ctx.withPhase(ctx.flattenPhase.prev))
237+
else atPhase(flattenPhase.prev)(innerClassSym.enclosingClass)
237238
} //todo is handled specially for JavaDefined symbols in scalac
238239

239240
val enclosingClass: ClassBType = classBTypeFromSymbol(enclosingClassSym)
@@ -257,7 +258,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
257258
if (innerClassSym.isAnonymousClass || innerClassSym.isAnonymousFunction) None
258259
else {
259260
val original = innerClassSym.initial
260-
Some(innerClassSym.name(using ctx.withPhase(original.validFor.phaseId)).mangledString) // moduleSuffix for module classes
261+
Some(atPhase(original.validFor.phaseId)(innerClassSym.name).mangledString) // moduleSuffix for module classes
261262
}
262263
}
263264

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dotty.tools.backend.jvm
22

33
import dotty.tools.dotc.ast.tpd
44
import dotty.tools.dotc.core.Contexts.{Context, ctx}
5+
import dotty.tools.dotc.core.Phases._
56
import dotty.tools.dotc.core.Symbols._
67
import dotty.tools.dotc.core.Flags.Trait
78
import dotty.tools.dotc.transform.MegaPhase.MiniPhase
@@ -32,7 +33,7 @@ class CollectSuperCalls extends MiniPhase {
3233
}
3334

3435
private def registerSuperCall(sym: ClassSymbol, calls: ClassSymbol)(using Context) = {
35-
ctx.genBCodePhase match {
36+
genBCodePhase match {
3637
case genBCodePhase: GenBCode =>
3738
genBCodePhase.registerSuperCall(sym, calls)
3839
case _ =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ object DottyBackendInterface {
160160
*/
161161
def isTopLevelModuleClass(using Context): Boolean =
162162
sym.is(ModuleClass) &&
163-
atPhase(ctx.flattenPhase) {
163+
atPhase(flattenPhase) {
164164
toDenot(sym).owner.is(PackageClass)
165165
}
166166

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import java.util.Optional
1515
import dotty.tools.dotc.core._
1616
import dotty.tools.dotc.sbt.ExtractDependencies
1717
import Contexts._
18+
import Phases._
1819
import Symbols._
1920
import Decorators._
2021

@@ -166,7 +167,7 @@ class GenBCodePipeline(val int: DottyBackendInterface)(using ctx: Context) exten
166167
if (classSymbol.effectiveName.toString < dupClassSym.effectiveName.toString) (classSymbol, dupClassSym)
167168
else (dupClassSym, classSymbol)
168169
val same = classSymbol.effectiveName.toString == dupClassSym.effectiveName.toString
169-
atPhase(ctx.typerPhase) {
170+
atPhase(typerPhase) {
170171
if (same)
171172
summon[Context].warning( // FIXME: This should really be an error, but then FromTasty tests fail
172173
s"${cl1.show} and ${cl2.showLocated} produce classes that overwrite one another", cl1.sourcePos)
@@ -271,7 +272,7 @@ class GenBCodePipeline(val int: DottyBackendInterface)(using ctx: Context) exten
271272

272273
// ----------- compiler and sbt's callbacks
273274

274-
val (fullClassName, isLocal) = atPhase(ctx.sbtExtractDependenciesPhase) {
275+
val (fullClassName, isLocal) = atPhase(sbtExtractDependenciesPhase) {
275276
(ExtractDependencies.classNameAsString(claszSymbol), claszSymbol.isLocal)
276277
}
277278

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ class JSCodeGen()(using genCtx: Context) {
21212121
if (isStat) {
21222122
boxedResult
21232123
} else {
2124-
val tpe = atPhase(ctx.elimErasedValueTypePhase) {
2124+
val tpe = atPhase(elimErasedValueTypePhase) {
21252125
sym.info.finalResultType
21262126
}
21272127
unbox(boxedResult, tpe)
@@ -2735,14 +2735,14 @@ class JSCodeGen()(using genCtx: Context) {
27352735
def paramNamesAndTypes(using Context): List[(Names.TermName, Type)] =
27362736
sym.info.paramNamess.flatten.zip(sym.info.paramInfoss.flatten)
27372737

2738-
val wereRepeated = atPhase(ctx.elimRepeatedPhase) {
2738+
val wereRepeated = atPhase(elimRepeatedPhase) {
27392739
val list =
27402740
for ((name, tpe) <- paramNamesAndTypes)
27412741
yield (name -> tpe.isRepeatedParam)
27422742
list.toMap
27432743
}
27442744

2745-
val paramTypes = atPhase(ctx.elimErasedValueTypePhase) {
2745+
val paramTypes = atPhase(elimErasedValueTypePhase) {
27462746
paramNamesAndTypes.toMap
27472747
}
27482748

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Flags._
66
import Symbols._
77
import NameOps._
88
import StdNames._
9+
import Phases._
910
import NameKinds.DefaultGetterName
1011

1112
import JSDefinitions._
@@ -16,7 +17,7 @@ object JSInterop {
1617
/** Is this symbol a JavaScript type? */
1718
def isJSType(sym: Symbol)(using Context): Boolean = {
1819
//sym.hasAnnotation(jsdefn.RawJSTypeAnnot)
19-
atPhase(ctx.erasurePhase) {
20+
atPhase(erasurePhase) {
2021
sym.derivesFrom(jsdefn.JSAnyClass)
2122
}
2223
}
@@ -32,7 +33,7 @@ object JSInterop {
3233
* much as *accessor* methods created for `val`s and `var`s.
3334
*/
3435
def isJSGetter(sym: Symbol)(using Context): Boolean = {
35-
sym.info.firstParamTypes.isEmpty && atPhase(ctx.erasurePhase) {
36+
sym.info.firstParamTypes.isEmpty && atPhase(erasurePhase) {
3637
sym.info.isParameterless
3738
}
3839
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package ast
44

55
import core._
66
import util.Spans._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._
7-
import Symbols._, StdNames._, Trees._
7+
import Symbols._, StdNames._, Trees._, Phases._
88
import Decorators.{given _}, transform.SymUtils._
99
import NameKinds.{UniqueName, EvidenceParamName, DefaultGetterName}
1010
import typer.{FrontEnd, Namer}
@@ -1402,7 +1402,7 @@ object desugar {
14021402
*/
14031403
def makeAnnotated(fullName: String, tree: Tree)(using Context): Annotated = {
14041404
val parts = fullName.split('.')
1405-
val ttree = ctx.typerPhase match {
1405+
val ttree = typerPhase match {
14061406
case phase: FrontEnd if phase.stillToBeEntered(parts.last) =>
14071407
val prefix =
14081408
parts.init.foldLeft(Ident(nme.ROOTPKG): Tree)((qual, name) =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotc
33
package config
44

55
import core._
6-
import Contexts._, Symbols._, Names._, NameOps._
6+
import Contexts._, Symbols._, Names._, NameOps._, Phases._
77
import StdNames.nme
88
import Decorators.{given _}
99
import util.SourcePosition
@@ -36,7 +36,7 @@ object Feature:
3636
* import owner.{ feature => _ }
3737
*/
3838
def enabledByImport(feature: TermName, owner: Symbol = NoSymbol)(using Context): Boolean =
39-
atPhase(ctx.typerPhase) {
39+
atPhase(typerPhase) {
4040
ctx.importInfo != null
4141
&& ctx.importInfo.featureImported(feature,
4242
if owner.exists then owner else defn.LanguageModule.moduleClass)

0 commit comments

Comments
 (0)