test/langtools/tools/javac/patterns/BindingsExistTest.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 59285 7799a51dbe30
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com

/*
 * @test /nodynamiccopyright/
 * @bug 8231827
 * @summary Clashing bindings are reported correctly
 * @compile/fail/ref=BindingsExistTest.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BindingsExistTest.java
 */
public class BindingsExistTest {
    public void t(Object o1, Object o2) {
        if (o1 instanceof String k && o2 instanceof Integer k) {}

        if (o1 instanceof String k || o2 instanceof Integer k) {}

        if (!(o1 instanceof String k)) {
            return ;
        }
        if (o1 instanceof Integer k) {}

        String s2 = "";
        if (o1 instanceof String s2) {}

        if (o1 instanceof String s3) {
            String s3 = "";
        }

        if (!(o1 instanceof String s4)) {
            return ;
        }
        String s4 = "";
    }
}