Created
January 28, 2020 01:03
-
-
Save rzwitserloot/2e71bb5b3b47a3f8432f96604c9035f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JavacBrokenError { | |
public static void main(String[] args) { | |
test(5.0); | |
} | |
void test(double d) {} | |
void test(Double d) {} | |
} | |
// Compilng the above with javac8 as well as javac11 produces error: | |
// both method test(Double) in Test and method test(double) in Test match | |
// 1 error | |
// This is however incorrect; this invocation is not ambiguous; the lowercase-d version | |
// wins by way of JLS 15.12.2.2-4. However, there is a different error in this code: | |
// the test methods aren't static and are being invoked from a static context. | |
// The proper behaviour is that javac had reported: | |
// error: non-static method test(double) cannot be referenced from a static context | |
// NB: If you make the test methods static, the code compiles properly. | |
// NB2: ecj produces the correct error. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment