Skip to content

Commit 42eb864

Browse files
authored
Merge pull request #1873 from dotty-staging/fix-#1865
Fix #1865: Compute outer path at right phase
2 parents 2498cf9 + a7e88df commit 42eb864

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ object ExplicitOuter {
276276
if (tpe.prefix eq NoPrefix) cls.owner.enclosingClass.thisType
277277
else tpe.prefix
278278
case _ =>
279-
outerPrefix(tpe.underlying)
279+
// Need to be careful to dealias before erasure, otherwise we lose prefixes.
280+
outerPrefix(tpe.underlying(ctx.withPhaseNoLater(ctx.erasurePhase)))
280281
}
281282
case tpe: TypeProxy =>
282283
outerPrefix(tpe.underlying)

tests/pos/i1865.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class AbsCell {
2+
type T = Node
3+
class Node
4+
}
5+
6+
object Test {
7+
def test: Unit = {
8+
val cell = new AbsCell
9+
new cell.T
10+
}
11+
}
12+
13+
class AbsCell2 {
14+
type T = Node
15+
val value: T = value
16+
def set(x: T): Unit = {}
17+
class Node
18+
}
19+
object init {
20+
def main = {
21+
val cell = new AbsCell2 { val init = new Node }
22+
cell set (new cell.T)
23+
}
24+
}

0 commit comments

Comments
 (0)