summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2016-07-17 22:04:46 -0700
committerAdriaan Moors <adriaan@lightbend.com>2016-08-11 10:59:17 -0700
commit3540ffc1fb81eef75aeff41a0ba9142b1cce8a53 (patch)
tree45586d44ba0bc4914143e9412896c01ec1d61c52 /test
parent4555681544ec40c5b787b9708266fcbdcc2ff62b (diff)
downloadscala-3540ffc1fb81eef75aeff41a0ba9142b1cce8a53.tar.gz
scala-3540ffc1fb81eef75aeff41a0ba9142b1cce8a53.tar.bz2
scala-3540ffc1fb81eef75aeff41a0ba9142b1cce8a53.zip
Admit @volatile on accessor in trait
There's no other place to squirrel away the annotation until we create a field in a subclass. The test documents the idea, but does not capture the regression seen in the wild, as explained in a comment.
Diffstat (limited to 'test')
-rw-r--r--test/files/pos/trait_fields_volatile.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/files/pos/trait_fields_volatile.scala b/test/files/pos/trait_fields_volatile.scala
new file mode 100644
index 0000000000..030b24f187
--- /dev/null
+++ b/test/files/pos/trait_fields_volatile.scala
@@ -0,0 +1,13 @@
+// This test illustrates the intent of what should work (but didn't for a while during the fields refactoring),
+// but it does not actually defend against the regression seen in twitter-util's Scheduler, which I cannot reproduce
+// outside the project. The whole project consistently fails to build before, and compiles after the commit
+// that includes this test, but this single test file (as well as Scheduler.scala with external dependencies removed)
+// compiles both before and after....
+// (https://github.com/twitter/util/blob/6398a56923/util-core/src/main/scala/com/twitter/concurrent/Scheduler.scala#L260-L265)
+// There's also a run test that checks that the field in C is actually volatile.
+trait Vola {
+ @volatile private[this] var _vola = "tile"
+ @volatile var vola = "tile"
+}
+
+class C extends Vola