-
Notifications
You must be signed in to change notification settings - Fork 21
Impossible for Scala 2.12 to handle overloaded Java method that contains both varargs and parameters of same type #12765
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
Comments
So I managed to find a "solution" to this issue which to me appears more like a workaround then a solution. It turns out if I do log.debug("test", new Object: Any, new Object: Any) It manages to compile. The reason why I call this is a workaround is that it only seems to work in the case where you have two such overloads public void debug(String format, Object arg1, Object arg2);
public void debug(String format, Object... arguments); And specifically have 3 parameters |
The PR on |
Incase this is not clear, in other cases I have to methods such as
Are you talking about a scala compiler PR which theoretically solves the issue? If so can you link it, I am curious about what is actually causing the issue |
scala/scala#7966 but there are several related tickets. It doesn't read like a novel. |
For boxing, I just closed #8661 |
closing since it's 2.12-only and our policy is not to keep such tickets open. (regardless, the ticket has value as documentation and as a place to discuss workarounds; thanks.) |
I've forgotten if scala/scala#10378 was also this. |
Question for anyone that is still familiar with Scala 2.12 (specifically 2.12.17), I seem to have found a compiler bug that I cannot get around. Assuming that we have 2 java methods (these methods are actually from slf4j)
It seems to be impossible for Scala 2.12 to call either these methods. In other words no matter what you do you will always get an
where as in Java it would pick the
public void debug(String format, Object arg1, Object arg2)
version overpublic void debug(String format, Object... arguments);
if you only supplyarg1
andarg2
(and this is even stated as such in the documentation).I tried using various ways to force the type (i.e.
: Object
or.asInstanceOf[Object]
) but nothing seems to help. EvenWill fail to compile.
Pinging @som-snytt because I think you have the most experience here and actually worked on similar bugs
The text was updated successfully, but these errors were encountered: