summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Symbols.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2014-09-29 15:14:24 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2014-09-30 12:34:49 +0200
commit6346c6b46d2991def37a9ae81ed5f4f8b90d5efd (patch)
treeb9fe904014c490daf7d22150a1603d7ba7189707 /src/reflect/scala/reflect/internal/Symbols.scala
parent5508e00a552d81ce483bd69084eea087fb178647 (diff)
downloadscala-6346c6b46d2991def37a9ae81ed5f4f8b90d5efd.tar.gz
scala-6346c6b46d2991def37a9ae81ed5f4f8b90d5efd.tar.bz2
scala-6346c6b46d2991def37a9ae81ed5f4f8b90d5efd.zip
SI-8087 keep annotations on mixed-in private[this] fields
Related to SI-2511 / eea7956, which fixed the same issue for non `private[this]` fields. If you have trait T { private[this] val f = 0 } class C extends T Mixin geneartes an accessor method `T.f` with owner `T`. When generating the field in `C`, the Mixin.mixinTraitMembers calls `fAccessor.accessed`. The implementation of `accessed` does a lookup for a member named `"f "` (note the space). The bug is that `private[this]` fields are not renamed to have space (`LOCAL_SUFFIX_STRING`) in their name, so the accessed was not found, and no annotations were copied from it.
Diffstat (limited to 'src/reflect/scala/reflect/internal/Symbols.scala')
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 44fce2c9ab..b0c23ef45d 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -2023,12 +2023,19 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
info.decls.filter(sym => !sym.isMethod && sym.isParamAccessor).toList
/** The symbol accessed by this accessor (getter or setter) function. */
- final def accessed: Symbol = accessed(owner.info)
-
- /** The symbol accessed by this accessor function, but with given owner type. */
- final def accessed(ownerTp: Type): Symbol = {
+ final def accessed: Symbol = {
assert(hasAccessorFlag, this)
- ownerTp decl localName
+ val localField = owner.info decl localName
+
+ if (localField == NoSymbol && this.hasFlag(MIXEDIN)) {
+ // SI-8087: private[this] fields don't have a `localName`. When searching the accessed field
+ // for a mixin accessor of such a field, we need to look for `name` instead.
+ // The phase travel ensures that the field is found (`owner` is the trait class symbol, the
+ // field gets removed from there in later phases).
+ enteringPhase(picklerPhase)(owner.info).decl(name).suchThat(!_.isAccessor)
+ } else {
+ localField
+ }
}
/** The module corresponding to this module class (note that this