diff --git a/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala b/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala index 414b27101b7d..6dd85d730da8 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala @@ -225,6 +225,11 @@ class TreeTypeMap( val tmap1 = tmap.withMappedSyms( origCls(cls).typeParams ::: origDcls, cls.typeParams ::: mappedDcls) + mapped.foreach { sym => + // outer Symbols can reference nested ones in info, + // so we remap that once again with the updated TreeTypeMap + sym.info = tmap1.mapType(sym.info) + } origDcls.lazyZip(mappedDcls).foreach(cls.asClass.replace) tmap1 } diff --git a/tests/run/i23279.scala b/tests/run/i23279.scala new file mode 100644 index 000000000000..8774e5afcd79 --- /dev/null +++ b/tests/run/i23279.scala @@ -0,0 +1,28 @@ +inline def simpleInlineWrap(f: => Any): Unit = f + +@main def Test(): Unit = { + simpleInlineWrap { + object lifecycle { + object Lifecycle { + trait FromZIO + } + } + object defn { + val Lifecycle: lifecycle.Lifecycle.type = lifecycle.Lifecycle + } + val xa: defn.Lifecycle.type = defn.Lifecycle + } + + // more nested case + simpleInlineWrap { + object lifecycle { + object Lifecycle { + object FromZIO + } + } + object defn { + val Lifecycle: lifecycle.Lifecycle.type = lifecycle.Lifecycle + } + val xa: defn.Lifecycle.FromZIO.type = defn.Lifecycle.FromZIO + } +}