diff --git a/tests/run/i13358.check b/tests/run/i13358.check new file mode 100644 index 000000000000..d5425d4bc05f --- /dev/null +++ b/tests/run/i13358.check @@ -0,0 +1,8 @@ +1 +1 +1 +1 +2 +2 +2 +2 diff --git a/tests/run/i13358.scala b/tests/run/i13358.scala new file mode 100644 index 000000000000..c469e5373f54 --- /dev/null +++ b/tests/run/i13358.scala @@ -0,0 +1,22 @@ +object Test: + var cnt = 0 + + trait Foo: + lazy val foo1 = {cnt+=1; cnt} + + @scala.annotation.targetName("fooTwo") + lazy val foo2 = {cnt+=1; cnt} + + object Bar extends Foo + + def main(sa: Array[String]): Unit = + + println(Bar.foo1) // Prints 1 + println(Bar.foo1) // Prints 1 + println(Bar.foo1) // Prints 1 + println(Bar.foo1) // Prints 1 + + println(Bar.foo2) // Prints 2 + println(Bar.foo2) // Prints 3 EXPECTED 2 + println(Bar.foo2) // Prints 4 EXPECTED 2 + println(Bar.foo2) // Prints 5 EXPECTED 2 \ No newline at end of file