-
Notifications
You must be signed in to change notification settings - Fork 14
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
2.12 regression, backend crash: Cannot create ClassBType from non-class symbol #248
Comments
Here's a weird inconsistency that may explain this bug:
|
Why only check |
i have a patch ready soon, this is one of the issues. |
Ok, cool! |
Another weird thing is that two Later the Any intuition if creating the two symbols is fishy or not? |
Hmm, that does sound suboptimal, but I never dug deep into module symbol creation. |
In sequence
Your patch fixes it, and that test should be there, but there's also something fishy in the above. |
will cont. tomorrow, need to pay some overdue bills tonight 💵 |
Unfortunately I don't see an easy workaround for people affected by this (japgolly/nyaya#22 (comment)). If an already compiled module (or a dependency) contains code like this: package object p {
type Prop = String
}
package p {
object Prop {
class Whitelist
}
} any seperately-compiled code that accesses |
Use a value class instead of a type alias? Dare I ask what weird interactions that would yield? :-) |
Lift Whitelist out of the object? |
Is that supposed to be valid code to begin with? |
Sure, but that's a change to the project's API.. :(
?
I think by the spec, a companion class needs to be a class, not a type def. So they are not companions.
That actually helps as a workaround. By writing package object p {
type Prop = String
object Prop { class Whitelist }
} the classfile name is But it's not binary compatible, so users could not easily switch back to the other version. Also it's not recommended to put object / class definitions within a package object. |
Firstly, thanks @lrytz for narrowing that down and determining the cause so quickly. Secondly, allow me to provide some more info as to Why I Do These Things. Nyaya isn't the best example as there was a bunch of unplanned, organic growth that I've yet to clean up in Nyaya. A better example is
A possible workaround would be to move the Ideally we'd be able to define package-level type aliases anywhere in the package, just like classes and objects but I doubt that change would make it into 2.12. Anyhow, nothing useful in terms of technically resolving this, but hopefully some use in providing insight into cases like this. |
The bug is almost the same as https://issues.scala-lang.org/browse/SI-5031, with fixes in scala/scala#1016 and scala/scala#1532 I'm almost at the bottom of the issue in the classfile parser / unpickler, but don't see a way out yet.. |
Fixes scala/scala-dev/issues/248 This fix is the a workaround and does not fix the underlying issue. The change propsed here is minimal and safe. In principle, linkedClassOfClass should not return a type alias. This could be easily achieved by adding an additional filter to Symbol.companionClass, as proposed in a comment on the ticket. However, I observed some further complex interactions in the classfile parser / unpickler when having type aliases shadowing companions. This behavior might be cause by the proposed fix. In any case, a change to companionClass seems rather fundamental and needs to be carefully investigated.
Minimal "fix" (work around the underlying issue) in the backend: scala/scala#5479 |
This fixes scala/scala-dev#248, where a type alias reached the backend through this method. This is very similar to the fix for SI-5031, which changed it only in ModuleSymbol, but not in Symbol. The override in ModuleSymbol is actually unnecessary (it's identical), so it's removed in this commit. It was added for unclear reasons in 296b706.
Fixes scala/scala-dev/issues/248 This fix is the a workaround and does not fix the underlying issue. The change propsed here is minimal and safe. In principle, linkedClassOfClass should not return a type alias. This could be easily achieved by adding an additional filter to Symbol.companionClass, as proposed in a comment on the ticket. However, I observed some further complex interactions in the classfile parser / unpickler when having type aliases shadowing companions. This behavior might be cause by the proposed fix. In any case, a change to companionClass seems rather fundamental and needs to be carefully investigated.
WIP for frontend fixes / cleanups: scala/scala#5482 - see individual commit messages. |
The text was updated successfully, but these errors were encountered: