Description
Compiler version
3.3.1
Minimized code
I am in the process of trying to minimize the code There is a minimisation at https://github.com/mdedetrich/scala3-inline-temporary-variable-collision. Critical parts of the original codebase are
- https://github.com/mdedetrich/incubator-pekko/blob/732615b4679a4cded147daf337937878e65336ba/actor/src/main/scala-3/org/apache/pekko/actor/dungeon/ChildrenInline.scala
- https://github.com/mdedetrich/incubator-pekko/blob/732615b4679a4cded147daf337937878e65336ba/actor/src/main/scala-3/org/apache/pekko/actor/dungeon/DispatchInline.scala
- https://github.com/mdedetrich/incubator-pekko/blob/732615b4679a4cded147daf337937878e65336ba/actor/src/main/scala/org/apache/pekko/actor/dungeon/Children.scala#L32
- https://github.com/mdedetrich/incubator-pekko/blob/732615b4679a4cded147daf337937878e65336ba/actor/src/main/scala/org/apache/pekko/actor/dungeon/Dispatch.scala#L47
- https://github.com/mdedetrich/incubator-pekko/blob/201992d9846f16da8262f4deef2ddf5726c94776/actor/src/main/scala/org/apache/pekko/actor/ActorCell.scala#L429-L430
- https://github.com/mdedetrich/incubator-pekko/blob/732615b4679a4cded147daf337937878e65336ba/actor/src/main/scala/org/apache/pekko/util/Unsafe.scala#L23
Output
You can look at the error here (https://github.com/apache/incubator-pekko/actions/runs/6403063454/job/17380823553), i.e.
[error] -- [E164] Declaration Error: /home/runner/work/incubator-pekko/incubator-pekko/actor/src/main/scala/org/apache/pekko/actor/ActorCell.scala:420:21
[error] 420 |private[pekko] class ActorCell(
[error] | ^
[error] |error overriding method inline$Unsafe$i1 in trait ChildrenInline of type (x$0: org.apache.pekko.util): object org.apache.pekko.util.Unsafe;
[error] | method inline$Unsafe$i1 in trait DispatchInline of type (x$0: org.apache.pekko.util): object org.apache.pekko.util.Unsafe class ActorCell inherits conflicting members:
[error] | method inline$Unsafe$i1 in trait ChildrenInline of type (x$0: org.apache.pekko.util): org.apache.pekko.util.Unsafe and
[error] | method inline$Unsafe$i1 in trait DispatchInline of type (x$0: org.apache.pekko.util): org.apache.pekko.util.Unsafe
[error] |(Note: this can be resolved by declaring an override in class ActorCell.)
[error] one error found
Expectation
That the code compiles. This is definitely due to inline
i.e. if you remove the inline
keyword then the codebase compiles fine (actually only need to remove one of the inline
s for the code to compile and it doesn't matter which one which gives more credence to the interim variable collision theory) . From the surface it looks like scala3 is generating interim variables/fields (due to inline) which happen to have the exact same name (i.e. inline$Unsafe$i1
) in multiple different traits that is causing a collision and its this resulting collision which causes a spurious "please override one of the fields" (which is not even possible because they are internally generated, i.e. not in the source code).