File: T8055514.java

package info (click to toggle)
libnb-javaparser-java 9%2B2018-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 65,320 kB
  • sloc: java: 440,096; xml: 6,359; sh: 865; makefile: 314
file content (26 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * @test /nodynamiccopyright/
 * @bug     8055514
 * @summary  Wrong, confusing error when non-static varargs referenced in static context
 * @compile/fail/ref=T8055514.out -Xlint:varargs -Werror -XDrawDiagnostics T8055514.java
 */
class T8055514 {
    void m(int... args) { }

    void m2(int... args) { }
    static void m2(String s) { }

    void m3(int... args) { }
    static void m3(String s) { }
    static void m3(Runnable r) { }

    void m4(int... args) { }
    void m4(int i1, int i2, int i3) { }

    static void test() {
        m(1,2,3); //only one candidate (varargs) - varargs error wins
        m2(1,2,3); //two candidates - only one applicable (varargs) - varargs error wins
        m3(1,2,3); //three candidates - only one applicable (varargs) - varargs error wins
        m4(1,2,3); //two candidates - both applicable - basic error wins
    }
}