-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Internally generated interim variables/fields from inline keyword + package private create collision with trait mixin #18646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
So I have some good news, I managed to found out the offending culprit which is package private, i.e. if I remove It seems that the usage of package private is somehow altering the variables being generated which is causing the collision? Still trying to create a working minimization but hopefully since I figured out the cause it should be easier. |
I have managed to successfully minimize the issue, please see https://github.com/mdedetrich/scala3-inline-temporary-variable-collision |
Minimizationpackage pkg
trait A {
inline final def aInline: String = pkg.nest.Obj.field
}
class APlusB extends A with B
package nest {
private[pkg] object Obj {
var field: String = ""
}
} package pkg
trait B {
inline final def bInline: String = pkg.nest.Obj.field
} |
Same root cause as in #13215. The accessor is to a static member is generated in the class instead of a static scope. Furthermore, these accessors use a mangled name that does not contain the the prefix of the class ( We also need 2 files to make the local index of the generated accessor be the same ( |
Using the |
We cannot fix this collision without causing binary incompatibilities. We need To fix this issue we need to generate this accessor with the full owner prefix in it. It would be good to additionally make it static. |
Thanks, so for our case its not critical since we don't have to use
So does that mean fixing this core problem is out of the question for Scala 3.3.x series? |
Unfortunately, yes |
Compiler version
3.3.1
Minimized code
I am in the process of trying to minimize the codeThere is a minimisation at https://github.com/mdedetrich/scala3-inline-temporary-variable-collision. Critical parts of the original codebase areOutput
You can look at the error here (https://github.com/apache/incubator-pekko/actions/runs/6403063454/job/17380823553), i.e.
Expectation
That the code compiles. This is definitely due to
inline
i.e. if you remove theinline
keyword then the codebase compiles fine (actually only need to remove one of theinline
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).The text was updated successfully, but these errors were encountered: