summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/symtab
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-08-17 16:23:02 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-08-17 16:42:58 +0200
commitd877d0cb32a1198d7b40fe0c4583b6f4f488dc52 (patch)
tree5a3eee765639e8a00414f995c41b57868b242a25 /src/compiler/scala/tools/nsc/symtab
parent5084b74048f7f21f38fdf45ebfa8e634b863bb01 (diff)
downloadscala-d877d0cb32a1198d7b40fe0c4583b6f4f488dc52.tar.gz
scala-d877d0cb32a1198d7b40fe0c4583b6f4f488dc52.tar.bz2
scala-d877d0cb32a1198d7b40fe0c4583b6f4f488dc52.zip
SI-7501 Pickler: owner adjustment for param syms in annotation args
Pickling of trees within annotation arguments led to an unfortunate situation: the MethodType of a symbol contained a value parameter symbol that was pickled as though it were owned by the enclosing class (the root symbol of the pickle.) Under separate compilation, this would appear as a member of that class. Anyone using `@deprecatedName('oldName)` was exposed to this problem, as the argument expands to `Symbol.apply("oldName")`. This commit extends some similar treatment of local type parameters to also consider value parameters.
Diffstat (limited to 'src/compiler/scala/tools/nsc/symtab')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 9bad29097c..9ac1ce1b9c 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -88,12 +88,17 @@ abstract class Pickler extends SubComponent {
/** Returns usually symbol's owner, but picks classfile root instead
* for existentially bound variables that have a non-local owner.
* Question: Should this be done for refinement class symbols as well?
+ *
+ * Note: tree pickling also finds its way here; e.g. in SI-7501 the pickling
+ * of trees in annotation arguments considers the parameter symbol of a method
+ * called in such a tree as "local". The condition `sym.isValueParameter` was
+ * added to fix that bug, but there may be a better way.
*/
private def localizedOwner(sym: Symbol) =
if (isLocal(sym) && !isRootSym(sym) && !isLocal(sym.owner))
// don't use a class as the localized owner for type parameters that are not owned by a class: those are not instantiated by asSeenFrom
// however, they would suddenly be considered by asSeenFrom if their localized owner became a class (causing the crashes of #4079, #2741)
- (if(sym.isTypeParameter && !sym.owner.isClass) nonClassRoot
+ (if ((sym.isTypeParameter || sym.isValueParameter) && !sym.owner.isClass) nonClassRoot
else root)
else sym.owner