RFR: 8238213: Method resolution should stop on static error
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Wed Jun 9 16:34:17 UTC 2021
On Fri, 4 Jun 2021 02:58:15 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> Please review this fix that is stopping method resolution if a static error is found. Currently javac rejecting code like:
>
> public class Test {
> public static void main(String[] args) {
> test(5.0);
> }
>
> void test(double d) {}
> void test(Double d) {}
> }
>
> but for the wrong reason. Basically it is that the invocation of method `test` is ambiguous as if both were applicable when it should fail at the end of the first overload resolution phase indicating that the non-static method test(double) can't be referred from a static context. This patch is fixing this issue.
>
> TIA
Late to the party - I confirm what has been discussed here - the change is good with respect to the JLS - and I welcome the analysis to assess the compatibility risk. Perhaps this might warrant a CSR, to stay on the safe side, since it restricts space of compilable programs?
-------------
PR: https://git.openjdk.java.net/jdk/pull/4351
More information about the compiler-dev
mailing list