diff options
author | Martin Odersky <odersky@gmail.com> | 2015-02-19 14:36:37 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:14:08 +0100 |
commit | 30f08b095192435b080afe4b1734b8ce48039f84 (patch) | |
tree | aa0fa6e87098c1388663d560fc93ca6ae97b6f39 /src/dotty/tools/dotc/core/pickling/TreePickler.scala | |
parent | ed986b5256a535a50fe3c6095fe7a93376edb0fc (diff) | |
download | dotty-30f08b095192435b080afe4b1734b8ce48039f84.tar.gz dotty-30f08b095192435b080afe4b1734b8ce48039f84.tar.bz2 dotty-30f08b095192435b080afe4b1734b8ce48039f84.zip |
Changes to pickling annotations
Problem is that we need to be strict in the annotation symbol
(need to force at the latest when checking whether a definition
has some specific class of annotation), but should be lazy
in the rest of the tree.
This is achieved by pickling annotations with a symbol and a full
tree.
At the same time, Annotated trees can be ignored because they
are eliminated by Typer. We only need AnnotatedTypes.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/TreePickler.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/TreePickler.scala | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TreePickler.scala b/src/dotty/tools/dotc/core/pickling/TreePickler.scala index 801d3edb6..b842a5985 100644 --- a/src/dotty/tools/dotc/core/pickling/TreePickler.scala +++ b/src/dotty/tools/dotc/core/pickling/TreePickler.scala @@ -6,7 +6,7 @@ package pickling import ast.Trees._ import PickleFormat._ import core._ -import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._ +import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._, Annotations._ import collection.mutable import TastyBuffer._ @@ -187,7 +187,7 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) { withLength { pickleType(tpe.lo, richTypes); pickleType(tpe.hi, richTypes) } case tpe: AnnotatedType => writeByte(ANNOTATED) - withLength { pickleTree(tpe.annot.tree); pickleType(tpe.tpe, richTypes) } + withLength { pickleAnnotation(tpe.annot); pickleType(tpe.tpe, richTypes) } case tpe: AndOrType => writeByte(if (tpe.isAnd) ANDtype else ORtype) withLength { pickleType(tpe.tp1, richTypes); pickleType(tpe.tp2, richTypes) } @@ -385,9 +385,6 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) { case PackageDef(pid, stats) => writeByte(PACKAGE) withLength { pickleType(pid.tpe); stats.foreach(pickleTree) } - case Annotated(annot, arg) => - writeByte(ANNOTATED) - withLength { pickleTree(annot); pickleTree(arg) } case EmptyTree => writeByte(EMPTYTREE) }} @@ -450,7 +447,12 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) { if (flags is Covariant) writeByte(COVARIANT) if (flags is Contravariant) writeByte(CONTRAVARIANT) } - sym.annotations.foreach(ann => pickleTree(ann.tree)) + sym.annotations.foreach(pickleAnnotation) + } + + def pickleAnnotation(ann: Annotation) = { + writeByte(ANNOTATION) + withLength { pickleType(ann.symbol.typeRef); pickleTree(ann.tree) } } pickleTree(tree) |