Skip to content

Commit 7a7f144

Browse files
committed
Fix test case to error when missing cacheResult flag
1 parent 353d964 commit 7a7f144

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ object Semantic:
893893

894894
case Cold => Cold
895895

896-
case ref: Ref => eval(vdef.rhs, ref, enclosingClass)
896+
case ref: Ref => eval(vdef.rhs, ref, enclosingClass, cacheResult = sym.is(Flags.Lazy))
897897

898898
case _ =>
899899
report.error("[Internal error] unexpected this value when accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show + Trace.show, Trace.position)

tests/init/pos/recursion.scala

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/init/pos/self-ref.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class A {
2+
def foo(a: Int) = {
3+
lazy val x: Int = if (a == 0) x else 0
4+
println(x)
5+
}
6+
foo(0)
7+
8+
val y = 5
9+
}

0 commit comments

Comments
 (0)