@@ -2,6 +2,7 @@ package dotty.tools
2
2
package dotc
3
3
package ast
4
4
5
+ import dotty .tools .dotc .transform .ExplicitOuter
5
6
import dotty .tools .dotc .typer .ProtoTypes .FunProtoTyped
6
7
import transform .SymUtils ._
7
8
import core ._
@@ -243,6 +244,17 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
243
244
ta.assignType(untpd.TypeDef (cls.name, impl), cls)
244
245
}
245
246
247
+ // { <label> def while$(): Unit = if (cond) { body; while$() } ; while$() }
248
+ def WhileDo (owner : Symbol , cond : Tree , body : List [Tree ])(implicit ctx : Context ): Tree = {
249
+ val sym = ctx.newSymbol(owner, nme.WHILE_PREFIX , Flags .Label | Flags .Synthetic ,
250
+ MethodType (Nil , defn.UnitType ), coord = cond.pos)
251
+
252
+ val call = Apply (ref(sym), Nil )
253
+ val rhs = If (cond, Block (body, call), unitLiteral)
254
+ Block (List (DefDef (sym, rhs)), call)
255
+ }
256
+
257
+
246
258
def Import (expr : Tree , selectors : List [untpd.Tree ])(implicit ctx : Context ): Import =
247
259
ta.assignType(untpd.Import (expr, selectors), ctx.newImportSymbol(ctx.owner, expr))
248
260
@@ -288,7 +300,16 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
288
300
if (tp.isType) TypeTree (tp)
289
301
else if (prefixIsElidable(tp)) Ident (tp)
290
302
else tp.prefix match {
291
- case pre : SingletonType => singleton(pre).select(tp)
303
+ case pre : SingletonType =>
304
+ val prefix =
305
+ singleton(pre) match {
306
+ case t : This if ctx.erasedTypes && ! (t.symbol == ctx.owner.enclosingClass || t.symbol.isStaticOwner) =>
307
+ // after erasure outer paths should be respected
308
+ new ExplicitOuter .OuterOps (ctx).path(t.tpe.widen.classSymbol)
309
+ case t =>
310
+ t
311
+ }
312
+ prefix.select(tp)
292
313
case pre => SelectFromTypeTree (TypeTree (pre), tp)
293
314
} // no checks necessary
294
315
@@ -563,7 +584,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
563
584
loop(from.owner, from :: froms, to :: tos)
564
585
else {
565
586
// println(i"change owner ${from :: froms}%, % ==> $tos of $tree")
566
- new TreeTypeMap (oldOwners = from :: froms, newOwners = tos).apply(tree)
587
+ new TreeTypeMap (oldOwners = from :: froms, newOwners = tos)(ctx.withMode( Mode . FutureDefsOK )) .apply(tree)
567
588
}
568
589
}
569
590
loop(from, Nil , to :: Nil )
@@ -578,8 +599,11 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
578
599
def traverse (tree : Tree )(implicit ctx : Context ) = tree match {
579
600
case tree : DefTree =>
580
601
val sym = tree.symbol
581
- if (sym.denot(ctx.withPhase(trans)).owner == from)
582
- sym.copySymDenotation(owner = to).installAfter(trans)
602
+ if (sym.denot(ctx.withPhase(trans)).owner == from) {
603
+ val d = sym.copySymDenotation(owner = to)
604
+ d.installAfter(trans)
605
+ d.transformAfter(trans, d => if (d.owner eq from) d.copySymDenotation(owner = to) else d)
606
+ }
583
607
if (sym.isWeakOwner) traverseChildren(tree)
584
608
case _ =>
585
609
traverseChildren(tree)
0 commit comments