You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstractclassA(valid:String)
// `B.id` has alias `A.id`, no field in `B`abstractclassB(overridevalid:String) extendsA(id)
// `idC` has no alias, unnecessary field in `C`classC(idC: String) extendsB(idC) { defm= idC }
Class C gets a field. If B's parameter has a different name aliasing is identified, C gets no field.
The text was updated successfully, but these errors were encountered:
valsuperClazz= 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 discarded
Maybe 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 (#9330 (comment)).
SethTisue
changed the title
Unnecessary field in sublcass, parameter alias not detected
Unnecessary field in subclass, parameter alias not detected
May 6, 2024
On 2.13.14
Class
C
gets a field. If B's parameter has a different name aliasing is identified,C
gets no field.The text was updated successfully, but these errors were encountered: