summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2016-11-25 10:04:12 +0100
committerGitHub <noreply@github.com>2016-11-25 10:04:12 +0100
commiteb7d907f6283f897f6b248bae170bade57969519 (patch)
tree52a4db097a27a496845e56c4a86f605a1d21e127 /test/files
parentd5f21af9f41d8f4bd22ee6126e1476b4a76c51c2 (diff)
parent824103644337758f2a6a70ea69a33a9671e1e69c (diff)
downloadscala-eb7d907f6283f897f6b248bae170bade57969519.tar.gz
scala-eb7d907f6283f897f6b248bae170bade57969519.tar.bz2
scala-eb7d907f6283f897f6b248bae170bade57969519.zip
Merge pull request #5540 from retronym/ticket/9814
SI-9814 Fix synchronized in specialized overrides
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/t9814.scala28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/files/run/t9814.scala b/test/files/run/t9814.scala
new file mode 100644
index 0000000000..3aef3928f6
--- /dev/null
+++ b/test/files/run/t9814.scala
@@ -0,0 +1,28 @@
+import java.lang.reflect.Modifier
+
+import scala.annotation.strictfp
+
+class Foo extends (() => Unit) {
+ def apply(): Unit = synchronized {
+ // we're in a specialized subclass
+ assert(Thread.currentThread.getStackTrace.apply(1).getMethodName == "apply$mcV$sp")
+ assert(Thread.holdsLock(this))
+ }
+}
+
+class Bar extends (() => Unit) {
+ @strictfp def apply(): Unit = synchronized {
+ // we're in a specialized subclass
+ assert(Thread.currentThread.getStackTrace.apply(1).getMethodName == "apply$mcV$sp")
+ assert(Thread.holdsLock(this))
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ new Foo().apply()
+
+ val m = classOf[Bar].getDeclaredMethod("apply$mcV$sp")
+ assert(Modifier.isStrict(m.getModifiers))
+ }
+}