Skip to content

Fix #9463: create varargs forwarder symbols in transform instead of transformDefDef #9474

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

Merged
merged 6 commits into from
Aug 7, 2020

Conversation

TheElectronWill
Copy link
Contributor

@TheElectronWill TheElectronWill commented Jul 31, 2020

This allows the forwarder symbols to be visible during separate compilation.
See smarter's comment in #9463.

@TheElectronWill TheElectronWill linked an issue Jul 31, 2020 that may be closed by this pull request
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is missing a pos test with the code from #9463 ?

Also move some disabled tests to run tests,
and rename vararg-extend-java to varargs-extend-java
@TheElectronWill
Copy link
Contributor Author

TheElectronWill commented Aug 1, 2020

Oopsie 👀 Here are the tests.
I've moved (or deleted, when the use case was already covered by another test) some disabled varargs tests, they all pass now.

@TheElectronWill
Copy link
Contributor Author

TheElectronWill commented Aug 1, 2020

I don't understand why tests/pos/annot-bootstrap (which I didn't touch) fails now, especially as it's not consistent: sometimes it fails in test, sometimes in test_bootstraped, sometimes both, and I can't reproduce it locally 😕
When looking for the overriden symbols in overridesJava in transform (here), it ends up calling complete on a NoLoader, which fails.

@smarter
Copy link
Member

smarter commented Aug 1, 2020

Hmm, not sure what's going on. One thing I see is that overridesJava(sym) is now going to be called more often since the ref1 ne ref check was moved below it, so I guess this is causing some sort of cycle, but only in very specific conditions? From the stacktrace I see that the call to complete the NoLoader symbol comes from isAbsent which is itself called from TreeChecker#transformSym, that call could be changed to isAbsent(canForce = false) to avoid that completion (this won't break anything since TreeChecker is just here to run extra sanity checks anyway).

@TheElectronWill
Copy link
Contributor Author

TheElectronWill commented Aug 1, 2020

🤔 Hmmm canForce = false didn't fix the problem, it created more errors. But I have another idea.

@TheElectronWill
Copy link
Contributor Author

It works! 🎉

@@ -62,9 +62,9 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
super.transform(ref) match
case ref1: SymDenotation if ref1.is(Method) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally the ref1 ne ref was here which I think is equivalent to what the code is doing now?

Copy link
Contributor Author

@TheElectronWill TheElectronWill Aug 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite, because now transformVarArgs is called for all methods. If I move ref1 ne ref back to the case guard, some situations are not covered and e.g. tests/neg/varargs-annot fails.

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't new to this PR, but I've noticed something weird with this phase: it extends InfoTransformer, which are supposed to only change the info of denotation and leave everything else alone, but in this phase we actually override transform to do more stuff on top of that, so it's a bit misleading. I think it'd be good to rewrite as a regular DenotTransformer, especially now that transform has gotten more complicated.

@smarter smarter assigned TheElectronWill and unassigned smarter Aug 6, 2020
@TheElectronWill TheElectronWill merged commit 0535f59 into scala:master Aug 7, 2020
@TheElectronWill TheElectronWill deleted the override-varargs branch August 10, 2020 14:08
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

Successfully merging this pull request may close these issues.

Overriding an @varargs method fails under separate compilation
2 participants