-
Notifications
You must be signed in to change notification settings - Fork 39
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
variances are not preserved for 5+ type parameters #511
Comments
If it's really random, it makes me think that there is a compiler bug. We've seen similar things before. Probably you should open an upstream issue. |
Another possibility is some subtle bug in our binary tag encoding, but I very much doubt it because there is no concurrent access involved and the code is more or less straightforward. I would try to add some debug logging and see what happens. |
@memo33 What about Scala 2? Does this reproduce on Scala 2? EDIT: It does NOT reproduce on Scala 2 |
This IS a bug in Scala 3 Reflection API - specifically Symbol.typeMembers uses a Set underneath and the ordering is non-deterministic for large sets. This is not an API misuse issue, because there's no other way, that I found, using public API to get at type params of an applied concrete type. I'll check tomorrow if maybe I can retrieve a type lambda of a type constructor through its ParamRef retrieved through a .typeMembers call - no other ideas how to restore ordering using public API yet. EDIT: No, .typeMembers returns TypeRefs, not ParamRefs. Opened upstream issue: scala/scala3#22472 |
Ouch. So, I was kinda right. I think it's an API design issue, it returns an ordered collection interface which is backed by an unordered collection. |
Awesome. Thanks a lot for the quick fix. It works for me. |
From zio/zio-http#3264:
For classes with 5 or more type parameters, the variances seem to be randomly shuffled among the type parameters.
Output is random:
(Tested with izumi-reflect 2.3.10, Scala 3.6.3.)
The text was updated successfully, but these errors were encountered: