Cumbersome disambiguation between same-name, conflicting def and val members inherited via multiple inheritance #23169
Labels
stat:needs triage
Every issue needs to have an "area" and "itype" label
Compiler version
3.3.5
,3.6.4
Minimized example
Output
Without
override val log: DiagnosticLoggingAdapter = redefLog
With
override val log: DiagnosticLoggingAdapter = redefLog
DiagnosticLoggingAdapter
Expectation
A slightly different case to the one mentioned in #23061 - I hoped for a cleaner way to resolve the multiple-inheritance naming conflict but didn't find one, unfortunately. Mainly opening this issue since it may be tangentially relevant to the aforementioned ticket, so apologies if this is not an actual issue but maybe an accepted limitation due to technical or conceptual reasons.
https://scastie.scala-lang.org/EQGARTbATHODep7eGr9YBA
Given the above class/trait structure (where we only control the implementation of the types prefixed with My...), the compiler will complain about conflicting members during the declaration of class
MyActor
, namely aboutdef log: LoggingAdapter
inActorLogging
(viaFSM
) andval log: DiagnosticLoggingAdapter
inDiagnosticActorLogging
(viaMyDiagnosticActorLogging
). The message also states "this can be resolved by declaring an override in class MyActor". However, when trying to declare it asoverride val log: DiagnosticLoggingAdapter = super[MyDiagnosticActorLogging].log
(which is the desired behaviour) it also does not compile becauselog
is aval
inMyDiagnosticActorLogging
/DiagnosticActorLogging
.Defining
redefLog
inMyDiagnosticActorLogging
and referring to thisdef
when overriding the memberlog
inMyActor
seems to do the job as a workaround. Is the restriction ofsuper
todef
members unavoidable? If so, is there a cleaner way to disambiguate between the inherited members?The text was updated successfully, but these errors were encountered: