1/* 2 * @test /nodynamiccopyright/ 3 * @bug 8062373 4 * @summary Test that javac does not recommend a diamond site that would result in error. 5 * @compile/ref=Neg16.out -Xlint:-options Neg16.java -XDrawDiagnostics -XDfind=diamond 6 */ 7 8class Neg16 { 9 10 interface Predicate<T> { 11 default boolean test(T t) { 12 System.out.println("Default method"); 13 return false; 14 } 15 } 16 17 static void someMethod(Predicate<? extends Number> p) { 18 if (!p.test(null)) 19 throw new Error("Blew it"); 20 } 21 22 public static void main(String[] args) { 23 someMethod(new Predicate<Integer>() { // cannot convert to diamond 24 public boolean test(Integer n) { 25 System.out.println("Override"); 26 return true; 27 } 28 }); 29 someMethod(new Predicate<Number>() { // can convert to diamond. 30 public boolean test(Number n) { 31 System.out.println("Override"); 32 return true; 33 } 34 }); 35 } 36} 37