diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-09-29 16:02:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-29 16:02:53 -0700 |
commit | 1615ce9eb406c6c9de608900a3338ac715caabc6 (patch) | |
tree | 401fdb2c036f719aaa6201c88256022bf0ebbbaa /test/files/run/SD-235.scala | |
parent | 510d8ef05af7bb8602f3ce79a04826b5449d3aaf (diff) | |
parent | 515bc60e028c6d1c204e914b0869b4f0bd6dab8e (diff) | |
download | scala-1615ce9eb406c6c9de608900a3338ac715caabc6.tar.gz scala-1615ce9eb406c6c9de608900a3338ac715caabc6.tar.bz2 scala-1615ce9eb406c6c9de608900a3338ac715caabc6.zip |
Merge pull request #5430 from adriaanm/dev235
Emit local module like lazy val
Diffstat (limited to 'test/files/run/SD-235.scala')
-rw-r--r-- | test/files/run/SD-235.scala | 39 |
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 + } +} |