Skip to content

Commit c17bbfe

Browse files
committed
Make sure widening does not refer non-existent abstract objects
1 parent ad0da27 commit c17bbfe

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,8 @@ class Semantic {
351351
case addr: Addr =>
352352
// widen the outer to finitize addresses
353353
val outer = addr match
354-
case _: ThisRef => addr
355-
case warm: Warm =>
356-
if warm.outer.isInstanceOf[Warm] then warm.copy(outer = Cold)
357-
else warm
354+
case Warm(_, _: Warm) => Cold
355+
case _ => addr
358356

359357
val value = Warm(klass, outer)
360358
if !heap.contains(value) then

tests/init/neg/inner-loop.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Outer { outer =>
22
class Inner extends Outer {
3-
val x = 5 + outer.n
3+
val x = 5 + outer.n // error
44
}
55
val inner = new Inner
66
val n = 6 // error

0 commit comments

Comments
 (0)