File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package dotty.tools.dotc
22package transform
33
44import MegaPhase ._
5+ import core .Denotations .NonSymSingleDenotation
56import core .DenotTransformers ._
67import core .Symbols ._
78import core .Contexts ._
@@ -530,7 +531,18 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisPhase =>
530531 override def prepareForUnit (tree : Tree )(using Context ): Context =
531532 ctx.fresh.updateStore(Lifter , new Lifter (thisPhase))
532533
534+ /** The Lifter updates the type of symbols using `installAfter` to give them a
535+ * new `SymDenotation`, but that doesn't affect non-sym denotations, so we
536+ * reload them manually here.
537+ */
538+ private def reloadDenotation (tp : Type )(using Context ): Unit = tp match
539+ case tp : NamedType =>
540+ if tp.denot.isInstanceOf [NonSymSingleDenotation ] && lifter.free.contains(tp.symbol) then
541+ tp.recomputeDenot()
542+ case _ =>
543+
533544 override def transformIdent (tree : Ident )(using Context ): Tree = {
545+ reloadDenotation(tree.tpe)
534546 val sym = tree.symbol
535547 tree.tpe match {
536548 case tpe @ TermRef (prefix, _) =>
@@ -549,6 +561,10 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisPhase =>
549561 }
550562 }
551563
564+ override def transformSelect (tree : Select )(using Context ): Tree =
565+ reloadDenotation(tree.tpe)
566+ tree
567+
552568 override def transformApply (tree : Apply )(using Context ): Apply =
553569 cpy.Apply (tree)(tree.fun, lifter.addFreeArgs(tree.symbol, tree.args)).withSpan(tree.span)
554570
Original file line number Diff line number Diff line change 1+ object Bug {
2+ def bar (ev : Any ) = {
3+ trait X (val x : Int ) {
4+ def qux : () => x.type = { () => println(ev); x }
5+ }
6+ (new X (1 ) {}).qux()
7+ }
8+ }
9+
You can’t perform that action at this time.
0 commit comments