test/tools/javac/lambda/MethodReference25.java

changeset 1510
7873d37f5b37
parent 1415
01c9d4161882
child 2227
998b10c43157
     1.1 --- a/test/tools/javac/lambda/MethodReference25.java	Mon Jan 21 11:16:28 2013 -0800
     1.2 +++ b/test/tools/javac/lambda/MethodReference25.java	Mon Jan 21 20:13:56 2013 +0000
     1.3 @@ -25,21 +25,13 @@
     1.4   * @test
     1.5   * @bug 8003280
     1.6   * @summary Add lambda tests
     1.7 - *  check that non-boxing method references conversion has the precedence
     1.8 - * @run main MethodReference25
     1.9 + *  check that non-boxing method references is not preferred over boxing one
    1.10 + * @compile/fail/ref=MethodReference25.out -XDrawDiagnostics MethodReference25.java
    1.11   */
    1.12  
    1.13 -public class MethodReference25 {
    1.14 +class MethodReference25 {
    1.15  
    1.16 -    static void assertTrue(boolean cond) {
    1.17 -        assertionCount++;
    1.18 -        if (!cond)
    1.19 -            throw new AssertionError();
    1.20 -    }
    1.21 -
    1.22 -    static int assertionCount = 0;
    1.23 -
    1.24 -    static void m(Integer i) { assertTrue(true); }
    1.25 +    static void m(Integer i) { }
    1.26  
    1.27      interface SAM1 {
    1.28          void m(int x);
    1.29 @@ -49,11 +41,10 @@
    1.30          void m(Integer x);
    1.31      }
    1.32  
    1.33 -    static void call(int i, SAM1 s) { s.m(i); assertTrue(false); }
    1.34 +    static void call(int i, SAM1 s) { s.m(i);  }
    1.35      static void call(int i, SAM2 s) { s.m(i);  }
    1.36  
    1.37      public static void main(String[] args) {
    1.38 -        call(1, MethodReference25::m); //resolves to call(int, SAM2)
    1.39 -        assertTrue(assertionCount == 1);
    1.40 +        call(1, MethodReference25::m); //ambiguous
    1.41      }
    1.42  }

mercurial