aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-20 15:53:25 +0100
committerMartin Odersky <odersky@gmail.com>2017-03-20 16:08:53 +0100
commit99a77247d1cb4de92b52aa538ce4a2b200383256 (patch)
treef2ff8a23da00d8fa90b611aa294e6bab56401c45 /compiler
parent587a1f45f5cbd8f746b01777ac9b100743161633 (diff)
downloaddotty-99a77247d1cb4de92b52aa538ce4a2b200383256.tar.gz
dotty-99a77247d1cb4de92b52aa538ce4a2b200383256.tar.bz2
dotty-99a77247d1cb4de92b52aa538ce4a2b200383256.zip
Use shadowing to reference inherited accessors.
Normal references won't work since the referenced accessor has the same name as a private name in the class defining the forwarder. This showed up as pickling failures under separate compilation.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala b/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala
index 859ac8b06..a6c4b5d8d 100644
--- a/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala
@@ -4,6 +4,8 @@ package transform
import core._
import ast.Trees._
import Contexts._, Types._, Symbols._, Flags._, TypeUtils._, DenotTransformers._, StdNames._
+import Decorators._
+import config.Printers.typr
/** For all parameter accessors
*
@@ -48,7 +50,7 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
val candidate = sym.owner.asClass.superClass
.info.decl(sym.name).suchThat(_ is (ParamAccessor, butNot = Mutable)).symbol
if (candidate.isAccessibleFrom(currentClass.thisType, superAccess = true)) candidate
- else if (candidate is Method) inheritedAccessor(candidate)
+ else if (candidate.exists) inheritedAccessor(candidate)
else NoSymbol
}
def forwardParamAccessor(stat: Tree): Tree = {
@@ -66,8 +68,12 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
sym.copySymDenotation(initFlags = sym.flags | Method | Stable, info = sym.info.ensureMethodic)
.installAfter(thisTransformer)
val superAcc =
- Super(This(currentClass), tpnme.EMPTY, inConstrCall = false).select(alias)
- DefDef(sym, superAcc.ensureConforms(sym.info.widen))
+ Super(This(currentClass), tpnme.EMPTY, inConstrCall = false)
+ .select(alias)
+ val stpe @ TermRef(_, _) = superAcc.tpe
+ val superAccShadowed = superAcc.withType(stpe.shadowed)
+ typr.println(i"adding param forwarder $superAccShadowed")
+ DefDef(sym, superAccShadowed.ensureConforms(sym.info.widen))
}
return forwarder(ctx.withPhase(thisTransformer.next))
}