Skip to content

Change/defaultphase #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 15, 2014
8 changes: 5 additions & 3 deletions src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ object Contexts {

/** The current context */
private[this] var _period: Period = _
protected def period_=(period: Period) = _period = period
protected def period_=(period: Period) = {
assert(period.firstPhaseId == period.lastPhaseId, period)
_period = period
}
def period: Period = _period

/** The scope nesting level */
Expand Down Expand Up @@ -193,7 +196,7 @@ object Contexts {
/** This context at given phase.
* This method will always return a phase period equal to phaseId, thus will never return squashed phases
*/
final def withPhase(phaseId: PhaseId): Context = {
final def withPhase(phaseId: PhaseId): Context =
if (this.phaseId == phaseId) this
else if (phasedCtx.phaseId == phaseId) phasedCtx
else if (phasedCtxs != null && phasedCtxs(phaseId) != null) phasedCtxs(phaseId)
Expand All @@ -206,7 +209,6 @@ object Contexts {
}
ctx1
}
}

final def withPhase(phase: Phase): Context =
withPhase(phase.id)
Expand Down
6 changes: 3 additions & 3 deletions src/dotty/tools/dotc/core/Phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ object Phases {
private val patmatCache = new PhaseCache(classOf[PatternMatcher])
private val flattenCache = new PhaseCache(classOf[Flatten])
private val explicitOuterCache = new PhaseCache(classOf[ExplicitOuter])
private val gettersSettersCache = new PhaseCache(classOf[GettersSetters])
private val gettersCache = new PhaseCache(classOf[Getters])

def typerPhase = typerCache.phase
def refchecksPhase = refChecksCache.phase
def erasurePhase = erasureCache.phase
def patmatPhase = patmatCache.phase
def flattenPhase = flattenCache.phase
def explicitOuterPhase = explicitOuterCache.phase
def gettersSettersPhase = gettersSettersCache.phase
def gettersPhase = gettersCache.phase

def isAfterTyper(phase: Phase): Boolean = phase.id > typerPhase.id
}
Expand All @@ -194,7 +194,7 @@ object Phases {

def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] =
units.map { unit =>
val unitCtx = ctx.fresh.setPhase(this).setCompilationUnit(unit)
val unitCtx = ctx.fresh.setPhase(this.start).setCompilationUnit(unit)
run(unitCtx)
unitCtx.compilationUnit
}
Expand Down
17 changes: 9 additions & 8 deletions src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,16 @@ object Symbols {
* that starts being valid after `phase`.
* @pre Symbol is a class member
*/
def enteredAfter(phase: DenotTransformer)(implicit ctx: Context): this.type = {
val nextCtx = ctx.withPhase(phase.next)
if (this.owner.is(Package)) {
denot.validFor |= InitialPeriod
if (this is Module) this.moduleClass.validFor |= InitialPeriod
def enteredAfter(phase: DenotTransformer)(implicit ctx: Context): this.type =
if (ctx.phaseId != phase.next.id) enteredAfter(phase)(ctx.withPhase(phase.next))
else {
if (this.owner.is(Package)) {
denot.validFor |= InitialPeriod
if (this is Module) this.moduleClass.validFor |= InitialPeriod
}
else this.owner.asClass.ensureFreshScopeAfter(phase)
entered
}
else this.owner.asClass.ensureFreshScopeAfter(phase)(nextCtx)
entered(nextCtx)
}

/** This symbol, if it exists, otherwise the result of evaluating `that` */
def orElse(that: => Symbol)(implicit ctx: Context) =
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ class TypeComparer(initctx: Context) extends DotClass {
tp2.info match {
case tp2i: TermRef =>
isSubType(tp1, tp2i)
case ExprType(tp2i: TermRef) if (ctx.phase.id > ctx.gettersSettersPhase.id) =>
case ExprType(tp2i: TermRef) if (ctx.phase.id > ctx.gettersPhase.id) =>
isSubType(tp1, tp2i)
case _ =>
false
Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/transform/CapturedVars.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisTransfo

class Transform(captured: collection.Set[Symbol]) extends TreeTransform {
def phase = thisTransform
override def treeTransformPhase = thisTransform.next

private class CollectCaptured(implicit ctx: Context) extends EnclosingMethodTraverser {
private val captured = mutable.HashSet[Symbol]()
Expand Down
2 changes: 0 additions & 2 deletions src/dotty/tools/dotc/transform/Constructors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
override def phaseName: String = "constructors"
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Erasure])

override def treeTransformPhase = thisTransform.next

/** Symbols that are owned by either <local dummy> or a class field move into the
* primary constructor.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/dotty/tools/dotc/transform/ElimByName.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
// assumes idents and selects have symbols; interferes with splitter distribution
// that's why it's "after group".

override def treeTransformPhase = thisTransformer.next

/** The info of the tree's symbol at phase Nullarify (i.e. before transformation) */
private def originalDenotation(tree: Tree)(implicit ctx: Context) =
tree.symbol.denot(ctx.withPhase(thisTransformer))
Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/transform/ExplicitOuter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf
* before this phase starts
*/
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[PatternMatcher])
override def treeTransformPhase = thisTransformer.next

/** Add outer accessors if a class always needs an outer pointer */
override def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context) = tp match {
Expand Down
2 changes: 0 additions & 2 deletions src/dotty/tools/dotc/transform/ExtensionMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
ref
}

override def treeTransformPhase = thisTransformer.next

protected def rewiredTarget(target: Symbol, derived: Symbol)(implicit ctx: Context): Symbol =
if (isMethodWithExtension(target) &&
target.owner.linkedClass == derived.owner) extensionMethod(target)
Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/transform/FirstTransform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi

override def phaseName = "firstTransform"


def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp

override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = tree match {
Expand Down
2 changes: 0 additions & 2 deletions src/dotty/tools/dotc/transform/Flatten.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class Flatten extends MiniPhaseTransform with SymTransformer { thisTransform =>
else ref
}

override def treeTransformPhase = thisTransform.next

private val liftedDefs = new mutable.ListBuffer[Tree]

private def liftIfNested(tree: Tree)(implicit ctx: Context, info: TransformerInfo) =
Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/transform/Getters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class Getters extends MiniPhaseTransform with SymTransformer { thisTransform =>
import ast.tpd._

override def phaseName = "getters"
override def treeTransformPhase = thisTransform.next

override def transformSym(d: SymDenotation)(implicit ctx: Context): SymDenotation = {
def noGetterNeeded =
Expand Down
117 changes: 0 additions & 117 deletions src/dotty/tools/dotc/transform/GettersSetters.scala

This file was deleted.

2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/InterceptedMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import StdNames._
* using the most precise overload available
* - `x.getClass` for getClass in primitives becomes `x.getClass` with getClass in class Object.
*/
class InterceptedMethods extends MiniPhaseTransform {
class InterceptedMethods extends MiniPhaseTransform { thisTransform =>

import tpd._

Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform

class LambdaLifter extends TreeTransform {
override def phase = thisTransform
override def treeTransformPhase = thisTransform.next

private type SymSet = TreeSet[Symbol]

Expand Down
2 changes: 0 additions & 2 deletions src/dotty/tools/dotc/transform/LazyVals.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class LazyValsTransform extends MiniPhaseTransform with IdentityDenotTransformer

override def phaseName: String = "LazyVals"

override def treeTransformPhase = this.next

/** List of names of phases that should have finished processing of tree
* before this phase starts processing same tree */
// override def ensureAfter: Set[String] = Set("mixin")
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/Literalize.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ast.Trees._
* The constant types are eliminated by erasure, so we need to keep
* the info about constantness in the trees.
*/
class Literalize extends MiniPhaseTransform {
class Literalize extends MiniPhaseTransform { thisTransform =>
import ast.tpd._

override def phaseName: String = "literalize"
Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/transform/Memoize.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import Decorators._
import ast.tpd._

override def phaseName = "memoize"
override def treeTransformPhase = thisTransform.next

/** Should to run after mixin so that fields get generated in the
* class that contains the concrete getter rather than the trait
Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/transform/Mixin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform =>
import ast.tpd._

override def phaseName: String = "mixin"
override def treeTransformPhase = thisTransform.next

override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Erasure])

Expand Down
2 changes: 0 additions & 2 deletions src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import scala.reflect.internal.util.Collections
class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTransformer =>
import dotty.tools.dotc.ast.tpd._

override def treeTransformPhase = thisTransformer.next

override def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = ref

override def runsAfter = Set(classOf[ElimRepeated])
Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/transform/PrivateToStatic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class PrivateToStatic extends MiniPhase with SymTransformer { thisTransform =>

class Transform(thisParam: Symbol) extends TreeTransform {
def phase = thisTransform
override def treeTransformPhase = thisTransform.next

override def prepareForDefDef(tree: DefDef)(implicit ctx: Context) =
if (shouldBeStatic(tree.symbol)) {
Expand Down
2 changes: 0 additions & 2 deletions src/dotty/tools/dotc/transform/ResolveSuper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class ResolveSuper extends MiniPhaseTransform with IdentityDenotTransformer { th

override def phaseName: String = "resolveSuper"

override def treeTransformPhase = thisTransform.next

/** Returns the symbol that is accessed by a super-accessor in a mixin composition.
*
* @param base The class in which everything is mixed together
Expand Down
2 changes: 0 additions & 2 deletions src/dotty/tools/dotc/transform/RestoreScopes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class RestoreScopes extends MiniPhaseTransform with IdentityDenotTransformer { t
import ast.tpd._
override def phaseName = "restoreScopes"

override def treeTransformPhase = thisTransform.next

override def transformTypeDef(tree: TypeDef)(implicit ctx: Context, info: TransformerInfo) = {
val TypeDef(_, Template(constr, _, _, body)) = tree
val restoredDecls = newScope
Expand Down
3 changes: 1 addition & 2 deletions src/dotty/tools/dotc/transform/SeqLiterals.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import Decorators._
* is called directly. The reason for this step is that JavaSeqLiterals, being arrays
* keep a precise type after erasure, whereas SeqLiterals only get the erased type `Seq`,
*/
class SeqLiterals extends MiniPhaseTransform { thisTransformer =>
class SeqLiterals extends MiniPhaseTransform {
import ast.tpd._

override def phaseName = "seqLiterals"
override def treeTransformPhase = thisTransformer.next
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[PatternMatcher])

override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = tree match {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/Splitter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Contexts._, Types._, Decorators._, Denotations._, Symbols._, SymDenotatio
*
* For now, only self references are treated.
*/
class Splitter extends MiniPhaseTransform {
class Splitter extends MiniPhaseTransform { thisTransform =>
import ast.tpd._

override def phaseName: String = "splitter"
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/SyntheticMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class SyntheticMethods extends MiniPhaseTransform with IdentityDenotTransformer
override def transformTemplate(impl: Template)(implicit ctx: Context, info: TransformerInfo) =
if (ctx.owner.is(Case) || isDerivedValueClass(ctx.owner))
cpy.Template(impl)(
body = impl.body ++ syntheticMethods(ctx.owner.asClass)(ctx.withPhase(thisTransformer.next)))
body = impl.body ++ syntheticMethods(ctx.owner.asClass))
else
impl
}
Loading