diff options
author | Martin Odersky <odersky@gmail.com> | 2010-03-08 13:40:32 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2010-03-08 13:40:32 +0000 |
commit | 7144b4990f2c90002286ebf31a395c36024adcd2 (patch) | |
tree | a44fdf2e6af976bf54db36b596216b768e083a2c /src | |
parent | aff35a066a44b32ec343efe46c013424468cc6b4 (diff) | |
download | scala-7144b4990f2c90002286ebf31a395c36024adcd2.tar.gz scala-7144b4990f2c90002286ebf31a395c36024adcd2.tar.bz2 scala-7144b4990f2c90002286ebf31a395c36024adcd2.zip |
Closes #3115. Reviw by rytz
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index bd0dc448fb..aff6aa86e6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1107,30 +1107,42 @@ trait Namers { self: Analyzer => caseClassCopyMeth(cdef) foreach (namer.enterSyntheticSym(_)) } + def typeSig(tree: Tree): Type = { - val sym: Symbol = tree.symbol - // For definitions, transform Annotation trees to AnnotationInfos, assign - // them to the sym's annotations. Type annotations: see Typer.typedAnnotated - - // We have to parse definition annotatinos here (not in the typer when traversing - // the MemberDef tree): the typer looks at annotations of certain symbols; if - // they were added only in typer, depending on the compilation order, they would - // be visible or not - val annotated = if (sym.isModule) sym.moduleClass else sym - // typeSig might be called multiple times, e.g. on a ValDef: val, getter, setter - // parse the annotations only once. - if (!annotated.isInitialized) tree match { - case defn: MemberDef => - val ainfos = defn.mods.annotations filter { _ != null } map { ann => - // need to be lazy, #1782 - LazyAnnotationInfo(() => typer.typedAnnotation(ann)) - } - if (!ainfos.isEmpty) - annotated.setAnnotations(ainfos) - if (annotated.isTypeSkolem) - annotated.deSkolemize.setAnnotations(ainfos) - case _ => + + /** For definitions, transform Annotation trees to AnnotationInfos, assign + * them to the sym's annotations. Type annotations: see Typer.typedAnnotated + * We have to parse definition annotatinos here (not in the typer when traversing + * the MemberDef tree): the typer looks at annotations of certain symbols; if + * they were added only in typer, depending on the compilation order, they would + * be visible or not + */ + def annotate(annotated: Symbol) = { + // typeSig might be called multiple times, e.g. on a ValDef: val, getter, setter + // parse the annotations only once. + if (!annotated.isInitialized) tree match { + case defn: MemberDef => + val ainfos = defn.mods.annotations filter { _ != null } map { ann => + // need to be lazy, #1782 + LazyAnnotationInfo(() => typer.typedAnnotation(ann)) + } + if (!ainfos.isEmpty) + annotated.setAnnotations(ainfos) + if (annotated.isTypeSkolem) + annotated.deSkolemize.setAnnotations(ainfos) + case _ => + } } + + val sym: Symbol = tree.symbol + + // @Lukas: I am not sure this is the right way to do things. + // We used to only decorate the module class with annotations, which is + // clearly wrong. Now we decorate both the class and the object. + // But maybe some annotations are only meant for one of these but not for the other? + annotate(sym) + if (sym.isModule) annotate(sym.moduleClass) + val result = try { tree match { |