Skip to content
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

class Stream.Cons and object Stream.cons are clashing with each other #11997

Closed
sjrd opened this issue May 13, 2020 · 4 comments
Closed

class Stream.Cons and object Stream.cons are clashing with each other #11997

sjrd opened this issue May 13, 2020 · 4 comments
Assignees
Milestone

Comments

@sjrd
Copy link
Member

sjrd commented May 13, 2020

In object Stream, there is a class Cons and an object cons.

This happens not to cause any issue on the JVM, even on Windows. That's because Stream$cons$ being a nested object, scalac does not generate static forwarders for it in Stream$cons. However Scala.js generates more static forwarders, to be able to correctly define static methods in nested static classes of JDK APIs.

This basically prevents from building Scala.js 1.x with 2.13.x on Windows.

I don't know what to do about this, given the binary compat guarantees. 😰

@joroKr21
Copy link
Member

Running on Mac, I do see linking errors when building OSS projects that upgraded to Scala.js 1.x
I haven't investigated but this could be the reason.

@dwijnand
Copy link
Member

with 2.13.x

Same with 2.12.x, right? Seeing as it's the same: https://github.com/scala/scala/blob/v2.12.11/src/library/scala/collection/immutable/Stream.scala#L1149-L1163

@sjrd
Copy link
Member Author

sjrd commented May 13, 2020

I've never observed the issue with 2.12.x. And our build uses 2.12.x by default, so I'm constantly building on 2.12.x.

I guess this is because in 2.12.x, object cons comes before class Cons. So when we compile object cons, we generate Stream$cons$.class and Stream$cons.class. And then when we arrive at class Cons, we overwrite Stream$cons.class with the one for Cons. We lose the static forwarders for Stream$cons$, but we never observe that, because it's not a JDK class.

If my analysis is correct, we could work around the issue by swapping the order of the definitions in the 2.13.x source!

@SethTisue SethTisue added this to the 2.13.3 milestone May 13, 2020
@dwijnand dwijnand closed this as completed Jun 4, 2020
@dwijnand
Copy link
Member

dwijnand commented Jun 4, 2020

Fixed in scala/scala#9035.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants