Closed mdedetrich closed 10 months ago
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 Any
and Object
says backport candidate but the comments are not encouraging on that score. I think ascribing Any
is the workaround.
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
Incase this is not clear, in other cases I have to methods such as .box
(i.e. https://github.com/apache/incubator-pekko-persistence-r2dbc/pull/5/files#diff-7cbfbeca88cff2feb131206c0b3f481f599aa39915c546d60f13cb308c6ff867R289) because Any
doesn't work.
The PR on Any and Object says backport candidate but the comments are not encouraging on that score. I think ascribing Any is the workaround.
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
https://github.com/scala/scala/pull/7966 but there are several related tickets. It doesn't read like a novel.
For boxing, I just closed https://github.com/scala/bug/issues/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 https://github.com/scala/scala/pull/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