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

Handle overloaded members when generating Java varargs bridges #13066

Merged
merged 2 commits into from
Jul 15, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 13, 2021

Fixes #13043

Comment on lines +85 to +86
* but that does not work, since `allOverriddenSymbols` gets confused because the
* signatures of a Java varargs method and a Scala varargs override are not the same.
Copy link
Member

Choose a reason for hiding this comment

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

The issue is that allOverriddenSymbols delegates to Denotation#matchingDenotation which is missing the logic present in Denotation#matchesLoosely to handle matching denotations across languages (java/scala2/scala3), I think this needs to be fixed but this is a good stop-gap meanwhile.

Copy link
Contributor

@TheElectronWill TheElectronWill left a comment

Choose a reason for hiding this comment

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

Today I learned something :)

@@ -85,7 +102,8 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
private def isVarargsMethod(sym: Symbol)(using Context) =
hasVarargsAnnotation(sym) ||
hasRepeatedParams(sym) &&
(sym.allOverriddenSymbols.exists(s => s.is(JavaDefined) || hasVarargsAnnotation(s)))
overridesJava(sym)
Copy link
Contributor

Choose a reason for hiding this comment

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

The previous version skipped the checks on overriden symbols when there were no repeated params (hence the parens). Is it intentional to change that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is missing a pair of parens

@odersky odersky merged commit b61eb2e into scala:master Jul 15, 2021
@odersky odersky deleted the fix-13043 branch July 15, 2021 12:01
@Kordyjan Kordyjan added this to the 3.1.0 milestone Aug 2, 2023
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 Java varargs parameter of overloaded method requires explicit Array syntax
4 participants