Skip to content

Commit f2e3489

Browse files
committed
More docs and removing print statements
1 parent 06c50af commit f2e3489

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class Compiler {
4646
new TailRec),
4747
List(new PatternMatcher,
4848
new ExplicitOuter,
49-
// new LazyValTranformContext().transformer, // disabled, awaiting fixes
5049
new Splitter),
5150
List(new ElimByName,
5251
new InterceptedMethods,
@@ -55,7 +54,7 @@ class Compiler {
5554
new ResolveSuper),
5655
List(new Erasure),
5756
List(new Mixin,
58-
new Memoize,
57+
new Memoize, // TODO: Make LazyVals a part of this phase
5958
new CapturedVars,
6059
new Constructors),
6160
List(new LambdaLift,

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
546546
def traverse(tree: Tree) = tree match {
547547
case tree: DefTree =>
548548
val sym = tree.symbol
549-
if (sym.denot(ctx.withPhase(trans)).owner == from) {
550-
println(i"change owner $from -> $to of $sym")
549+
if (sym.denot(ctx.withPhase(trans)).owner == from)
551550
sym.copySymDenotation(owner = to).installAfter(trans)
552-
}
553551
if (sym.isWeakOwner) traverseChildren(tree)
554552
case _ =>
555553
traverseChildren(tree)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import Decorators._
3636
*
3737
* p.x = e
3838
* --> p.x_=(e)
39+
*
40+
* No fields are generated yet. This is done later in phase Memoize.
3941
*/
4042
class Getters extends MiniPhaseTransform with SymTransformer { thisTransform =>
4143
import ast.tpd._

src/dotty/tools/dotc/transform/Memoize.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ import Decorators._
3737
override def phaseName = "memoize"
3838
override def treeTransformPhase = thisTransform.next
3939

40+
/** Should to run after mixin so that fields get generated in the
41+
* class that contains the concrete getter rather than the trait
42+
* that defines it.
43+
*/
44+
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Mixin])
45+
4046
override def prepareForDefDef(tree: DefDef)(implicit ctx: Context) = {
4147
val sym = tree.symbol
4248
if (sym.isGetter && !sym.is(NoFieldNeeded)) {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import Decorators._
1313
import DenotTransformers._
1414
import StdNames._
1515
import NameOps._
16+
import Phases._
1617
import ast.Trees._
1718
import collection.mutable
1819

19-
// todo: interface
2020
/** This phase performs the following transformations:
2121
*
2222
* 1. (done in `traitDefs`) Map every concrete trait getter
@@ -57,14 +57,20 @@ import collection.mutable
5757
* 3.3 (done in `setters`) For every concrete setter `<mods> def x_=(y: T)` in M:
5858
*
5959
* <mods> def x_=(y: T) = ()
60+
*
61+
* Conceptually, this is the second half of the previous mixin phase. It needs to run
62+
* after erasure because it copies references to possibly private inner classes and objects
63+
* into enclosing classes where they are not visible. This can only be done if all references
64+
* are symbolic.
6065
*/
6166
class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform =>
6267
import ast.tpd._
6368

6469
override def phaseName: String = "mixin"
65-
6670
override def treeTransformPhase = thisTransform.next
6771

72+
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Erasure])
73+
6874
override def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation =
6975
if (sym.is(Accessor, butNot = Deferred) && sym.owner.is(Trait))
7076
sym.copySymDenotation(initFlags = sym.flags | Deferred)

src/dotty/tools/dotc/transform/ResolveSuper.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ import collection.mutable
3939
*
4040
* A method in M needs to be disambiguated if it is concrete, not overridden in C,
4141
* and if it overrides another concrete method.
42+
*
43+
* This is the first part of what was the mixin phase. It is complemented by
44+
* Mixin, which runs after erasure.
4245
*/
4346
class ResolveSuper extends MiniPhaseTransform with IdentityDenotTransformer { thisTransform =>
4447
import ast.tpd._
@@ -61,11 +64,11 @@ class ResolveSuper extends MiniPhaseTransform with IdentityDenotTransformer { th
6164
var bcs = cls.info.baseClasses.dropWhile(acc.owner != _).tail
6265
var sym: Symbol = NoSymbol
6366
val SuperAccessorName(memberName) = acc.name: Name // dotty deviation: ": Name" needed otherwise pattern type is neither a subtype nor a supertype of selector type
64-
println(i"starting rebindsuper from $cls of ${acc.showLocated}: ${acc.info} in $bcs, name = $memberName")
67+
ctx.debuglog(i"starting rebindsuper from $cls of ${acc.showLocated}: ${acc.info} in $bcs, name = $memberName")
6568
while (bcs.nonEmpty && sym == NoSymbol) {
6669
val other = bcs.head.info.nonPrivateDecl(memberName)
67-
//if (ctx.settings.debug.value)
68-
println(i"rebindsuper ${bcs.head} $other deferred = ${other.symbol.is(Deferred)}")
70+
if (ctx.settings.debug.value)
71+
ctx.log(i"rebindsuper ${bcs.head} $other deferred = ${other.symbol.is(Deferred)}")
6972
sym = other.matchingDenotation(cls.thisType, cls.thisType.memberInfo(acc)).symbol
7073
bcs = bcs.tail
7174
}

0 commit comments

Comments
 (0)