@@ -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, readAnnot, readWithin, NoSymbol )
516
+ val (givenFlags, annotFns , privateWithin) = readModifiers(end, readAnnot, readWithin, NoSymbol )
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 _ =>
@@ -562,10 +561,10 @@ class TreeUnpickler(reader: TastyReader,
562
561
* boundary symbol.
563
562
*/
564
563
def readModifiers [WithinType , AnnotType ]
565
- (end : Addr , readAnnot : Context => AnnotType , readWithin : Context => WithinType , defaultWithin : WithinType )
566
- (implicit ctx : Context ): (FlagSet , List [AnnotType ], WithinType ) = {
564
+ (end : Addr , readAnnot : Context => Symbol => AnnotType , readWithin : Context => WithinType , defaultWithin : WithinType )
565
+ (implicit ctx : Context ): (FlagSet , List [Symbol => AnnotType ], WithinType ) = {
567
566
var flags : FlagSet = EmptyFlags
568
- var annots : List [AnnotType ] = Nil
567
+ var annotFns : List [Symbol => AnnotType ] = Nil
569
568
var privateWithin = defaultWithin
570
569
while (currentAddr.index != end.index) {
571
570
def addFlag (flag : FlagSet ) = {
@@ -617,29 +616,31 @@ class TreeUnpickler(reader: TastyReader,
617
616
addFlag(Protected )
618
617
privateWithin = readWithin(ctx)
619
618
case ANNOTATION =>
620
- annots = readAnnot(ctx) :: annots
619
+ annotFns = readAnnot(ctx) :: annotFns
621
620
case tag =>
622
621
assert(false , s " illegal modifier tag $tag at $currentAddr, end = $end" )
623
622
}
624
623
}
625
- (flags, annots .reverse, privateWithin)
624
+ (flags, annotFns .reverse, privateWithin)
626
625
}
627
626
628
627
private val readWithin : Context => Symbol =
629
628
implicit ctx => readType().typeSymbol
630
629
631
- private val readAnnot : Context => Annotation = {
630
+ private val readAnnot : Context => Symbol => Annotation = {
632
631
implicit ctx =>
633
632
readByte()
634
633
val end = readEnd()
635
634
val tp = readType()
636
- val lazyAnnotTree = readLater(end, rdr => ctx => rdr.readTerm()(ctx))
637
- if (tp.isRef(defn.BodyAnnot ))
638
- LazyBodyAnnotation (implicit ctx => lazyAnnotTree.complete)
639
- else
640
- Annotation .deferredSymAndTree(
641
- implicit ctx => tp.typeSymbol,
642
- implicit ctx => lazyAnnotTree.complete)
635
+ val lazyAnnotTree = readLaterWithOwner(end, rdr => ctx => rdr.readTerm()(ctx))
636
+
637
+ owner =>
638
+ if (tp.isRef(defn.BodyAnnot ))
639
+ LazyBodyAnnotation (implicit ctx => lazyAnnotTree(owner).complete)
640
+ else
641
+ Annotation .deferredSymAndTree(
642
+ implicit ctx => tp.typeSymbol,
643
+ implicit ctx => lazyAnnotTree(owner).complete)
643
644
}
644
645
645
646
/** Create symbols for the definitions in the statement sequence between
@@ -1165,10 +1166,13 @@ class TreeUnpickler(reader: TastyReader,
1165
1166
setPos(start, CaseDef (pat, guard, rhs))
1166
1167
}
1167
1168
1168
- def readLater [T <: AnyRef ](end : Addr , op : TreeReader => Context => T )(implicit ctx : Context ): Trees .Lazy [T ] = {
1169
+ def readLater [T <: AnyRef ](end : Addr , op : TreeReader => Context => T )(implicit ctx : Context ): Trees .Lazy [T ] =
1170
+ readLaterWithOwner(end, op)(ctx)(ctx.owner)
1171
+
1172
+ def readLaterWithOwner [T <: AnyRef ](end : Addr , op : TreeReader => Context => T )(implicit ctx : Context ): Symbol => Trees .Lazy [T ] = {
1169
1173
val localReader = fork
1170
1174
goto(end)
1171
- new LazyReader (localReader, ctx. owner, ctx.mode, op)
1175
+ owner => new LazyReader (localReader, owner, ctx.mode, op)
1172
1176
}
1173
1177
1174
1178
def readHole (end : Addr , isType : Boolean )(implicit ctx : Context ): Tree = {
@@ -1265,7 +1269,7 @@ class TreeUnpickler(reader: TastyReader,
1265
1269
def readMods (): untpd.Modifiers = {
1266
1270
val (flags, annots, privateWithin) =
1267
1271
readModifiers(end, readUntypedAnnot, readUntypedWithin, EmptyTypeName )
1268
- untpd.Modifiers (flags, privateWithin, annots)
1272
+ untpd.Modifiers (flags, privateWithin, annots.map(_( NoSymbol )) )
1269
1273
}
1270
1274
1271
1275
def readRhs (): untpd.Tree =
@@ -1384,8 +1388,8 @@ class TreeUnpickler(reader: TastyReader,
1384
1388
private val readUntypedWithin : Context => TypeName =
1385
1389
implicit ctx => readName().toTypeName
1386
1390
1387
- private val readUntypedAnnot : Context => untpd.Tree =
1388
- implicit ctx => readUntyped()
1391
+ private val readUntypedAnnot : Context => Symbol => untpd.Tree =
1392
+ implicit ctx => _ => readUntyped()
1389
1393
1390
1394
// ------ Setting positions ------------------------------------------------
1391
1395
0 commit comments