Copy the type history of mixed in members from before uncurry.#7752
Closed
sjrd wants to merge 1 commit intoscala:2.13.xfrom
Closed
Copy the type history of mixed in members from before uncurry.#7752sjrd wants to merge 1 commit intoscala:2.13.xfrom
sjrd wants to merge 1 commit intoscala:2.13.xfrom
Conversation
Previously, the type history was only copied from before erasure. This is necessary for Java interop, to correctly emit generic Java signatures for the relevant members. Scala.js wants more, because accurate JavaScript interop relies on the type history from before *uncurry* rather than before erasure. This commit therefore extends the type history of mixed in members all the way to uncurry. Fixes scala-js/scala-js#3538.
smarter
added a commit
to smarter/scala
that referenced
this pull request
Mar 10, 2019
…tures The compiler spends a lot of effort trying to generate correct generic signatures for mixin forwarders, but is still not correct as witnessed by scala/bug#8905 among others. However, it seems that if we just emit them with the BRIDGE flag set, both javac and ecj (the Eclipse Java Compiler) will be smart enough to go look for the signature in the overridden methods, which is exactly what we want. This means that we should be able to get rid of `cloneBeforeErasure` and related code, though that would conflict with scala#7752. Because history always repeats itself, it turns out that this used to be how mixin forwarders were emitted until fe94bc7 changed this 7 years ago. The commit only says that this "has deleterious effects since many tools ignore bridge methods" which is too vague for me to do anything about. Fixes scala/bug#8905 and probably countless others.
smarter
added a commit
to smarter/scala
that referenced
this pull request
Mar 10, 2019
The compiler spends a lot of effort trying to generate correct generic signatures for mixin forwarders, but is still not correct as witnessed by scala/bug#8905 among others. However, it seems that if we just emit them with the BRIDGE flag set, both javac and ecj (the Eclipse Java Compiler) will be smart enough to go look for the signature in the overridden methods, which is exactly what we want. This means that we should be able to get rid of `cloneBeforeErasure` and related code, though that would conflict with scala#7752. Because history always repeats itself, it turns out that this used to be how mixin forwarders were emitted until fe94bc7 changed this 7 years ago. The commit only says that this "has deleterious effects since many tools ignore bridge methods" which is too vague for me to do anything about. Fixes scala/bug#8905 and probably countless others.
smarter
added a commit
to smarter/scala
that referenced
this pull request
Mar 10, 2019
The compiler spends a lot of effort trying to generate correct generic signatures for mixin forwarders, but is still not correct as witnessed by scala/bug#8905 among others. However, it seems that if we just emit them with the BRIDGE flag set, both javac and ecj (the Eclipse Java Compiler) will be smart enough to go look for the signature in the overridden methods, which is exactly what we want. This means that we should be able to get rid of `cloneBeforeErasure` and related code, though that would conflict with scala#7752. Because history always repeats itself, it turns out that this used to be how mixin forwarders were emitted until fe94bc7 changed this 7 years ago. The commit only says that this "has deleterious effects since many tools ignore bridge methods" which is too vague for me to do anything about. Fixes scala/bug#8905 and probably countless others.
smarter
added a commit
to smarter/scala
that referenced
this pull request
Mar 10, 2019
The compiler spends a lot of effort trying to generate correct generic signatures for mixin forwarders, but is still not correct as witnessed by scala/bug#8905 among others. However, it seems that if we just emit them with the BRIDGE flag set, both javac and ecj (the Eclipse Java Compiler) will be smart enough to go look for the signature in the overridden methods, which is exactly what we want. This means that we should be able to get rid of `cloneBeforeErasure` and related code, though that would conflict with scala#7752. Because history always repeats itself, it turns out that this used to be how mixin forwarders were emitted until fe94bc7 changed this 7 years ago. The commit only says that this "has deleterious effects since many tools ignore bridge methods" which is too vague for me to do anything about. Fixes scala/bug#8905 and probably countless others.
smarter
added a commit
to smarter/scala
that referenced
this pull request
Mar 11, 2019
The compiler spends a lot of effort trying to generate correct generic signatures for mixin forwarders, but is still not correct as witnessed by scala/bug#8905 among others. However, it seems that if we just emit them with the BRIDGE flag set, both javac and ecj (the Eclipse Java Compiler) will be smart enough to go look for the signature in the overridden methods, which is exactly what we want. This means that we should be able to get rid of `cloneBeforeErasure` and related code, though that would conflict with scala#7752. Because history always repeats itself, it turns out that this used to be how mixin forwarders were emitted until fe94bc7 changed this 7 years ago. The commit only says that this "has deleterious effects since many tools ignore bridge methods" which is too vague for me to do anything about. Fixes scala/bug#8905 and probably countless others.
smarter
added a commit
to smarter/scala
that referenced
this pull request
Mar 12, 2019
The compiler spends a lot of effort trying to generate correct generic signatures for mixin forwarders, but is still not correct as witnessed by scala/bug#8905 among others. However, it seems that if we just emit them with the BRIDGE flag set, both javac and ecj (the Eclipse Java Compiler) will be smart enough to go look for the signature in the overridden methods, which is exactly what we want. This means that we should be able to get rid of `cloneBeforeErasure` and related code, though that would conflict with scala#7752. Because history always repeats itself, it turns out that this used to be how mixin forwarders were emitted until fe94bc7 changed this 7 years ago. The commit only says that this "has deleterious effects since many tools ignore bridge methods" which is too vague for me to do anything about. Fixes scala/bug#8905 and probably countless others.
Member
Author
|
Inspired by the discussion that happened at #7843, I managed to find a complete solution on Scala.js' side. So this PR is superseded by scala-js/scala-js#3584. Sorry for the time you spent reviewing this PR 😖 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the type history was only copied from before erasure. This is necessary for Java interop, to correctly emit generic Java signatures for the relevant members.
Scala.js wants more, because accurate JavaScript interop relies on the type history from before uncurry rather than before erasure. This commit therefore extends the type history of mixed in members all the way to uncurry.
Fixes scala-js/scala-js#3538.
I am not sure how to test this within this repository, as the change only affects Scala.js. I have tested it within Scala.js with:
sbt publishLocalfor this PRexamples/helloworld/HelloWorld.scalain the Scala.js repo:sbt ++2.13.0-pre-SNAPSHOT helloworld/runin the Scala.js repositoryThe third
printlncrashes with any existing version, and correctly prints 24 with this branch.If this PR is merged, I'll introduce a dedicated test in Scala.js, which will then be picked up by the community build.
In theory, I believe this commit could also be applied in a minor version of Scala, including 2.12.9. Hence it could also go to 2.13.1 and not in RC1. I'm happy to retarget the PR to any version that you deem appropriate.