diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2017-02-13 20:36:28 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2017-02-18 23:35:34 +0100 |
commit | b2e4fe3212c226f03869c9f7c4d0b921a4e424de (patch) | |
tree | df47e2cb647b9897e36561577c71a7b887a102fd /compiler/src/dotty/tools/dotc | |
parent | 7e53f17c19d02e28c59298e5c6c05d7d2aa5bee8 (diff) | |
download | dotty-b2e4fe3212c226f03869c9f7c4d0b921a4e424de.tar.gz dotty-b2e4fe3212c226f03869c9f7c4d0b921a4e424de.tar.bz2 dotty-b2e4fe3212c226f03869c9f7c4d0b921a4e424de.zip |
TreeUnpickler: do not capture Context in Annotation symbol
Diffstat (limited to 'compiler/src/dotty/tools/dotc')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Annotations.scala | 14 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 4 |
2 files changed, 13 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index 985b1ea3d..8280c69c3 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -117,11 +117,17 @@ object Annotations { } /** Create an annotation where the symbol and the tree are computed lazily. */ - def deferredSymAndTree(sym: => Symbol, treeFn: Context => Tree)(implicit ctx: Context): Annotation = + def deferredSymAndTree(symf: Context => Symbol, treeFn: Context => Tree)(implicit ctx: Context): Annotation = new LazyAnnotation { - lazy val symf = sym - - override def symbol(implicit ctx: Context): Symbol = symf + private[this] var mySym: Symbol = _ + + override def symbol(implicit ctx: Context): Symbol = { + if (mySym == null) { + mySym = symf(ctx) + assert(mySym != null) + } + mySym + } def complete(implicit ctx: Context) = treeFn(ctx) } diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 55de06b3e..fcba957c0 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -554,7 +554,9 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle val end = readEnd() val tp = readType() val lazyAnnotTree = readLater(end, rdr => ctx => rdr.readTerm()(ctx)) - annots += Annotation.deferredSymAndTree(tp.typeSymbol, implicit ctx => lazyAnnotTree.complete) + annots += Annotation.deferredSymAndTree( + implicit ctx => tp.typeSymbol, + implicit ctx => lazyAnnotTree.complete) case tag => assert(false, s"illegal modifier tag $tag at $currentAddr, end = $end") } |