langtools/test/tools/javac/generics/diamond/neg/Neg06.java
author sadayapalam
Thu, 26 Nov 2015 17:38:15 +0530
changeset 34474 14deea5f86f1
parent 29776 984a79b71cfe
permissions -rw-r--r--
8078660: Misleading recommendation from diamond finder. Summary: javac should recommend diamond usage if that could lead to a change in program behavior. Reviewed-by: mcimadamore

/*
 * @test /nodynamiccopyright/
 * @bug 6939620 7020044 8062373
 *
 * @summary  Check that diamond works where LHS is supertype of RHS (nilary constructor)
 * @author mcimadamore
 * @compile/fail/ref=Neg06.out Neg06.java -XDrawDiagnostics
 *
 */

class Neg06 {
   interface ISuperFoo<X> {}
   interface IFoo<X extends Number> extends ISuperFoo<X> {}

   static class CSuperFoo<X> {}
   static class CFoo<X extends Number> extends CSuperFoo<X> {}

   ISuperFoo<String> isf = new IFoo<>() {};
   CSuperFoo<String> csf1 = new CFoo<>();
   CSuperFoo<String> csf2 = new CFoo<>() {};
}