Skip to content

Internally generated interim variables/fields from inline keyword + package private create collision with trait mixin #18646

Open
@mdedetrich

Description

@mdedetrich

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

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 inlines 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).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions