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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.

val sym = ref1.symbol
val isJavaOverride = overridesJava(sym)
val isJavaOverride = (ref1 ne ref) && overridesJava(sym) // (ref1 ne ref) avoids cycles
transformVarArgs(sym, isJavaOverride)
if (ref1 ne ref) && isJavaOverride then
if isJavaOverride then
// This method won't override the corresponding Java method at the end of this phase,
// only the forwarder added by `addVarArgsForwarder` will.
ref1.copySymDenotation(initFlags = ref1.flags &~ Override)
Expand Down