@@ -513,7 +513,7 @@ class TreeUnpickler(reader: TastyReader,
513
513
val rhsStart = currentAddr
514
514
val rhsIsEmpty = nothingButMods(end)
515
515
if (! rhsIsEmpty) skipTree()
516
- val (givenFlags, annots , privateWithin) = readModifiers(end)
516
+ val (givenFlags, annotFns , privateWithin) = readModifiers(end)
517
517
pickling.println(i " creating symbol $name at $start with flags $givenFlags" )
518
518
val flags = normalizeFlags(tag, givenFlags, name, isAbsType, rhsIsEmpty)
519
519
def adjustIfModule (completer : LazyType ) =
@@ -532,13 +532,12 @@ class TreeUnpickler(reader: TastyReader,
532
532
rootd.symbol
533
533
case _ =>
534
534
val completer = adjustIfModule(new Completer (ctx.owner, subReader(start, end)))
535
-
536
535
if (isClass)
537
536
ctx.newClassSymbol(ctx.owner, name.asTypeName, flags, completer, privateWithin, coord)
538
537
else
539
538
ctx.newSymbol(ctx.owner, name, flags, completer, privateWithin, coord)
540
539
}
541
- sym.annotations = annots
540
+ sym.annotations = annotFns.map(_(sym))
542
541
ctx.owner match {
543
542
case cls : ClassSymbol => cls.enter(sym)
544
543
case _ =>
@@ -561,9 +560,9 @@ class TreeUnpickler(reader: TastyReader,
561
560
/** Read modifier list into triplet of flags, annotations and a privateWithin
562
561
* boundary symbol.
563
562
*/
564
- def readModifiers (end : Addr )(implicit ctx : Context ): (FlagSet , List [Annotation ], Symbol ) = {
563
+ def readModifiers (end : Addr )(implicit ctx : Context ): (FlagSet , List [Symbol => Annotation ], Symbol ) = {
565
564
var flags : FlagSet = EmptyFlags
566
- var annots : List [Annotation ] = Nil
565
+ var annotFns : List [Symbol => Annotation ] = Nil
567
566
var privateWithin : Symbol = NoSymbol
568
567
while (currentAddr.index != end.index) {
569
568
def addFlag (flag : FlagSet ) = {
@@ -615,23 +614,25 @@ class TreeUnpickler(reader: TastyReader,
615
614
addFlag(Protected )
616
615
privateWithin = readType().typeSymbol
617
616
case ANNOTATION =>
618
- annots = readAnnot(ctx) :: annots
617
+ annotFns = readAnnot(ctx) :: annotFns
619
618
case tag =>
620
619
assert(false , s " illegal modifier tag $tag at $currentAddr, end = $end" )
621
620
}
622
621
}
623
- (flags, annots .reverse, privateWithin)
622
+ (flags, annotFns .reverse, privateWithin)
624
623
}
625
624
626
- private val readAnnot : Context => Annotation = {
625
+ private val readAnnot : Context => Symbol => Annotation = {
627
626
implicit ctx =>
628
627
readByte()
629
628
val end = readEnd()
630
629
val tp = readType()
631
- val lazyAnnotTree = readLater(end, rdr => ctx => rdr.readTerm()(ctx))
632
- Annotation .deferredSymAndTree(
633
- implicit ctx => tp.typeSymbol,
634
- implicit ctx => lazyAnnotTree.complete)
630
+ val lazyAnnotTree = readLaterWithOwner(end, rdr => ctx => rdr.readTerm()(ctx))
631
+
632
+ owner =>
633
+ Annotation .deferredSymAndTree(
634
+ implicit ctx => tp.typeSymbol,
635
+ implicit ctx => lazyAnnotTree(owner).complete)
635
636
}
636
637
637
638
/** Create symbols for the definitions in the statement sequence between
@@ -1154,10 +1155,13 @@ class TreeUnpickler(reader: TastyReader,
1154
1155
setPos(start, CaseDef (pat, guard, rhs))
1155
1156
}
1156
1157
1157
- def readLater [T <: AnyRef ](end : Addr , op : TreeReader => Context => T )(implicit ctx : Context ): Trees .Lazy [T ] = {
1158
+ def readLater [T <: AnyRef ](end : Addr , op : TreeReader => Context => T )(implicit ctx : Context ): Trees .Lazy [T ] =
1159
+ readLaterWithOwner(end, op)(ctx)(ctx.owner)
1160
+
1161
+ def readLaterWithOwner [T <: AnyRef ](end : Addr , op : TreeReader => Context => T )(implicit ctx : Context ): Symbol => Trees .Lazy [T ] = {
1158
1162
val localReader = fork
1159
1163
goto(end)
1160
- new LazyReader (localReader, ctx. owner, ctx.mode, op)
1164
+ owner => new LazyReader (localReader, owner, ctx.mode, op)
1161
1165
}
1162
1166
1163
1167
def readHole (end : Addr , isType : Boolean )(implicit ctx : Context ): Tree = {
0 commit comments