test/tools/javac/varargs/8055514/T8055514.java

Wed, 10 Sep 2014 10:51:36 +0100

author
mcimadamore
date
Wed, 10 Sep 2014 10:51:36 +0100
changeset 2559
0253e7cc98a4
permissions
-rw-r--r--

8055514: Wrong, confusing error when non-static varargs referenced in static context
Summary: Improved heuristics in MethodResolutionPhase.mergeResults()
Reviewed-by: vromero

mcimadamore@2559 1 /*
mcimadamore@2559 2 * @test /nodynamiccopyright/
mcimadamore@2559 3 * @bug 8055514
mcimadamore@2559 4 * @summary Wrong, confusing error when non-static varargs referenced in static context
mcimadamore@2559 5 * @compile/fail/ref=T8055514.out -Xlint:varargs -Werror -XDrawDiagnostics T8055514.java
mcimadamore@2559 6 */
mcimadamore@2559 7 class T8055514 {
mcimadamore@2559 8 void m(int... args) { }
mcimadamore@2559 9
mcimadamore@2559 10 void m2(int... args) { }
mcimadamore@2559 11 static void m2(String s) { }
mcimadamore@2559 12
mcimadamore@2559 13 void m3(int... args) { }
mcimadamore@2559 14 static void m3(String s) { }
mcimadamore@2559 15 static void m3(Runnable r) { }
mcimadamore@2559 16
mcimadamore@2559 17 void m4(int... args) { }
mcimadamore@2559 18 void m4(int i1, int i2, int i3) { }
mcimadamore@2559 19
mcimadamore@2559 20 static void test() {
mcimadamore@2559 21 m(1,2,3); //only one candidate (varargs) - varargs error wins
mcimadamore@2559 22 m2(1,2,3); //two candidates - only one applicable (varargs) - varargs error wins
mcimadamore@2559 23 m3(1,2,3); //three candidates - only one applicable (varargs) - varargs error wins
mcimadamore@2559 24 m4(1,2,3); //two candidates - both applicable - basic error wins
mcimadamore@2559 25 }
mcimadamore@2559 26 }

mercurial