diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2016-07-17 22:04:46 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-08-11 10:59:17 -0700 |
commit | 3540ffc1fb81eef75aeff41a0ba9142b1cce8a53 (patch) | |
tree | 45586d44ba0bc4914143e9412896c01ec1d61c52 /src/compiler/scala/tools/nsc | |
parent | 4555681544ec40c5b787b9708266fcbdcc2ff62b (diff) | |
download | scala-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 'src/compiler/scala/tools/nsc')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index efb0830204..1fe8438b56 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2008,7 +2008,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper val tpt1 = checkNoEscaping.privates(sym, typedType(vdef.tpt)) checkNonCyclic(vdef, tpt1) - if (sym.hasAnnotation(definitions.VolatileAttr) && !sym.isMutable) + // allow trait accessors: it's the only vehicle we have to hang on to annotations that must be passed down to + // the field that's mixed into a subclass + if (sym.hasAnnotation(definitions.VolatileAttr) && !((sym hasFlag MUTABLE) || (sym hasFlag ACCESSOR) && sym.owner.isTrait)) VolatileValueError(vdef) val rhs1 = |