-
Notifications
You must be signed in to change notification settings - Fork 1.1k
SortedMap#empty Fails At Runtime With NoSuchMethodError #9175
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
The correct signature appears to be The empty method in question is defined in SortedMapFactoryDefaults: override def empty: CC[K, V @uncheckedVariance] = sortedMapFactory.empty(ordering) where CC is defined as: CC[x, y] <: Map[x, y] with SortedMapOps[x, y, CC, CC[x, y]] with UnsortedCC[x, y] Dotty and Scala 2 do not erase intersection types in the same way (scala 2 does some really weird stuff), I'm working on a PR to take that into account when calling into scala 2 code which should hopefully fix that. |
Thanks! For what it is worth I also tried to use parentheses like |
Indeed, but you should be able to call |
Yes but if I am working with polymorphic types I may not have an implicit |
Because our algorithm for erasing intersection types does not exactly match the one used by Scala 2, we could end up emitting calls to Scala 2 methods with the wrong bytecode signature, leading to NoSuchMethodError at runtime. We could try to exactly match what Scala 2 does, but it turns out that the Scala 2 logic heavily relies on implementation details which makes it extremely complex to reliably replicate. Therefore, this commit instead special-cases the erasure of Scala 2 intersections (just like we already special-case the erasure of Java intersections) and limits which Scala 2 intersection types we support to a subset that we can erase without too much complications (but even that still requires ~200 lines of code!). This means that we're now free to change the way we erase intersections in any way we want without introducing more compatibility problems (until 3.0.0 that is), I'll explore this in a follow-up PR. Fixes scala#4619. Fixes scala#9175.
Because our algorithm for erasing intersection types does not exactly match the one used by Scala 2, we could end up emitting calls to Scala 2 methods with the wrong bytecode signature, leading to NoSuchMethodError at runtime. We could try to exactly match what Scala 2 does, but it turns out that the Scala 2 logic heavily relies on implementation details which makes it extremely complex to reliably replicate. Therefore, this commit instead special-cases the erasure of Scala 2 intersections (just like we already special-case the erasure of Java intersections) and limits which Scala 2 intersection types we support to a subset that we can erase without too much complications (but even that still requires ~200 lines of code!). This means that we're now free to change the way we erase intersections in any way we want without introducing more compatibility problems (until 3.0.0 that is), I'll explore this in a follow-up PR. Fixes scala#4619. Fixes scala#9175.
Minimized code
Output
Expectation
I would expect that since this method is in the API of the latest Scala collections it would work correctly. At the minimum if it did not work I would expect to get a compilation failure with a helpful error message.
The text was updated successfully, but these errors were encountered: