diff options
author | Sébastien Doeraene <sjrdoeraene@gmail.com> | 2016-02-27 18:39:40 +0100 |
---|---|---|
committer | Sébastien Doeraene <sjrdoeraene@gmail.com> | 2016-03-01 15:47:56 +0100 |
commit | 0ebf36b394b00f3f432d8fdedeaa15e7d4df2b06 (patch) | |
tree | 14938c97bc207b86aa175edbc0c3e4d151c8ecbf /src/dotty/tools/dotc/transform/Memoize.scala | |
parent | b347d2725d1a4e5f66d798be79d3fc3f0f44ea88 (diff) | |
download | dotty-0ebf36b394b00f3f432d8fdedeaa15e7d4df2b06.tar.gz dotty-0ebf36b394b00f3f432d8fdedeaa15e7d4df2b06.tar.bz2 dotty-0ebf36b394b00f3f432d8fdedeaa15e7d4df2b06.zip |
Mark concrete vals mixed in from Scala2 traits as mutable.
When a concrete val is mixed in from a Scala2 trait, a setter is
generated, which is called by the `$init$` method. Since the
assignment in this setter is not done in the constructor, it is
nonsensical for the field to be immutable.
This commit sets the Mutable flag on such fields. It only applies
for vals coming from Scala2 traits. vals coming from Dotty traits
are kept immutable.
Diffstat (limited to 'src/dotty/tools/dotc/transform/Memoize.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/Memoize.scala | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/transform/Memoize.scala b/src/dotty/tools/dotc/transform/Memoize.scala index fbf8ed763..b775496ae 100644 --- a/src/dotty/tools/dotc/transform/Memoize.scala +++ b/src/dotty/tools/dotc/transform/Memoize.scala @@ -91,6 +91,7 @@ import Decorators._ } } else if (sym.isSetter) { if (!sym.is(ParamAccessor)) { val Literal(Constant(())) = tree.rhs } // this is intended as an assertion + field.setFlag(Mutable) // necessary for vals mixed in from Scala2 traits val initializer = Assign(ref(field), ref(tree.vparamss.head.head.symbol)) cpy.DefDef(tree)(rhs = transformFollowingDeep(initializer)(ctx.withOwner(sym), info)) } |