Open lrytz opened 6 months ago
The issue is here https://github.com/scala/scala/blob/v2.13.14/src/compiler/scala/tools/nsc/typechecker/Typers.scala#L6554
val superClazz = sym.superClass
superAcc.initialize.alias // Is the param accessor is an alias for a field further up the class hierarchy?
orElse (superAcc getterIn superAcc.owner) // otherwise, lookup the accessor for the super
filter (alias => superClazz.info.nonPrivateMember(alias.name) == alias) // the accessor must be public
superAcc
is the field B.id
superAcc.initialize.alias
is the getter A.id
superClazz.info.nonPrivateMember(alias.name)
gives the getter override B.id
, which is not A.id
, so the alias is discardedMaybe it's an overisght, we could change it to alias.owner.info.nonPrivateMember
; but I'm not entirely sure because the generated bytecode is INVOKESPECIAL A.id
(super call to A.id
), but we have C extends B extends A
, where B
overrides id
. Would need to dig to know if that's valid.
On the other hand, generating a super call instead of a virtual call might a bug on its own (https://github.com/scala/bug/issues/9330#issuecomment-2095908600).
On 2.13.14
Class
C
gets a field. If B's parameter has a different name aliasing is identified,C
gets no field.