-
Notifications
You must be signed in to change notification settings - Fork 396
Fix #3259: Generate overriding bridges in synthesized SAM wrappers. #3260
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
Conversation
Thanks! I was going to poke at this over the weekend in case you were busy, but this is better ;) |
4871252
to
ae1a0af
Compare
Refer to this link for build results (access rights to CI server needed): https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/4498/ |
Refer to this link for build results (access rights to CI server needed): https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/4501/ |
Dear Jenkins, retest this please |
ae1a0af
to
4748ffc
Compare
Rebased. |
Refer to this link for build results (access rights to CI server needed): https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/4503/ |
project/Build.scala
Outdated
(if (isJSTest) ((testDir / "require-sam") ** "*.scala").get else Nil) | ||
} | ||
|
||
val hasBugWithOverridenMethods = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*overridden
} | ||
|
||
for (sam <- samInfo.sam :: samBridges) { | ||
if (seenEncodedNames.add(encodeMethodSym(sam).name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the JVM backend does something similar (they call .disctinct
here). I guess this would happen if a SAM type extends several interfaces, each defining the same method, which would then collapse as the same bridge. The most reliable way for us to detect duplicates at this point is to test uniqueness of the encodedName
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... OK. Not very nice, but fair enough.
…ppers. Just like Scala/JVM needs to instruct the `LambdaMetaFactory` to generate bridges for methods overridden by the SAM, we need to directly generate appropriate bridges in our synthesized SAM wrappers. Instead of generating actual *bridges*, in the sense that they call the canonical implementation of the method, we generate bodies for all the bridges just like for the canonical method. This is fine because the bodies are just calling the closure stored in a field of the instance anyway.
4748ffc
to
b6be908
Compare
Updated. |
Refer to this link for build results (access rights to CI server needed): https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/4504/ |
Just like Scala/JVM needs to instruct the
LambdaMetaFactory
to generate bridges for methods overridden by the SAM, we need to directly generate appropriate bridges in our synthesized SAM wrappers.Instead of generating actual bridges, in the sense that they call the canonical implementation of the method, we generate bodies for all the bridges just like for the canonical method. This is fine because the bodies are just calling the closure stored in a field of the instance anyway.
Only the last commit is part of this PR. It will have to be rebased on top of #3258.
Tested locally with: