test/langtools/tools/javac/patterns/ImpossibleTypeTest.java
changeset 59285 7799a51dbe30
equal deleted inserted replaced
59284:88502b1cf76f 59285:7799a51dbe30
       
     1 /*
       
     2  * @test /nodynamiccopyright/
       
     3  * @bug 8231827
       
     4  * @summary Ensure that in type test patterns, the predicate is not trivially provable false.
       
     5  * @compile/fail/ref=ImpossibleTypeTest.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ImpossibleTypeTest.java
       
     6  */
       
     7 public class ImpossibleTypeTest {
       
     8 
       
     9     public static void main(String[] args) {
       
    10 
       
    11         int in = 42;
       
    12         Integer i = 42;
       
    13 
       
    14         if (i instanceof String s ) {
       
    15             System.out.println("Broken");
       
    16         }
       
    17         if (i instanceof Undefined u ) {
       
    18             System.out.println("Broken");
       
    19         }
       
    20     }
       
    21 }