test/langtools/tools/javac/ConditionalWithVoid.java
changeset 59021 cfc7bb9a5a92
parent 53878 4584d0331318
equal deleted inserted replaced
59020:aebd72de84b0 59021:cfc7bb9a5a92
     2  * @test /nodynamiccopyright/
     2  * @test /nodynamiccopyright/
     3  * @bug 4974927 8064464
     3  * @bug 4974927 8064464
     4  * @summary The compiler was allowing void types in its parsing of conditional expressions.
     4  * @summary The compiler was allowing void types in its parsing of conditional expressions.
     5  * @author tball
     5  * @author tball
     6  *
     6  *
     7  * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ConditionalWithVoid.java
     7  * @compile/fail/ref=ConditionalWithVoid.out -XDrawDiagnostics ConditionalWithVoid.java
     8  */
     8  */
     9 public class ConditionalWithVoid {
     9 public class ConditionalWithVoid {
    10     public void test(Object o, String s) {
    10     public void test(Object o, String s) {
    11         // Should fail to compile since Object.wait() has a void return type. Poly case.
    11         // Should fail to compile since Object.wait() has a void return type. Poly case.
    12         System.out.println(o instanceof String ? o.hashCode() : o.wait());
    12         System.out.println(o instanceof String ? o.hashCode() : o.wait());