summaryrefslogtreecommitdiff
path: root/test/files/run/SD-235.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/SD-235.scala')
-rw-r--r--test/files/run/SD-235.scala39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/files/run/SD-235.scala b/test/files/run/SD-235.scala
new file mode 100644
index 0000000000..eb79c6fe71
--- /dev/null
+++ b/test/files/run/SD-235.scala
@@ -0,0 +1,39 @@
+class C {
+ var ORef: Object = null
+ def test = {
+ object O {
+ assert(!Thread.holdsLock(C.this))
+ assert(Thread.holdsLock(ORef))
+ }
+ val captor = new { def oh = O }
+ val refField = captor.getClass.getDeclaredFields.last
+ refField.setAccessible(true)
+ assert(refField.getType.toString.contains("LazyRef"), refField)
+ ORef = refField.get(captor)
+ O
+ }
+}
+
+class D {
+ var ORef: Object = null
+ def test = {
+ lazy val O = {
+ assert(!Thread.holdsLock(D.this))
+ assert(Thread.holdsLock(ORef))
+ "O"
+ }
+ val captor = new { def oh = O }
+ val refField = captor.getClass.getDeclaredFields.last
+ refField.setAccessible(true)
+ assert(refField.getType.toString.contains("LazyRef"), refField)
+ ORef = refField.get(captor)
+ O
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ new C().test
+ new D().test
+ }
+}