Skip to content

Commit 2b55f0e

Browse files
jchybtgodzik
authored andcommitted
Fix Symbol.info remapping in TreeTypeMap
Previously, the map would first copy and remap the outermost symbols, then inner declarations, then ddeclarations of those declarations etc., so if an outer symbol referred to a more nested one, that reference was not remapped, causing issues later. [Cherry-picked e57d743]
1 parent a24216f commit 2b55f0e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ class TreeTypeMap(
224224
val tmap1 = tmap.withMappedSyms(
225225
origCls(cls).typeParams ::: origDcls,
226226
cls.typeParams ::: mappedDcls)
227+
mapped.foreach { sym =>
228+
// outer Symbols can reference nested ones in info,
229+
// so we remap that once again with the updated TreeTypeMap
230+
sym.info = tmap1.mapType(sym.info)
231+
}
227232
origDcls.lazyZip(mappedDcls).foreach(cls.asClass.replace)
228233
tmap1
229234
}

tests/run/i23279.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
inline def simpleInlineWrap(f: => Any): Unit = f
2+
3+
@main def Test(): Unit = {
4+
simpleInlineWrap {
5+
object lifecycle {
6+
object Lifecycle {
7+
trait FromZIO
8+
}
9+
}
10+
object defn {
11+
val Lifecycle: lifecycle.Lifecycle.type = lifecycle.Lifecycle
12+
}
13+
val xa: defn.Lifecycle.type = defn.Lifecycle
14+
}
15+
16+
// more nested case
17+
simpleInlineWrap {
18+
object lifecycle {
19+
object Lifecycle {
20+
object FromZIO
21+
}
22+
}
23+
object defn {
24+
val Lifecycle: lifecycle.Lifecycle.type = lifecycle.Lifecycle
25+
}
26+
val xa: defn.Lifecycle.FromZIO.type = defn.Lifecycle.FromZIO
27+
}
28+
}

0 commit comments

Comments
 (0)