changeset 56931:c487001dbbbc patterns

Merging patterns-stage-1 branch into the patterns branch.
author jlahoda
date Mon, 15 Jul 2019 12:52:33 +0200
parents f6a80788dc08 b212bd325a04
children 08eadf898934 f3e3e9e47ade
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java test/langtools/tools/javac/api/TestGetElementReferenceData.java test/langtools/tools/javac/diags/examples/MatchBindingExists.java test/langtools/tools/javac/patterns/DuplicateBindingTest.out test/langtools/tools/javac/patterns/MatchBindingScopeTest.out test/langtools/tools/javac/patterns/PatternMatchPosTest.java test/langtools/tools/javac/patterns/PatternMatchPosTest.out
diffstat 19 files changed, 307 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jul 15 12:52:33 2019 +0200
@@ -3796,7 +3796,8 @@
             attribTree(tree.pattern, env, castInfo);
             clazztype = tree.pattern.type;
             if (!clazztype.hasTag(TYPEVAR)) {
-                clazztype = chk.checkClassOrArrayType(tree.pattern.pos(), clazztype);
+                JCBindingPattern pattern = (JCBindingPattern) tree.pattern;
+                clazztype = chk.checkClassOrArrayType(pattern.vartype.pos(), clazztype);
             }
         } else {
             clazztype = attribType(tree.pattern, env);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Mon Jul 15 12:52:33 2019 +0200
@@ -3450,6 +3450,11 @@
                     duplicateErasureError(pos, sym, byName);
                     sym.flags_field |= CLASH;
                     return true;
+                } else if ((sym.flags() & MATCH_BINDING) != 0 &&
+                           (byName.flags() & MATCH_BINDING) != 0 &&
+                           (byName.flags() & MATCH_BINDING_TO_OUTER) == 0) {
+                    //this error will be reported separatelly in MatchBindingsComputer
+                    return false;
                 } else {
                     duplicateError(pos, byName);
                     return false;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java	Mon Jul 15 12:52:33 2019 +0200
@@ -59,9 +59,9 @@
         ATTR(4),
         FLOW(5),
         TRANSTYPES(6),
-        UNLAMBDA(7),
-        TRANSSWITCHES(8),
-        TRANSPATTERNS(9),
+        TRANSSWITCHES(7),
+        TRANSPATTERNS(8),
+        UNLAMBDA(9),
         LOWER(10),
         GENERATE(11);
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Mon Jul 15 12:52:33 2019 +0200
@@ -1817,7 +1817,7 @@
          */
         protected boolean trackable(VarSymbol sym) {
             return
-                sym.pos >= startPos && ((sym.flags() & MATCH_BINDING) == 0) &&
+                sym.pos >= startPos &&
                 ((sym.owner.kind == MTH || sym.owner.kind == VAR ||
                 isFinalUninitializedField(sym)));
         }
@@ -2790,11 +2790,6 @@
             // Do nothing for modules
         }
 
-        // TODO: 2017-02-02 JUST TO ALLOW THINGS TO CONTINUE
-        public void visitTypeTestPattern(JCBindingPattern tree) {
-            // Do nothing
-        }
-
     /**************************************************************************
      * main method
      *************************************************************************/
@@ -2994,11 +2989,6 @@
             // Do nothing for modules
         }
 
-        // TODO: 2017-02-02 JUST TO ALLOW THINGS TO CONTINUE
-        public void visitTypeTestPattern(JCBindingPattern tree) {
-            // Do nothing
-        }
-
     /**************************************************************************
      * main method
      *************************************************************************/
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java	Mon Jul 15 12:52:33 2019 +0200
@@ -70,6 +70,7 @@
 
 import com.sun.tools.javac.code.Symbol.MethodSymbol;
 import com.sun.tools.javac.comp.MatchBindingsComputer.BindingSymbol;
+import com.sun.tools.javac.jvm.Target;
 import com.sun.tools.javac.tree.JCTree.JCBlock;
 import com.sun.tools.javac.tree.JCTree.JCDoWhileLoop;
 import com.sun.tools.javac.tree.JCTree.JCStatement;
@@ -99,6 +100,7 @@
     private Log log;
     private ConstFold constFold;
     private Names names;
+    private Target target;
 
     BindingContext bindingContext = new BindingContext() {
         @Override
@@ -143,6 +145,7 @@
         log = Log.instance(context);
         constFold = ConstFold.instance(context);
         names = Names.instance(context);
+        target = Target.instance(context);
         debugTransPatterns = Options.instance(context).isSet("debug.patterns");
     }
 
@@ -154,8 +157,8 @@
             Type tempType = tree.expr.type.hasTag(BOT) ?
                     syms.objectType
                     : tree.expr.type;
-            VarSymbol temp = new VarSymbol(pattSym.flags(),
-                    pattSym.name.append(names.fromString("$temp")),
+            VarSymbol temp = new VarSymbol(pattSym.flags() | Flags.SYNTHETIC,
+                    names.fromString(pattSym.name.toString() + target.syntheticNameChar() + "temp"),
                     tempType,
                     patt.symbol.owner);
             JCExpression translatedExpr = translate(tree.expr);
@@ -482,7 +485,7 @@
             this.parent = bindingContext;
             this.hoistedVarMap = matchBindings.stream()
                     .filter(v -> parent.getBindingFor(v) == null)
-                    .collect(Collectors.toMap(v -> v, v -> new VarSymbol(v.flags(), v.name.append(names.fromString("$binding")), v.type, v.owner)));
+                    .collect(Collectors.toMap(v -> v, v -> new VarSymbol(v.flags(), v.name, v.type, v.owner)));
         }
 
         @Override
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Mon Jul 15 12:52:33 2019 +0200
@@ -1558,6 +1558,18 @@
             env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
             compileStates.put(env, CompileState.TRANSTYPES);
 
+            if (shouldStop(CompileState.TRANSSWITCHES))
+                return;
+
+            env.tree = TransSwitches.instance(context).translateTopLevelClass(env, env.tree, localMake);
+            compileStates.put(env, CompileState.TRANSSWITCHES);
+
+            if (shouldStop(CompileState.TRANSPATTERNS))
+                return;
+
+            env.tree = TransPatterns.instance(context).translateTopLevelClass(env, env.tree, localMake);
+            compileStates.put(env, CompileState.TRANSPATTERNS);
+
             if (Feature.LAMBDA.allowedInSource(source) && scanner.hasLambdas) {
                 if (shouldStop(CompileState.UNLAMBDA))
                     return;
@@ -1566,18 +1578,6 @@
                 compileStates.put(env, CompileState.UNLAMBDA);
             }
 
-            if (shouldStop(CompileState.TRANSSWITCHES))
-                return;
-
-            env.tree = TransSwitches.instance(context).translateTopLevelClass(env, env.tree, localMake);
-            compileStates.put(env, CompileState.TRANSSWITCHES);
-
-            if (shouldStop(CompileState.TRANSSWITCHES))
-                return;
-
-            env.tree = TransPatterns.instance(context).translateTopLevelClass(env, env.tree, localMake);
-            compileStates.put(env, CompileState.TRANSPATTERNS);
-
             if (shouldStop(CompileState.LOWER))
                 return;
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Jul 15 12:52:33 2019 +0200
@@ -939,14 +939,13 @@
             if (token.kind == INSTANCEOF) {
                 int pos = token.pos;
                 nextToken();
-                int patternPos = token.pos;
                 JCTree pattern = parseType(true);
                 if (token.kind == IDENTIFIER) {
                     if (pattern.hasTag(IDENT) && isRestrictedTypeName(((JCIdent) pattern).name, pattern.pos, true)) {
                         reportSyntaxError(pos, Errors.RestrictedTypeNotAllowed(((JCIdent) pattern).name, ((JCIdent) pattern).name == names.var ? Source.JDK10 : Source.JDK13));
                         pattern = null;
                     }
-                    pattern = toP(F.at(patternPos).BindingPattern(ident(), pattern));
+                    pattern = toP(F.at(token.pos).BindingPattern(ident(), pattern));
                 }
                 odStack[top] = F.at(pos).TypeTest(odStack[top], pattern);
             } else {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Mon Jul 15 12:52:33 2019 +0200
@@ -490,6 +490,15 @@
                     return getStartPos(node.vartype);
                 }
             }
+            case BINDINGPATTERN: {
+                JCBindingPattern node = (JCBindingPattern)tree;
+                if (node.vartype == null) {
+                    //var binding pattern
+                    return node.pos;
+                } else {
+                    return getStartPos(node.vartype);
+                }
+            }
             case ERRONEOUS: {
                 JCErroneous node = (JCErroneous)tree;
                 if (node.errs != null && node.errs.nonEmpty())
--- a/test/langtools/tools/javac/api/TestGetElementReferenceData.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/test/langtools/tools/javac/api/TestGetElementReferenceData.java	Mon Jul 15 12:52:33 2019 +0200
@@ -35,8 +35,8 @@
         java.util.List< /*getElement:INTERFACE:java.util.List*/ String> l;
         utility/*getElement:METHOD:test.TestGetElementReferenceData.Base.utility()*/();
         target(TestGetElementReferenceData :: test/*getElement:METHOD:test.TestGetElementReferenceData.test()*/);
-        Object o = null;
-        if (o __matches String/*getElement:CLASS:java.lang.String*/ str/*getElement:LOCAL_VARIABLE:str*/) ;
+        Object/*getElement:CLASS:java.lang.Object*/ o = null;
+        if (o/*getElement:LOCAL_VARIABLE:o*/ instanceof String/*getElement:CLASS:java.lang.String*/ str/*getElement:LOCAL_VARIABLE:str*/) ;
     }
     private static void target(Runnable r) { r.run(); }
     public static class Base {
--- a/test/langtools/tools/javac/diags/examples/MatchBindingExists.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/test/langtools/tools/javac/diags/examples/MatchBindingExists.java	Mon Jul 15 12:52:33 2019 +0200
@@ -22,17 +22,9 @@
  */
 
 // key: compiler.err.match.binding.exists
-// key: compiler.err.match.binding.exists.with.different.type
-//TODO: the following error is extraneous?
-// key: compiler.err.already.defined
 
-class X {
-    public static void main(String [] args) {
-        String s = "Hello";
-        Integer i = 42;
-        Object o1 = s, o2 = i;
-
-        if (o1 __matches String k && o2 __matches Integer k) {}
-        if (o1 __matches String k || o2 __matches Integer k) {}
+class MatchBindingExists {
+    public void test(Object o1, Object o2) {
+        if (o1 instanceof String k && o2 instanceof Integer k) {}
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/MatchBindingExistsWithDifferentType.java	Mon Jul 15 12:52:33 2019 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.match.binding.exists.with.different.type
+
+class MatchBindingExistsWithDifferentType {
+    public static void main(Object o1, Object o2) {
+        if (o1 instanceof String k || o2 instanceof Integer k) {}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/patterns/BindingsExistTest.java	Mon Jul 15 12:52:33 2019 +0200
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Clashing bindings are reported correctly
+ * @compile/fail/ref=BindingsExistTest.out -XDrawDiagnostics 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 = "";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/patterns/BindingsExistTest.out	Mon Jul 15 12:52:33 2019 +0200
@@ -0,0 +1,7 @@
+BindingsExistTest.java:8:36: compiler.err.match.binding.exists
+BindingsExistTest.java:10:36: compiler.err.match.binding.exists.with.different.type
+BindingsExistTest.java:15:35: compiler.err.already.defined: kindname.variable, k, kindname.method, t(java.lang.Object,java.lang.Object)
+BindingsExistTest.java:18:34: compiler.err.already.defined: kindname.variable, s2, kindname.method, t(java.lang.Object,java.lang.Object)
+BindingsExistTest.java:21:20: compiler.err.already.defined: kindname.variable, s3, kindname.method, t(java.lang.Object,java.lang.Object)
+BindingsExistTest.java:27:16: compiler.err.already.defined: kindname.variable, s4, kindname.method, t(java.lang.Object,java.lang.Object)
+6 errors
--- a/test/langtools/tools/javac/patterns/BindingsTest1.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/test/langtools/tools/javac/patterns/BindingsTest1.java	Mon Jul 15 12:52:33 2019 +0200
@@ -175,6 +175,21 @@
             s.length();
         }
 
+        if (o1 instanceof String s) {
+            Runnable r1 = new Runnable() {
+                @Override
+                public void run() {
+                    s.length();
+                }
+            };
+            r1.run();
+            Runnable r2 = () -> {
+                s.length();
+            };
+            r2.run();
+            String s2 = s;
+        }
+
         System.out.println("BindingsTest1 complete");
     }
 }
--- a/test/langtools/tools/javac/patterns/DuplicateBindingTest.out	Thu Jul 11 12:45:33 2019 +0000
+++ b/test/langtools/tools/javac/patterns/DuplicateBindingTest.out	Mon Jul 15 12:52:33 2019 +0200
@@ -1,4 +1,4 @@
-DuplicateBindingTest.java:15:36: compiler.err.already.defined: kindname.variable, s, kindname.method, main(java.lang.String[])
+DuplicateBindingTest.java:15:43: compiler.err.already.defined: kindname.variable, s, kindname.method, main(java.lang.String[])
 DuplicateBindingTest.java:19:22: compiler.err.already.defined: kindname.variable, k, kindname.method, main(java.lang.String[])
 DuplicateBindingTest.java:21:22: compiler.err.already.defined: kindname.variable, args, kindname.method, main(java.lang.String[])
 DuplicateBindingTest.java:18:19: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/patterns/LocalVariableTable.java	Mon Jul 15 12:52:33 2019 +0200
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Ensure the LV table entries are generated for bindings
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ * @compile -g LocalVariableTable.java
+ * @run main LocalVariableTable
+ */
+
+import java.io.*;
+import java.lang.annotation.*;
+import java.util.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * The test checks that a LocalVariableTable attribute is generated for the
+ * method bodies containing patterns, and checks that the expected
+ * set of entries is found in the attribute.
+ *
+ * The test looks for test cases represented by nested classes whose
+ * name begins with "Pattern".  Each such class contains a method
+ * with patterns, and because the test is compiled
+ * with -g, these methods should have a LocalVariableTable.  The set of
+ * expected names in the LVT is provided in an annotation on the class for
+ * the test case.
+ */
+//Copied from: test/langtools/tools/javac/lambda/LocalVariableTable.java
+public class LocalVariableTable {
+    public static void main(String... args) throws Exception {
+        new LocalVariableTable().run();
+    }
+
+    void run() throws Exception {
+        // the declared classes are returned in an unspecified order,
+        // so for neatness, sort them by name before processing them
+        Class<?>[] classes = getClass().getDeclaredClasses();
+        Arrays.sort(classes, (c1, c2) -> c1.getName().compareTo(c2.getName()));
+
+        for (Class<?> c : classes) {
+            if (c.getSimpleName().startsWith("Pattern"))
+                check(c);
+        }
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    /** Check an individual test case. */
+    void check(Class<?> c) throws Exception {
+        System.err.println("Checking " + c.getSimpleName());
+
+        Expect expect = c.getAnnotation(Expect.class);
+        if (expect == null) {
+            error("@Expect not found for class " + c.getSimpleName());
+            return;
+        }
+
+        ClassFile cf = ClassFile.read(getClass().getResource(c.getName() + ".class").openStream());
+        Method m = getMethodByName(cf, c.getSimpleName().contains("Lambda") ? "lambda$" : "test");
+        if (m == null) {
+            error("test method not found");
+            return;
+        }
+
+        Code_attribute code = (Code_attribute) m.attributes.get(Attribute.Code);
+        if (code == null) {
+            error("Code attribute not found");
+            return;
+        }
+
+        LocalVariableTable_attribute lvt =
+                (LocalVariableTable_attribute) code.attributes.get(Attribute.LocalVariableTable);
+        if (lvt == null) {
+            error("LocalVariableTable attribute not found");
+            return;
+        }
+
+        Set<String> foundNames = new LinkedHashSet<>();
+        for (LocalVariableTable_attribute.Entry e: lvt.local_variable_table) {
+            foundNames.add(cf.constant_pool.getUTF8Value(e.name_index));
+        }
+
+        Set<String> expectNames = new LinkedHashSet<>(Arrays.asList(expect.value()));
+        if (!foundNames.equals(expectNames)) {
+            Set<String> foundOnly = new LinkedHashSet<>(foundNames);
+            foundOnly.removeAll(expectNames);
+            for (String s: foundOnly)
+                error("Unexpected name found: " + s);
+            Set<String> expectOnly = new LinkedHashSet<>(expectNames);
+            expectOnly.removeAll(foundNames);
+            for (String s: expectOnly)
+                error("Expected name not found: " + s);
+        }
+    }
+
+    Method getMethodByName(ClassFile cf, String name) throws ConstantPoolException {
+        for (Method m: cf.methods) {
+            if (m.getName(cf.constant_pool).startsWith(name))
+                return m;
+        }
+        return null;
+    }
+
+    /** Report an error. */
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    /**
+     * Annotation used to provide the set of names expected in the LVT attribute.
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Expect {
+        String[] value();
+    }
+
+    /*
+     * ---------- Test cases ---------------------------------------------------
+     */
+
+    @Expect({ "o", "s" })
+    static class Pattern_Simple {
+        public static void test(Object o) {
+            if (o instanceof String s) {}
+        }
+    }
+
+    @Expect({ "s" })
+    static class Pattern_Lambda {
+        public static void test(Object o) {
+            if (o instanceof String s) {
+                Runnable r = () -> {
+                    s.length();
+                };
+            }
+        }
+    }
+
+}
+
--- a/test/langtools/tools/javac/patterns/MatchBindingScopeTest.out	Thu Jul 11 12:45:33 2019 +0000
+++ b/test/langtools/tools/javac/patterns/MatchBindingScopeTest.out	Mon Jul 15 12:52:33 2019 +0200
@@ -1,5 +1,4 @@
 MatchBindingScopeTest.java:18:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
-MatchBindingScopeTest.java:22:53: compiler.err.already.defined: kindname.variable, j, kindname.method, main(java.lang.String[])
 MatchBindingScopeTest.java:22:36: compiler.err.match.binding.exists
 MatchBindingScopeTest.java:29:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
 MatchBindingScopeTest.java:30:32: compiler.err.cant.resolve.location: kindname.variable, k, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
@@ -14,4 +13,4 @@
 MatchBindingScopeTest.java:64:21: compiler.err.cant.resolve.location: kindname.variable, x, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
 MatchBindingScopeTest.java:70:23: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
 MatchBindingScopeTest.java:73:23: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
-16 errors
+15 errors
\ No newline at end of file
--- a/test/langtools/tools/javac/patterns/PatternMatchPosTest.java	Thu Jul 11 12:45:33 2019 +0000
+++ b/test/langtools/tools/javac/patterns/PatternMatchPosTest.java	Mon Jul 15 12:52:33 2019 +0200
@@ -97,6 +97,9 @@
                     if (print) {
                         int start = (int) sp.getStartPosition(dataPath.getCompilationUnit(), tree);
                         int end = (int) sp.getEndPosition(dataPath.getCompilationUnit(), tree);
+                        if (start == (-1)) {
+                            System.err.println("!");
+                        }
                         System.out.println(text.substring(start, end));
                     }
                     return super.scan(tree, p);
@@ -122,9 +125,11 @@
         //no var in instanceof:
 //        if (o instanceof var s) { }
         if (o instanceof String s) { }
+        if (o instanceof java.lang.String s) { }
         switch (o) {
             case 1: break;
             case String s: break;
+            case java.lang.Integer i: break;
             case var s: break;
         }
     }
--- a/test/langtools/tools/javac/patterns/PatternMatchPosTest.out	Thu Jul 11 12:45:33 2019 +0000
+++ b/test/langtools/tools/javac/patterns/PatternMatchPosTest.out	Mon Jul 15 12:52:33 2019 +0200
@@ -3,8 +3,19 @@
 o
 String s
 String
+(o instanceof java.lang.String s)
+o instanceof java.lang.String s
+o
+java.lang.String s
+java.lang.String
+java.lang
+java
 1
 1
 String s
 String
+java.lang.Integer i
+java.lang.Integer
+java.lang
+java
 var s