changeset 52357:79c8fbd899fe patterns-stage-1

Limiting pattern matching features to a core set (no literal patterns, no patterns in switch, no var pattern).
author jlahoda
date Tue, 11 Sep 2018 12:40:55 +0200
parents 423d48955408
children 9eb968074157
files src/jdk.compiler/share/classes/com/sun/source/tree/BindingPatternTree.java src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java src/jdk.compiler/share/classes/com/sun/source/tree/InstanceOfTree.java src/jdk.compiler/share/classes/com/sun/source/tree/LiteralPatternTree.java src/jdk.compiler/share/classes/com/sun/source/tree/MatchesTree.java src/jdk.compiler/share/classes/com/sun/source/tree/PatternTree.java src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java 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/LambdaToMethod.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MatchBindingsComputer.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransSwitches.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TreeDiffer.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/CRTable.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.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/parser/Tokens.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java test/langtools/jdk/jshell/CompletenessTest.java test/langtools/tools/javac/api/TestGetElementReferenceData.java test/langtools/tools/javac/diags/examples/MatchBindingExists.java test/langtools/tools/javac/diags/examples/PatternBindingMayNotBeAssigned.java test/langtools/tools/javac/diags/examples/PatternDominated.java test/langtools/tools/javac/patterns/BindingsTest1.java test/langtools/tools/javac/patterns/BindingsTest2.java test/langtools/tools/javac/patterns/BindingsTest2.out test/langtools/tools/javac/patterns/BreakInsideMatch.java test/langtools/tools/javac/patterns/CastConversionMatch.java test/langtools/tools/javac/patterns/CastConversionMatch.out test/langtools/tools/javac/patterns/ConstantPatternTest1.java test/langtools/tools/javac/patterns/DefaultClauseMustBeLast.java test/langtools/tools/javac/patterns/DefaultClauseMustBeLast.out test/langtools/tools/javac/patterns/DuplicateBindingTest.java test/langtools/tools/javac/patterns/DuplicateBindingTest.out test/langtools/tools/javac/patterns/DuplicateConstantPatternTests.java test/langtools/tools/javac/patterns/DuplicateConstantPatternTests.out test/langtools/tools/javac/patterns/EnsureTypesOrderTest.java test/langtools/tools/javac/patterns/ErasureDominationTest.java test/langtools/tools/javac/patterns/ErasureDominationTest.out test/langtools/tools/javac/patterns/ExamplesFromProposal.java test/langtools/tools/javac/patterns/FlowAnalysisAndConstantPatterns.java test/langtools/tools/javac/patterns/FlowAnalysisAndConstantPatterns.out test/langtools/tools/javac/patterns/FlowAnalysisAndConstantPatterns2.java test/langtools/tools/javac/patterns/FlowAnalysisAndConstantPatterns2.out test/langtools/tools/javac/patterns/FlowAnalysisTest.java test/langtools/tools/javac/patterns/FlowAnalysisTest.out test/langtools/tools/javac/patterns/ImpossibleTypeTest.java test/langtools/tools/javac/patterns/ImpossibleTypeTest.out test/langtools/tools/javac/patterns/MatchBindingScopeTest.java test/langtools/tools/javac/patterns/MatchBindingScopeTest.out test/langtools/tools/javac/patterns/MatchStmtTest.java test/langtools/tools/javac/patterns/MatchesToken.java test/langtools/tools/javac/patterns/NestingMatchAndMatches.java test/langtools/tools/javac/patterns/NullPatternTest.java test/langtools/tools/javac/patterns/NullsInPatterns.java test/langtools/tools/javac/patterns/PatternMatchPosTest.java test/langtools/tools/javac/patterns/PatternMatchPosTest.out test/langtools/tools/javac/patterns/PatternMatchTest1.java test/langtools/tools/javac/patterns/PatternMatchTest2.java test/langtools/tools/javac/patterns/PatternTypeTest1.java test/langtools/tools/javac/patterns/PatternTypeTest2.java test/langtools/tools/javac/patterns/PatternVariablesAreFinal.java test/langtools/tools/javac/patterns/PatternVariablesAreFinal.out test/langtools/tools/javac/patterns/PatternVariablesAreFinal2.java test/langtools/tools/javac/patterns/PrimitiveSelectorTest.java test/langtools/tools/javac/patterns/SwitchExpressionWithPatterns.java test/langtools/tools/javac/patterns/SwitchFallThrough1.java test/langtools/tools/javac/patterns/SwitchFallThrough2.java test/langtools/tools/javac/patterns/SwitchFallThrough2.out test/langtools/tools/javac/patterns/UncheckedWarningOnMatchesTest.java test/langtools/tools/javac/patterns/UncheckedWarningOnMatchesTest.out test/langtools/tools/javac/patterns/UnreachableCasesTest.java test/langtools/tools/javac/patterns/UnreachableCasesTest.out test/langtools/tools/javac/patterns/UnreachableStatementInMatchClause.java test/langtools/tools/javac/patterns/UnreachableStatementInMatchClause.out test/langtools/tools/javac/patterns/VoidTest.java test/langtools/tools/javac/patterns/VoidTest.out
diffstat 93 files changed, 498 insertions(+), 3000 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/BindingPatternTree.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/BindingPatternTree.java	Tue Sep 11 12:40:55 2018 +0200
@@ -25,6 +25,8 @@
 
 package com.sun.source.tree;
 
+import javax.lang.model.element.Name;
+
 /**
  * A binding pattern tree
  */
@@ -36,5 +38,11 @@
      */
     Tree getType();
 
+    /**
+     * A binding variable name.
+     * @return something
+     */
+    Name getBinding();
+
 }
 
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java	Tue Sep 11 12:40:55 2018 +0200
@@ -32,7 +32,7 @@
  *
  * For example:
  * <pre>
- *   case <em>pattern</em> :
+ *   case <em>expression</em> :
  *       <em>statements</em>
  *
  *   default :
@@ -48,13 +48,10 @@
 public interface CaseTree extends Tree {
     /**
      * Returns the expression for the case, or
-     * {@code null} if this is the default case
-     * or this case covers a non-constant pattern.
-     * If this case has multiple patterns, returns the first label.
+     * {@code null} if this is the default case.
+     * If this case has multiple lables, returns the first label.
      * @return the expression for the case, or null
-     * @deprecated use {@link #getPattern()}
      */
-    @Deprecated
     ExpressionTree getExpression();
 
     /**
@@ -72,13 +69,6 @@
     List<? extends ExpressionTree> getExpressions();
 
     /**
-     * Returns the patterns for this case.
-     * For default case, returns an empty list.
-     * @return the patterns for this case
-     */
-    List<? extends PatternTree> getPatterns();
-
-    /**
      * For case with kind {@linkplain CaseKind#STATEMENT},
      * returns the statements labeled by the case.
      * Returns {@code null} for case with kind
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/InstanceOfTree.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/InstanceOfTree.java	Tue Sep 11 12:40:55 2018 +0200
@@ -51,4 +51,10 @@
      * @return the type
      */
     Tree getType();
+
+    /**
+     * Returns the tested pattern.
+     * @return the tested pattern
+     */
+    PatternTree getPattern();
 }
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/LiteralPatternTree.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-package com.sun.source.tree;
-
-/**
- * A literal pattern tree
- */
-public interface LiteralPatternTree extends PatternTree {
-
-    /**
-     * The literal value of this pattern.
-     * @return literal value of this pattern
-     */
-    public ExpressionTree getValue();
-
-}
-
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/MatchesTree.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-package com.sun.source.tree;
-
-/**
- * A tree node for an {@code matches} expression.
- *
- * For example:
- * <pre>
- *   <em>expression</em> matches <em>pattern</em>
- * </pre>
- *
- */
-public interface MatchesTree extends ExpressionTree {
-    /**
-     * Returns the expression to be matched.
-     * @return the expression
-     */
-    ExpressionTree getExpression();
-
-    /**
-     * Returns the pattern to match against.
-     * @return the pattern
-     */
-    Tree getPattern();
-}
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/PatternTree.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/PatternTree.java	Tue Sep 11 12:40:55 2018 +0200
@@ -32,9 +32,4 @@
  */
 public interface PatternTree extends Tree {
 
-    /**
-     * A doc to make build happy
-     * @return something
-     */
-    Name getBinding();
 }
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java	Tue Sep 11 12:40:55 2018 +0200
@@ -179,11 +179,6 @@
         LABELED_STATEMENT(LabeledStatementTree.class),
 
         /**
-         * Used for instances of {@link MatchesTree}.
-         */
-        MATCHES(MatchesTree.class),
-
-        /**
          * Used for instances of {@link MethodTree}.
          */
         METHOD(MethodTree.class),
@@ -230,11 +225,6 @@
         BINDING_PATTERN(BindingPatternTree.class),
 
         /**
-         * Used for instances of {@link LiteralPatternTree}.
-         */
-        LITERAL_PATTERN(LiteralPatternTree.class),
-
-        /**
          * Used for instances of {@link PrimitiveTypeTree}.
          */
         PRIMITIVE_TYPE(PrimitiveTypeTree.class),
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java	Tue Sep 11 12:40:55 2018 +0200
@@ -258,14 +258,6 @@
     R visitLiteral(LiteralTree node, P p);
 
     /**
-     * Visits a MatchesTree node.
-     * @param node the node being visited
-     * @param p a parameter value
-     * @return a result value
-     */
-    R visitMatches(MatchesTree node, P p);
-
-    /**
      * Visits an BindingPattern node.
      * @param node the node being visited
      * @param p a parameter value
@@ -274,14 +266,6 @@
     R visitBindingPattern(BindingPatternTree node, P p);
 
     /**
-     * Visits a LiteralPattern node.
-     * @param node the node being visited
-     * @param p a parameter value
-     * @return a result value
-     */
-    R visitLiteralPattern(LiteralPatternTree node, P p);
-
-    /**
      * Visits a MethodTree node.
      * @param node the node being visited
      * @param p a parameter value
--- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java	Tue Sep 11 12:40:55 2018 +0200
@@ -566,18 +566,6 @@
      * @return  the result of {@code defaultAction}
      */
     @Override
-    public R visitMatches(MatchesTree node, P p) {
-        return defaultAction(node, p);
-    }
-
-    /**
-     * {@inheritDoc} This implementation calls {@code defaultAction}.
-     *
-     * @param node {@inheritDoc}
-     * @param p {@inheritDoc}
-     * @return  the result of {@code defaultAction}
-     */
-    @Override
     public R visitBindingPattern(BindingPatternTree node, P p) {
         return defaultAction(node, p);
     }
@@ -590,18 +578,6 @@
      * @return  the result of {@code defaultAction}
      */
     @Override
-    public R visitLiteralPattern(LiteralPatternTree node, P p) {
-        return defaultAction(node, p);
-    }
-
-    /**
-     * {@inheritDoc} This implementation calls {@code defaultAction}.
-     *
-     * @param node {@inheritDoc}
-     * @param p {@inheritDoc}
-     * @return  the result of {@code defaultAction}
-     */
-    @Override
     public R visitArrayAccess(ArrayAccessTree node, P p) {
         return defaultAction(node, p);
     }
--- a/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java	Tue Sep 11 12:40:55 2018 +0200
@@ -365,7 +365,7 @@
     @Override
     @SuppressWarnings("removal")
     public R visitCase(CaseTree node, P p) {
-        R r = scan(node.getPatterns(), p);
+        R r = scan(node.getExpressions(), p);
         if (node.getCaseKind() == CaseKind.RULE)
             r = scanAndReduce(node.getBody(), p, r);
         else
@@ -677,7 +677,11 @@
     @Override
     public R visitInstanceOf(InstanceOfTree node, P p) {
         R r = scan(node.getExpression(), p);
-        r = scanAndReduce(node.getType(), p, r);
+        if (node.getPattern() != null) {
+            r = scanAndReduce(node.getPattern(), p, r);
+        } else {
+            r = scanAndReduce(node.getType(), p, r);
+        }
         return r;
     }
 
@@ -689,20 +693,6 @@
      * @return the result of scanning
      */
     @Override
-    public R visitMatches(MatchesTree node, P p) {
-        R r = scan(node.getExpression(), p);
-        r = scanAndReduce(node.getPattern(), p, r);
-        return r;
-    }
-
-    /**
-     * {@inheritDoc} This implementation scans the children in left to right order.
-     *
-     * @param node the node being visited
-     * @param p a parameter value
-     * @return a result value
-     */
-    @Override
     public R visitBindingPattern(BindingPatternTree node, P p) {
         return scan(node.getType(), p);
     }
@@ -710,18 +700,6 @@
     /**
      * {@inheritDoc} This implementation scans the children in left to right order.
      *
-     * @param node the node being visited
-     * @param p a parameter value
-     * @return a result value
-     */
-    @Override
-    public R visitLiteralPattern(LiteralPatternTree node, P p) {
-        return scan(node.getValue(), p);
-    }
-
-    /**
-     * {@inheritDoc} This implementation scans the children in left to right order.
-     *
      * @param node  {@inheritDoc}
      * @param p  {@inheritDoc}
      * @return the result of scanning
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Sep 11 12:40:55 2018 +0200
@@ -59,7 +59,6 @@
 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.tree.JCTree.JCLiteralPattern.LiteralPatternKind;
 import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
@@ -76,7 +75,6 @@
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.code.TypeTag.WILDCARD;
-import com.sun.tools.javac.tree.JCTree.GenericSwitch.SwitchKind;
 import com.sun.tools.javac.comp.Analyzer.AnalyzerMode;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
@@ -1419,7 +1417,7 @@
     }
 
     public void visitSwitch(JCSwitch tree) {
-        handleSwitch(tree, tree.selector, tree.cases, (t, k) -> ((JCSwitch) t).kind = k, (c, caseEnv) -> {
+        handleSwitch(tree, tree.selector, tree.cases, (c, caseEnv) -> {
             attribStats(c.stats, caseEnv);
         });
         result = null;
@@ -1443,7 +1441,7 @@
         ListBuffer<DiagnosticPosition> caseTypePositions = new ListBuffer<>();
         ListBuffer<Type> caseTypes = new ListBuffer<>();
 
-        handleSwitch(tree, tree.selector, tree.cases, (t, k) -> ((JCSwitchExpression) t).kind = k, (c, caseEnv) -> {
+        handleSwitch(tree, tree.selector, tree.cases, (c, caseEnv) -> {
             caseEnv.info.breakResult = condInfo;
             attribStats(c.stats, caseEnv);
             new TreeScanner() {
@@ -1486,7 +1484,6 @@
     private void handleSwitch(JCTree switchTree,
                               JCExpression selector,
                               List<JCCase> cases,
-                              BiConsumer<JCTree, SwitchKind> kindSetter,
                               BiConsumer<JCCase, Env<AttrContext>> attribCase) {
         Type seltype = attribExpr(selector, env);
 
@@ -1494,31 +1491,15 @@
             env.dup(switchTree, env.info.dup(env.info.scope.dup()));
 
         try {
-            boolean hasPatternCases = cases.stream()
-                                           .flatMap(c -> c.pats.stream())
-                                           .anyMatch(pat -> pat.constExpression() == null); //XXX: null handling???
-            SwitchKind kind;
-            if (hasPatternCases) {
-                //TODO: check source level
-                kind = SwitchKind.MATCHING;
-            } else if ((seltype.tsym.flags() & Flags.ENUM) != 0) {
-                kind = SwitchKind.ENUM;
-            } else if (types.isSameType(seltype, syms.stringType)) {
-                kind = SwitchKind.STRING;
-            } else if (!types.isAssignable(seltype, syms.intType) &&
-                       !types.isSameType(seltype, syms.voidType)) {
-                //TODO: check source level
-                kind = SwitchKind.MATCHING;
-            } else {
+            boolean enumSwitch = (seltype.tsym.flags() & Flags.ENUM) != 0;
+            boolean stringSwitch = types.isSameType(seltype, syms.stringType);
+            if (!enumSwitch && !stringSwitch)
                 seltype = chk.checkType(selector.pos(), seltype, syms.intType);
-                kind = SwitchKind.ORDINARY;
-            }
-            kindSetter.accept(switchTree, kind);
+
             // Attribute all cases and
             // check that there are no duplicate case labels or default clauses.
             Set<Object> labels = new HashSet<>(); // The set of case labels.
             boolean hasDefault = false;      // Is there a default label?
-            List<BindingSymbol> prevBindings = null;
             @SuppressWarnings("removal")
             CaseKind caseKind = null;
             boolean wasError = false;
@@ -1531,73 +1512,43 @@
                               Errors.SwitchMixingCaseTypes);
                     wasError = true;
                 }
-                List<BindingSymbol> matchBindings = prevBindings;
-                if (c.getPatterns().nonEmpty()) {
-                    for (JCPattern pat : c.getPatterns()) {
+                if (c.getExpressions().nonEmpty()) {
+                    for (JCExpression pat : c.getExpressions()) {
                         if (TreeInfo.isNull(pat)) {
                             log.error(pat.pos(),
                                       Errors.SwitchNullNotAllowed);
-                            continue;
-                        }
-                        switch (kind) {
-                            case MATCHING:
-                                ResultInfo castInfo = unknownExprInfo;
-                                if (pat.getTag() == BINDINGPATTERN) {
-                                    JCBindingPattern bindingPattern = (JCBindingPattern) pat;
-                                    if (bindingPattern.vartype == null)
-                                        castInfo = castInfo(seltype);
-                                }
-                                Type patType = attribTree(pat, switchEnv, castInfo);
-                                chk.checkCastable(selector.pos(), seltype, patType);
-                                if (pat.getTag() == LITERALPATTERN && !labels.add(patType.constValue())) {
+                        } else if (enumSwitch) {
+                            Symbol sym = enumConstant(pat, seltype);
+                            if (sym == null) {
+                                log.error(pat.pos(), Errors.EnumLabelMustBeUnqualifiedEnum);
+                            } else if (!labels.add(sym)) {
+                                log.error(c.pos(), Errors.DuplicateCaseLabel);
+                            }
+                        } else {
+                            Type pattype = attribExpr(pat, switchEnv, seltype);
+                            if (!pattype.hasTag(ERROR)) {
+                                if (pattype.constValue() == null) {
+                                    log.error(pat.pos(),
+                                              (stringSwitch ? Errors.StringConstReq : Errors.ConstExprReq));
+                                } else if (!labels.add(pattype.constValue())) {
                                     log.error(c.pos(), Errors.DuplicateCaseLabel);
                                 }
-                                break;
-                            case ENUM:
-                                Symbol sym = enumConstant(pat.constExpression(), seltype);
-                                if (sym == null) {
-                                    log.error(pat.constExpression().pos(), Errors.EnumLabelMustBeUnqualifiedEnum);
-                                } else if (!labels.add(sym)) {
-                                    log.error(c.pos(), Errors.DuplicateCaseLabel);
-                                }
-                                break;
-                            default:
-                                Type pattype = attribExpr(pat.constExpression(), switchEnv, seltype);
-                                if (!pattype.hasTag(ERROR)) {
-                                    if (pattype.constValue() == null) {
-                                        log.error(pat.constExpression().pos(),
-                                                  (kind == SwitchKind.STRING ? Errors.StringConstReq
-                                                                                  : Errors.ConstExprReq));
-                                    } else if (!labels.add(pattype.constValue())) {
-                                        log.error(c.pos(), Errors.DuplicateCaseLabel);
-                                    }
-                                }
-                                break;
+                            }
                         }
-                        matchBindings = getMatchBindings(types, log, pat, true, matchBindings);
                     }
+                } else if (hasDefault) {
+                    log.error(c.pos(), Errors.DuplicateDefaultLabel);
                 } else {
-                    if (hasDefault) {
-                        log.error(c.pos(), Errors.DuplicateDefaultLabel);
-                    } else {
-                        hasDefault = true;
-                    }
-                    matchBindings = getMatchBindings(types, log, null, true, matchBindings);
+                    hasDefault = true;
                 }
-
-                Env<AttrContext> caseEnv = bindingEnv(switchEnv, matchBindings);
-
-                caseEnv.tree = c;
-
+                Env<AttrContext> caseEnv =
+                    switchEnv.dup(c, env.info.dup(switchEnv.info.scope.dup()));
                 try {
                     attribCase.accept(c, caseEnv);
                 } finally {
                     caseEnv.info.scope.leave();
                     addVars(c.stats, switchEnv.info.scope);
                 }
-
-                flow.aliveAfterCase(caseEnv, c, make);
-                prevBindings = c.completesNormally ? matchBindings : null;
             }
         } finally {
             switchEnv.info.scope.leave();
@@ -3743,7 +3694,13 @@
         boolean isPoly = allowPoly && (expr.hasTag(LAMBDA) || expr.hasTag(REFERENCE));
         if (isPoly) {
             //expression is a poly - we need to propagate target type info
-            castInfo = castInfo(clazztype);
+            castInfo = new ResultInfo(KindSelector.VAL, clazztype,
+                                      new Check.NestedCheckContext(resultInfo.checkContext) {
+                @Override
+                public boolean compatible(Type found, Type req, Warner warn) {
+                    return types.isCastable(found, req, warn);
+                }
+            });
         } else {
             //standalone cast - target-type info is not propagated
             castInfo = unknownExprInfo;
@@ -3760,44 +3717,28 @@
     public void visitTypeTest(JCInstanceOf tree) {
         Type exprtype = chk.checkNullOrRefType(
                 tree.expr.pos(), attribExpr(tree.expr, env));
-        Type clazztype = attribType(tree.clazz, env);
-        if (!clazztype.hasTag(TYPEVAR)) {
-            clazztype = chk.checkClassOrArrayType(tree.clazz.pos(), clazztype);
-        }
-        if (!clazztype.isErroneous() && !types.isReifiable(clazztype)) {
-            log.error(tree.clazz.pos(), Errors.IllegalGenericTypeForInstof);
-            clazztype = types.createErrorType(clazztype);
-        }
-        chk.validate(tree.clazz, env, false);
+        Type clazztype;
+        if (tree.pattern.getTag() == BINDINGPATTERN) {
+            attribTree(tree.pattern, env, unknownExprInfo);
+            clazztype = tree.pattern.type;
+            if (!clazztype.hasTag(TYPEVAR)) {
+                clazztype = chk.checkClassOrArrayType(tree.pattern.pos(), clazztype);
+            }
+        } else {
+            clazztype = attribType(tree.pattern, env);
+            if (!clazztype.hasTag(TYPEVAR)) {
+                clazztype = chk.checkClassOrArrayType(tree.pattern.pos(), clazztype);
+            }
+            if (!clazztype.isErroneous() && !types.isReifiable(clazztype)) {
+                log.error(tree.pattern.pos(), Errors.IllegalGenericTypeForInstof);
+                clazztype = types.createErrorType(clazztype);
+            }
+            chk.validate(tree.pattern, env, false);
+        }
         chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
         result = check(tree, syms.booleanType, KindSelector.VAL, resultInfo);
     }
 
-    public void visitPatternTest(JCMatches tree) {
-        Type exprtype = attribExpr(tree.expr, env); //no target type
-        ResultInfo castInfo = unknownExprInfo;
-        if (tree.pattern.getTag() == BINDINGPATTERN) {
-            JCBindingPattern bindingPattern = (JCBindingPattern) tree.pattern;
-            if (bindingPattern.vartype == null)
-                castInfo = castInfo(exprtype);
-        }
-        attribTree(tree.pattern, env, castInfo);
-        chk.checkCastable(tree.expr.pos(), exprtype, tree.pattern.type);
-        result = check(tree, syms.booleanType, KindSelector.VAL, resultInfo);
-    }
-
-    ResultInfo castInfo(Type target) {
-        return target.isErroneous() ?
-                unknownExprInfo :
-                new ResultInfo(KindSelector.VAL, target,
-                        new Check.NestedCheckContext(resultInfo.checkContext) {
-                            @Override
-                            public boolean compatible(Type found, Type req, Warner warn) {
-                                return types.isCastable(found, req, warn);
-                            }
-                        });
-    }
-
     public void visitBindingPattern(JCBindingPattern tree) {
         if (tree.vartype != null) {
             ResultInfo varInfo = new ResultInfo(KindSelector.TYP, resultInfo.pt, resultInfo.checkContext);
@@ -3813,35 +3754,6 @@
         result = tree.type;
     }
 
-    public void visitLiteralPattern(JCLiteralPattern tree) {
-        Type patType = attribTree(tree.value, env, resultInfo);
-
-        if (tree.value.hasTag(IDENT)) {
-            // Pattern is an identifier
-            JCIdent ident = (JCIdent)tree.value;
-            if (ident.sym.kind==TYP) {
-                tree.patternKind = LiteralPatternKind.TYPE;
-            } else {
-                tree.patternKind = LiteralPatternKind.CONSTANTEXPRESSIONORNULL;
-            }
-        } else if (tree.value.hasTag(SELECT)) {
-            // Pattern is a compound name
-            JCFieldAccess ident = (JCFieldAccess)tree.value;
-            if (ident.sym.kind==TYP) {
-                tree.patternKind = LiteralPatternKind.TYPE;
-            } else {
-                tree.patternKind = LiteralPatternKind.CONSTANTEXPRESSIONORNULL;
-            }
-        } else {
-            // Pattern must be null literal or a constant expression
-            tree.patternKind = LiteralPatternKind.CONSTANTEXPRESSIONORNULL;
-            if (!patType.isErroneous() && !patType.hasTag(BOT) && patType.constValue() == null) {
-                log.error(tree.pos(), Errors.ConstExprReq);
-            }
-        }
-        tree.type = patType;
-    }
-
     public void visitIndexed(JCArrayAccess tree) {
         Type owntype = types.createErrorType(tree.type);
         Type atype = attribExpr(tree.indexed, env);
@@ -5232,8 +5144,8 @@
             super.visitTypeCast(tree);
         }
         public void visitTypeTest(JCInstanceOf tree) {
-            if (tree.clazz != null && tree.clazz.type != null)
-                validateAnnotatedType(tree.clazz, tree.clazz.type);
+            if (tree.pattern != null && !(tree.pattern instanceof JCPattern) && tree.pattern.type != null)
+                validateAnnotatedType(tree.pattern, tree.pattern.type);
             super.visitTypeTest(tree);
         }
         public void visitNewClass(JCNewClass tree) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java	Tue Sep 11 12:40:55 2018 +0200
@@ -60,10 +60,9 @@
         FLOW(5),
         TRANSTYPES(6),
         UNLAMBDA(7),
-        TRANSSWITCHES(8),
-        TRANSPATTERNS(9),
-        LOWER(10),
-        GENERATE(11);
+        TRANSPATTERNS(8),
+        LOWER(9),
+        GENERATE(10);
 
         CompileState(int value) {
             this.value = value;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Tue Sep 11 12:40:55 2018 +0200
@@ -45,7 +45,6 @@
 
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.tree.JCTree.GenericSwitch.SwitchKind;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Flags.BLOCK;
@@ -256,23 +255,6 @@
         }
     }
 
-    public void aliveAfterCase(Env<AttrContext> env, JCCase that, TreeMaker make) {
-        //we need to disable diagnostics temporarily; the problem is that if
-        //a lambda expression contains e.g. an unreachable statement, an error
-        //message will be reported and will cause compilation to skip the flow analyis
-        //step - if we suppress diagnostics, we won't stop at Attr for flow-analysis
-        //related errors, which will allow for more errors to be detected
-        Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log);
-        try {
-            CaseAliveAnalyzer analyzer = new CaseAliveAnalyzer();
-
-            analyzer.analyzeTree(env, that.stats, make);
-            that.completesNormally = analyzer.isAlive();
-        } finally {
-            log.popDiagnosticHandler(diagHandler);
-        }
-    }
-
     /**
      * Definite assignment scan mode
      */
@@ -615,137 +597,39 @@
         }
 
         public void visitSwitch(JCSwitch tree) {
-            if (tree.kind == SwitchKind.MATCHING) {
-                visitMatchingSwitch(tree);
-            } else {
-                visitLegacySwitch(tree);
+            ListBuffer<PendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<>();
+            scan(tree.selector);
+            boolean hasDefault = false;
+            for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
+                alive = true;
+                JCCase c = l.head;
+                if (c.pats.isEmpty())
+                    hasDefault = true;
+                else {
+                    for (JCExpression pat : c.pats) {
+                        scan(pat);
+                    }
+                }
+                scanStats(c.stats);
+                c.completesNormally = alive;
+                if (alive && c.caseKind == JCCase.RULE) {
+                    scanSyntheticBreak(make, tree);
+                    alive = false;
+                }
+                // Warn about fall-through if lint switch fallthrough enabled.
+                if (alive &&
+                    lint.isEnabled(Lint.LintCategory.FALLTHROUGH) &&
+                    c.stats.nonEmpty() && l.tail.nonEmpty())
+                    log.warning(Lint.LintCategory.FALLTHROUGH,
+                                l.tail.head.pos(),
+                                Warnings.PossibleFallThroughIntoCase);
             }
+            if (!hasDefault) {
+                alive = true;
+            }
+            alive |= resolveBreaks(tree, prevPendingExits);
         }
-            // where
-            private void visitMatchingSwitch(JCSwitch tree) {
-                ListBuffer<PendingExit> prevPendingExits = pendingExits;
-                pendingExits = new ListBuffer<>();
-                scan(tree.selector);
-                boolean aliveInAnyArm = false;
-                boolean hasDefault = false;
-                for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
-                    JCCase c = l.head;
-                    alive = true;
-                    if (c.pats.nonEmpty()) {
-                        for (JCPattern pat : c.pats) {
-                            if (patternDominated(tree.cases, pat, tree.selector.type)) {
-                                log.error(c, Errors.PatternDominated);
-                            }
-                            scan(pat);
-                        }
-                    } else {
-                        if (patternDominated(tree.cases, null, tree.selector.type)) {
-                            log.error(c, Errors.UnreachableStmt);
-                        }
-                        hasDefault = true;
-                    }
-                    scanStats(c.stats);
-                    aliveInAnyArm |= alive;
-                }
-                alive = aliveInAnyArm || !hasDefault;
-                alive |= resolveBreaks(tree, prevPendingExits);
-            }
-            //where:
-                private boolean patternDominated(List<JCCase> clauses, JCPattern givenPattern, Type selectorType) {
-                    // TODO: This needs to evolve as we add more support for other pattern kinds.
-                    boolean assignableCaseFound = false;
-                    OUTTER: for (List<JCCase> l = clauses; l.nonEmpty(); l = l.tail) {
-                        JCCase c = l.head;
-                        if (c.pats.isEmpty()) {
-                            if (givenPattern == null) {
-                                break ;
-                            } else {
-                                // default clause must be the last
-                                return l.nonEmpty();
-                            }
-                        }
-                        for (JCPattern pat : c.pats) {
-                            if (pat == givenPattern) {
-                                break OUTTER;
-                            }
-                            switch (pat.getTag()) {
-                                case BINDINGPATTERN: {
-                                    JCBindingPattern vpatt = (JCBindingPattern)pat;
-                                    if (vpatt.vartype == null) {
-                                        assignableCaseFound = true;
-                                        if (givenPattern != null)
-                                            return true;
-                                    } else {
-                                        if (types.isAssignable(selectorType, vpatt.type))
-                                            assignableCaseFound = true;
-                                        if (givenPattern != null) {
-                                            switch (givenPattern.getTag()) {
-                                                case BINDINGPATTERN:
-                                                    JCBindingPattern currentPattern = (JCBindingPattern)givenPattern;
-                                                    if (currentPattern.vartype != null) {
-                                                        if (types.isAssignable(types.erasure(currentPattern.vartype.type), types.erasure(vpatt.type)))
-                                                            return true;
-                                                    }
-                                                    break;
-                                                case LITERALPATTERN:
-                                                    JCLiteralPattern literalPattern = (JCLiteralPattern) givenPattern;
-                                                    if (literalPattern.type.constValue()==null) {
-                                                        return false; // null pattern is not dominated by a type test pattern
-                                                    } else if (types.isAssignable(literalPattern.type, vpatt.type)) {
-                                                        return true;
-                                                    }
-                                                    break;
-                                            }
-                                        }
-                                    }
-                                    break;
-                                }
-                                case LITERALPATTERN: {
-                                    break;  // does not dominate any other pattern.
-                                }
-                                default: {
-                                    Assert.check(false);
-                                    break;
-                                }
-                            }
-                        }
-                    }
-                    return givenPattern != null ? assignableCaseFound : false;
-                }
-            private void visitLegacySwitch(JCSwitch tree) {
-                ListBuffer<PendingExit> prevPendingExits = pendingExits;
-                pendingExits = new ListBuffer<>();
-                scan(tree.selector);
-                boolean hasDefault = false;
-                for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
-                    alive = true;
-                    JCCase c = l.head;
-                    if (c.pats.isEmpty())
-                        hasDefault = true;
-                    else {
-                        for (JCPattern pat : c.pats) {
-                            scan(pat);
-                        }
-                    }
-                    scanStats(c.stats);
-                    if (alive && c.caseKind == JCCase.RULE) {
-                        System.err.println("synthetic break: " + tree);
-                        scanSyntheticBreak(make, tree);
-                        alive = false;
-                    }
-                    // Warn about fall-through if lint switch fallthrough enabled.
-                    if (alive &&
-                        lint.isEnabled(Lint.LintCategory.FALLTHROUGH) &&
-                        c.stats.nonEmpty() && l.tail.nonEmpty())
-                        log.warning(Lint.LintCategory.FALLTHROUGH,
-                                    l.tail.head.pos(),
-                                    Warnings.PossibleFallThroughIntoCase);
-                }
-                if (!hasDefault) {
-                    alive = true;
-                }
-                alive |= resolveBreaks(tree, prevPendingExits);
-            }
 
         @Override
         public void visitSwitchExpression(JCSwitchExpression tree) {
@@ -767,18 +651,18 @@
                 if (c.pats.isEmpty())
                     hasDefault = true;
                 else {
-                    for (JCPattern pat : c.pats) {
+                    for (JCExpression pat : c.pats) {
                         scan(pat);
-                        if (constants != null && pat.hasTag(LITERALPATTERN)) {
-                            JCExpression lit = ((JCLiteralPattern) pat).value;
-                            if (lit.hasTag(IDENT))
-                                constants.remove(((JCIdent) lit).name);
-                            if (lit.type != null)
-                                constants.remove(lit.type.constValue());
+                        if (constants != null) {
+                            if (pat.hasTag(IDENT))
+                                constants.remove(((JCIdent) pat).name);
+                            if (pat.type != null)
+                                constants.remove(pat.type.constValue());
                         }
                     }
                 }
                 scanStats(c.stats);
+                c.completesNormally = alive;
             }
             if ((constants == null || !constants.isEmpty()) && !hasDefault) {
                 log.error(tree, Errors.NotExhaustive);
@@ -919,15 +803,12 @@
             analyzeTree(env, env.tree, make);
         }
         public void analyzeTree(Env<AttrContext> env, JCTree tree, TreeMaker make) {
-            analyzeTree(env, List.of(tree), make);
-        }
-        public void analyzeTree(Env<AttrContext> env, List<? extends JCTree> trees, TreeMaker make) {
             try {
                 attrEnv = env;
                 Flow.this.make = make;
                 pendingExits = new ListBuffer<>();
                 alive = true;
-                scan(trees);
+                scan(tree);
             } finally {
                 pendingExits = null;
                 Flow.this.make = null;
@@ -1544,19 +1425,6 @@
     }
 
     /**
-     * TODO
-     */
-    class CaseAliveAnalyzer extends AliveAnalyzer {
-        @Override
-        public void visitClassDef(JCClassDecl tree) {
-            //skip
-        }
-        public boolean isAlive() {
-            return super.alive;
-        }
-    }
-
-    /**
      * Specialized pass that performs DA/DU on a lambda
      */
     class LambdaAssignAnalyzer extends AssignAnalyzer {
@@ -2326,7 +2194,7 @@
                 if (c.pats.isEmpty()) {
                     hasDefault = true;
                 } else {
-                    for (JCPattern pat : c.pats) {
+                    for (JCExpression pat : c.pats) {
                         scanExpr(pat);
                     }
                 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Tue Sep 11 12:40:55 2018 +0200
@@ -67,7 +67,6 @@
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
-import com.sun.tools.javac.tree.JCTree.GenericSwitch.SwitchKind;
 import static com.sun.tools.javac.jvm.Pool.DynamicMethod;
 
 import javax.lang.model.element.ElementKind;
@@ -716,10 +715,9 @@
             JCBreak br = make.Break(null);
             breaks.add(br);
             List<JCStatement> stmts = entry.getValue().append(br).toList();
-            cases.add(make.Case(JCCase.STATEMENT, List.of(make.LiteralPattern(make.Literal(entry.getKey()))), stmts, null));
+            cases.add(make.Case(JCCase.STATEMENT, List.of(make.Literal(entry.getKey())), stmts, null));
         }
         JCSwitch sw = make.Switch(deserGetter("getImplMethodName", syms.stringType), cases.toList());
-        sw.kind = SwitchKind.STRING;
         for (JCBreak br : breaks) {
             br.target = sw;
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Tue Sep 11 12:40:55 2018 +0200
@@ -56,17 +56,15 @@
 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
+import static com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode.DEREF;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
 import com.sun.tools.javac.tree.JCTree.JCBreak;
 import com.sun.tools.javac.tree.JCTree.JCCase;
 import com.sun.tools.javac.tree.JCTree.JCExpression;
 import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
 import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.LEFT;
-import com.sun.tools.javac.tree.JCTree.GenericSwitch.SwitchKind;
-import com.sun.tools.javac.tree.JCTree.JCSwitchExpression;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
-
 /** This pass translates away some syntactic sugar: inner classes,
  *  class literals, assertions, foreach loops, etc.
  *
@@ -3358,23 +3356,60 @@
     }
 
     public void visitSwitch(JCSwitch tree) {
-        Type target;
-        switch (tree.kind) {
-            case ENUM: target = tree.selector.type; break;
-            case STRING: target = syms.stringType; break;
-            case ORDINARY: target = syms.intType; break;
-            default:
-                Assert.error("Should not get here, kind: " + tree.kind);
-                throw new InternalError();
+        //expand multiple label cases:
+        ListBuffer<JCCase> cases = new ListBuffer<>();
+
+        for (JCCase c : tree.cases) {
+            switch (c.pats.size()) {
+                case 0: //default
+                case 1: //single label
+                    cases.append(c);
+                    break;
+                default: //multiple labels, expand:
+                    //case C1, C2, C3: ...
+                    //=>
+                    //case C1:
+                    //case C2:
+                    //case C3: ...
+                    List<JCExpression> patterns = c.pats;
+                    while (patterns.tail.nonEmpty()) {
+                        cases.append(make_at(c.pos()).Case(JCCase.STATEMENT,
+                                                           List.of(patterns.head),
+                                                           List.nil(),
+                                                           null));
+                        patterns = patterns.tail;
+                    }
+                    c.pats = patterns;
+                    cases.append(c);
+                    break;
+            }
         }
+
+        for (JCCase c : cases) {
+            if (c.caseKind == JCCase.RULE && c.completesNormally) {
+                JCBreak b = make_at(c.pos()).Break(null);
+                b.target = tree;
+                c.stats = c.stats.append(b);
+            }
+        }
+
+        tree.cases = cases.toList();
+
+        Type selsuper = types.supertype(tree.selector.type);
+        boolean enumSwitch = selsuper != null &&
+            (tree.selector.type.tsym.flags() & ENUM) != 0;
+        boolean stringSwitch = selsuper != null &&
+            types.isSameType(tree.selector.type, syms.stringType);
+        Type target = enumSwitch ? tree.selector.type :
+            (stringSwitch? syms.stringType : syms.intType);
         tree.selector = translate(tree.selector, target);
         tree.cases = translateCases(tree.cases);
-        switch (tree.kind) {
-            case ENUM: result = visitEnumSwitch(tree); break;
-            case STRING: result = visitStringSwitch(tree); break;
-            case ORDINARY: result = tree; break;
-            default:
-                Assert.error("Should not get here, kind: " + tree.kind);
+        if (enumSwitch) {
+            result = visitEnumSwitch(tree);
+        } else if (stringSwitch) {
+            result = visitStringSwitch(tree);
+        } else {
+            result = tree;
         }
     }
 
@@ -3392,16 +3427,14 @@
         ListBuffer<JCCase> cases = new ListBuffer<>();
         for (JCCase c : tree.cases) {
             if (c.pats.nonEmpty()) {
-                VarSymbol label = (VarSymbol)TreeInfo.symbol(c.pats.head.constExpression());
-                JCLiteral value = map.forConstant(label);
-                JCPattern pat = make.LiteralPattern(value);
+                VarSymbol label = (VarSymbol)TreeInfo.symbol(c.pats.head);
+                JCLiteral pat = map.forConstant(label);
                 cases.append(make.Case(JCCase.STATEMENT, List.of(pat), c.stats, null));
             } else {
                 cases.append(c);
             }
         }
         JCSwitch enumSwitch = make.Switch(selector, cases.toList());
-        enumSwitch.kind = SwitchKind.ORDINARY;
         patchTargets(enumSwitch, tree, enumSwitch);
         return enumSwitch;
     }
@@ -3467,7 +3500,7 @@
 
             for(JCCase oneCase : caseList) {
                 if (oneCase.pats.nonEmpty()) { // pats is empty for a "default" case
-                    JCExpression expression = oneCase.pats.head.constExpression();
+                    JCExpression expression = oneCase.pats.head;
                     String labelExpr = (String) expression.type.constValue();
                     Integer mapping = caseLabelToPosition.put(labelExpr, casePosition);
                     Assert.checkNull(mapping);
@@ -3529,7 +3562,6 @@
                                                        List.nil()).setType(syms.intType);
             JCSwitch switch1 = make.Switch(hashCodeCall,
                                         caseBuffer.toList());
-            switch1.kind = SwitchKind.ORDINARY;
             for(Map.Entry<Integer, Set<String>> entry : hashToString.entrySet()) {
                 int hashCode = entry.getKey();
                 Set<String> stringsWithHashCode = entry.getValue();
@@ -3552,7 +3584,7 @@
                 breakStmt.target = switch1;
                 lb.append(elsepart).append(breakStmt);
 
-                caseBuffer.append(make.Case(JCCase.STATEMENT, List.of(make.LiteralPattern(make.Literal(hashCode))), lb.toList(), null));
+                caseBuffer.append(make.Case(JCCase.STATEMENT, List.of(make.Literal(hashCode)), lb.toList(), null));
             }
 
             switch1.cases = caseBuffer.toList();
@@ -3564,7 +3596,6 @@
 
             ListBuffer<JCCase> lb = new ListBuffer<>();
             JCSwitch switch2 = make.Switch(make.Ident(dollar_tmp), lb.toList());
-            switch2.kind = SwitchKind.ORDINARY;
             for(JCCase oneCase : caseList ) {
                 // Rewire up old unlabeled break statements to the
                 // replacement switch being created.
@@ -3575,11 +3606,11 @@
                 if (isDefault)
                     caseExpr = null;
                 else {
-                    caseExpr = make.Literal(caseLabelToPosition.get((String)TreeInfo.skipParens(oneCase.pats.head.constExpression()).
+                    caseExpr = make.Literal(caseLabelToPosition.get((String)TreeInfo.skipParens(oneCase.pats.head).
                                                                     type.constValue()));
                 }
 
-                lb.append(make.Case(JCCase.STATEMENT, caseExpr == null ? List.nil() : List.of(make.LiteralPattern(caseExpr)),
+                lb.append(make.Case(JCCase.STATEMENT, caseExpr == null ? List.nil() : List.of(caseExpr),
                                     oneCase.getStatements(), null));
             }
 
@@ -3592,8 +3623,73 @@
 
     @Override
     public void visitSwitchExpression(JCSwitchExpression tree) {
-        Assert.error("Shuld not get here!");
+        //translates switch expression to statement switch:
+        //switch (selector) {
+        //    case C: break value;
+        //    ...
+        //}
+        //=>
+        //(letexpr T exprswitch$;
+        //         switch (selector) {
+        //             case C: { exprswitch$ = value; break; }
+        //         }
+        //         exprswitch$
+        //)
+        VarSymbol dollar_switchexpr = new VarSymbol(Flags.FINAL|Flags.SYNTHETIC,
+                           names.fromString("exprswitch" + tree.pos + target.syntheticNameChar()),
+                           tree.type,
+                           currentMethodSym);
+
+        ListBuffer<JCStatement> stmtList = new ListBuffer<>();
+
+        stmtList.append(make.at(tree.pos()).VarDef(dollar_switchexpr, null).setType(dollar_switchexpr.type));
+        JCSwitch switchStatement = make.Switch(tree.selector, null);
+        switchStatement.cases =
+                tree.cases.stream()
+                          .map(c -> convertCase(dollar_switchexpr, switchStatement, tree, c))
+                          .collect(List.collector());
+        if (tree.cases.stream().noneMatch(c -> c.pats.isEmpty())) {
+            JCThrow thr = make.Throw(makeNewClass(syms.incompatibleClassChangeErrorType,
+                                                  List.nil()));
+            JCCase c = make.Case(JCCase.STATEMENT, List.nil(), List.of(thr), null);
+            switchStatement.cases = switchStatement.cases.append(c);
+        }
+
+        stmtList.append(translate(switchStatement));
+
+        result = make.LetExpr(stmtList.toList(), make.Ident(dollar_switchexpr))
+                     .setType(dollar_switchexpr.type);
     }
+        //where:
+        private JCCase convertCase(VarSymbol dollar_switchexpr, JCSwitch switchStatement,
+                                   JCSwitchExpression switchExpr, JCCase c) {
+            make.at(c.pos());
+            ListBuffer<JCStatement> statements = new ListBuffer<>();
+            statements.addAll(new TreeTranslator() {
+                @Override
+                public void visitLambda(JCLambda tree) {}
+                @Override
+                public void visitClassDef(JCClassDecl tree) {}
+                @Override
+                public void visitMethodDef(JCMethodDecl tree) {}
+                @Override
+                public void visitBreak(JCBreak tree) {
+                    if (tree.target == switchExpr) {
+                        tree.target = switchStatement;
+                        JCExpressionStatement assignment =
+                                make.Exec(make.Assign(make.Ident(dollar_switchexpr),
+                                                      translate(tree.value))
+                                              .setType(dollar_switchexpr.type));
+                        result = make.Block(0, List.of(assignment,
+                                                       tree));
+                        tree.value = null;
+                    } else {
+                        result = tree;
+                    }
+                }
+            }.translate(c.stats));
+            return make.Case(JCCase.STATEMENT, c.pats, statements.toList(), null);
+        }
 
     public void visitNewArray(JCNewArray tree) {
         tree.elemtype = translate(tree.elemtype);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MatchBindingsComputer.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MatchBindingsComputer.java	Tue Sep 11 12:40:55 2018 +0200
@@ -34,7 +34,6 @@
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCBinary;
 import com.sun.tools.javac.tree.JCTree.JCConditional;
-import com.sun.tools.javac.tree.JCTree.JCLiteralPattern;
 import com.sun.tools.javac.tree.JCTree.JCUnary;
 import com.sun.tools.javac.tree.JCTree.JCBindingPattern;
 import com.sun.tools.javac.tree.TreeScanner;
@@ -64,11 +63,6 @@
     }
 
     @Override
-    public void visitLiteralPattern(JCLiteralPattern tree) {
-        //noop
-    }
-
-    @Override
     public void visitBinary(JCBinary tree) {
         switch (tree.getTag()) {
             case AND:
@@ -193,9 +187,9 @@
         }
         return bindings;
     }
-    
+
     public static class BindingSymbol extends VarSymbol {
-        
+
         public BindingSymbol(Name name, Type type, Symbol owner) {
             super(Flags.FINAL | Flags.HASINIT | Flags.MATCH_BINDING, name, type, owner);
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java	Tue Sep 11 12:40:55 2018 +0200
@@ -32,25 +32,17 @@
 import com.sun.tools.javac.code.Types;
 import com.sun.tools.javac.comp.MatchBindingsComputer.BindingSymbol;
 import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.GenericSwitch.SwitchKind;
 import com.sun.tools.javac.tree.JCTree.JCAssign;
 import com.sun.tools.javac.tree.JCTree.JCBinary;
-import com.sun.tools.javac.tree.JCTree.JCBlock;
-import com.sun.tools.javac.tree.JCTree.JCBreak;
-import com.sun.tools.javac.tree.JCTree.JCCase;
 import com.sun.tools.javac.tree.JCTree.JCConditional;
-import com.sun.tools.javac.tree.JCTree.JCLiteralPattern;
 import com.sun.tools.javac.tree.JCTree.JCExpression;
 import com.sun.tools.javac.tree.JCTree.JCForLoop;
 import com.sun.tools.javac.tree.JCTree.JCIdent;
 import com.sun.tools.javac.tree.JCTree.JCIf;
 import com.sun.tools.javac.tree.JCTree.JCInstanceOf;
 import com.sun.tools.javac.tree.JCTree.JCLabeledStatement;
-import com.sun.tools.javac.tree.JCTree.JCLiteralPattern.LiteralPatternKind;
-import com.sun.tools.javac.tree.JCTree.JCMatches;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import com.sun.tools.javac.tree.JCTree.JCStatement;
-import com.sun.tools.javac.tree.JCTree.JCSwitch;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
 import com.sun.tools.javac.tree.JCTree.JCBindingPattern;
 import com.sun.tools.javac.tree.JCTree.JCWhileLoop;
@@ -71,10 +63,9 @@
 import com.sun.tools.javac.code.Symbol.MethodSymbol;
 import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
 import static com.sun.tools.javac.code.TypeTag.BOT;
-import static com.sun.tools.javac.tree.JCTree.Tag.SWITCH;
 
 /**
- * This pass translates pattern-matching constructs, such as __match and __matches.
+ * This pass translates pattern-matching constructs, such as instanceof <pattern>.
  */
 public class TransPatterns extends TreeTranslator {
 
@@ -136,60 +127,36 @@
         debugTransPatterns = Options.instance(context).isSet("debug.patterns");
     }
 
-    public void visitPatternTest(JCMatches tree) {
-        JCTree pattern = tree.pattern;
-        switch (pattern.getTag()) {
-            case BINDINGPATTERN:{
-                JCBindingPattern patt = (JCBindingPattern)pattern;
-                VarSymbol pattSym = patt.symbol;
-                Type tempType = tree.expr.type.hasTag(BOT) ?
-                        syms.objectType
-                        : tree.expr.type;
-                VarSymbol temp = new VarSymbol(pattSym.flags(),
-                        pattSym.name.append(names.fromString("$temp")),
-                        tempType,
-                        patt.symbol.owner);
-                JCExpression translatedExpr = translate(tree.expr);
-                Type castTargetType = types.boxedTypeOrType(pattSym.erasure(types));
-                if (patt.vartype == null || tree.expr.type.isPrimitive()) {
-                    result = make.Literal(BOOLEAN,1).setType(syms.booleanType);
-                } else {
-                    result = makeTypeTest(make.Ident(temp), make.Type(castTargetType));
-                }
+    @Override
+    public void visitTypeTest(JCInstanceOf tree) {
+        if (tree.pattern.hasTag(Tag.BINDINGPATTERN)) {
+            JCBindingPattern patt = (JCBindingPattern)tree.pattern;
+            VarSymbol pattSym = patt.symbol;
+            Type tempType = tree.expr.type.hasTag(BOT) ?
+                    syms.objectType
+                    : tree.expr.type;
+            VarSymbol temp = new VarSymbol(pattSym.flags(),
+                    pattSym.name.append(names.fromString("$temp")),
+                    tempType,
+                    patt.symbol.owner);
+            JCExpression translatedExpr = translate(tree.expr);
+            Type castTargetType = types.boxedTypeOrType(pattSym.erasure(types));
+            if (patt.vartype == null || tree.expr.type.isPrimitive()) {
+                result = make.Literal(BOOLEAN,1).setType(syms.booleanType);
+            } else {
+                result = makeTypeTest(make.Ident(temp), make.Type(castTargetType));
+            }
 
-                VarSymbol bindingVar = bindingContext.getBindingFor(patt.symbol);
-                if (bindingVar != null) {
-                    JCAssign fakeInit = (JCAssign)make.at(tree.pos).Assign(
-                            make.Ident(bindingVar), convert(make.Ident(temp), castTargetType)).setType(bindingVar.erasure(types));
-                    result = makeBinary(Tag.AND, (JCExpression)result,
-                            makeBinary(Tag.EQ, fakeInit, convert(make.Ident(temp), castTargetType)));
-                }
-                result = make.at(tree.pos).LetExpr(make.VarDef(temp, translatedExpr), (JCExpression)result).setType(syms.booleanType);
-                break;
+            VarSymbol bindingVar = bindingContext.getBindingFor(patt.symbol);
+            if (bindingVar != null) {
+                JCAssign fakeInit = (JCAssign)make.at(tree.pos).Assign(
+                        make.Ident(bindingVar), convert(make.Ident(temp), castTargetType)).setType(bindingVar.erasure(types));
+                result = makeBinary(Tag.AND, (JCExpression)result,
+                        makeBinary(Tag.EQ, fakeInit, convert(make.Ident(temp), castTargetType)));
             }
-            case LITERALPATTERN: {
-                JCLiteralPattern patt = (JCLiteralPattern)pattern;
-                if (patt.patternKind == LiteralPatternKind.TYPE) {
-                    result = makeTypeTest(tree.expr, patt.value);
-                } else {
-                    JCExpression ce = ((JCLiteralPattern) pattern).value;
-                    JCExpression lhs = ce.type.hasTag(BOT) ?
-                            tree.expr
-                            : make.TypeCast(make.Type(ce.type), tree.expr).setType(ce.type.baseType());
-                    if (!ce.type.hasTag(BOT) && tree.expr.type.isReference()) {
-                        result = translate(makeBinary(
-                                Tag.AND,
-                                makeTypeTest(tree.expr, make.Type(types.boxedTypeOrType(ce.type))),
-                                makeBinary(JCTree.Tag.EQ, lhs, ce)));
-                    } else {
-                        result = translate(makeBinary(JCTree.Tag.EQ, lhs, ce));
-                    }
-                }
-                break;
-            }
-            default: {
-                Assert.error("Cannot get here");
-            }
+            result = make.at(tree.pos).LetExpr(make.VarDef(temp, translatedExpr), (JCExpression)result).setType(syms.booleanType);
+        } else {
+            super.visitTypeTest(tree);
         }
     }
 
@@ -218,17 +185,6 @@
     }
 
     @Override
-    public void visitBreak(JCBreak tree) {
-        if (tree.target.hasTag(SWITCH) && ((JCSwitch) tree.target).kind == SwitchKind.MATCHING) {
-            Assert.checkNonNull(pendingMatchLabel);
-            tree.target = pendingMatchLabel;
-            result = tree;
-        } else {
-            super.visitBreak(tree);
-        }
-    }
-
-    @Override
     public void visitConditional(JCConditional tree) {
         bindingContext = new BasicBindingContext(
                 Attr.getMatchBindings(types, log, tree.cond, true)
@@ -277,48 +233,6 @@
     }
 
     @Override
-    public void visitSwitch(JCSwitch tree) {
-        if (tree.kind == SwitchKind.MATCHING) {
-            JCLabeledStatement prevMatchLabel = pendingMatchLabel;
-            try {
-                pendingMatchLabel = make.Labelled(names.fromString("match$" + tree.pos), null);
-                VarSymbol fallthroughSym = new VarSymbol(0, names.fromString("fallthrough$" + tree.pos), syms.booleanType, currentMethodSym);
-
-                JCStatement fallthroughInit = make.at(tree.pos).VarDef(fallthroughSym, make.Literal(BOOLEAN, 0).setType(syms.booleanType));
-
-                List<JCStatement> resultStatements = List.of(fallthroughInit);
-
-                for (JCCase clause : tree.cases) {
-                    Assert.check(clause.pats.size() <= 1);
-                    final JCExpression jcMatches = clause.pats.nonEmpty() ? make.PatternTest(tree.selector, clause.pats.head) : make.Literal(BOOLEAN, 1);
-                    jcMatches.setType(syms.booleanType);
-                    JCStatement body;
-                    List<JCStatement> stats = clause.stats;
-                    if (clause.completesNormally) {
-                        stats = stats.append(make.at(tree.pos).Exec(make.Assign(make.Ident(fallthroughSym), make.Literal(BOOLEAN, 1).setType(syms.booleanType)).setType(syms.booleanType)));
-                    }
-                    body = make.Block(0, stats);
-                    JCStatement translatedIf = translate(make.If(jcMatches, body, null));
-                    JCIf testStatement = translatedIf.hasTag(Tag.IF) ? (JCIf)translatedIf : (JCIf) ((JCBlock)translatedIf).stats.tail.head;
-
-                    testStatement.cond = makeBinary(Tag.OR,
-                            make.Ident(fallthroughSym),
-                            testStatement.cond);
-
-                    resultStatements = resultStatements.append(translatedIf);
-                }
-                pendingMatchLabel.body = make.Block(0, resultStatements);
-                result = pendingMatchLabel;
-            } finally {
-                pendingMatchLabel = prevMatchLabel;
-            }
-        } else {
-            super.visitSwitch(tree);
-        }
-    }
-
-
-    @Override
     public void visitMethodDef(JCMethodDecl tree) {
         MethodSymbol prevMethodSym = currentMethodSym;
         try {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransSwitches.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,276 +0,0 @@
-/*
- * Copyright (c) 2018, 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-package com.sun.tools.javac.comp;
-
-import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCBreak;
-import com.sun.tools.javac.tree.JCTree.JCCase;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
-import com.sun.tools.javac.tree.JCTree.JCExpression;
-import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
-import com.sun.tools.javac.tree.JCTree.JCLambda;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
-import com.sun.tools.javac.tree.JCTree.JCNewClass;
-import com.sun.tools.javac.tree.JCTree.JCPattern;
-import com.sun.tools.javac.tree.JCTree.JCStatement;
-import com.sun.tools.javac.tree.JCTree.JCSwitch;
-import com.sun.tools.javac.tree.JCTree.JCSwitchExpression;
-import com.sun.tools.javac.tree.JCTree.JCThrow;
-import com.sun.tools.javac.tree.TreeInfo;
-import com.sun.tools.javac.tree.TreeMaker;
-import com.sun.tools.javac.tree.TreeTranslator;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Names;
-
-/**
- * This pass translates JDK12 switch constructs, like cases with multiple patterns, rule switches
- * and switch expressions.
- */
-public class TransSwitches extends TreeTranslator {
-
-    protected static final Context.Key<TransSwitches> transSwitchesKey = new Context.Key<>();
-
-    public static TransSwitches instance(Context context) {
-        TransSwitches instance = context.get(transSwitchesKey);
-        if (instance == null)
-            instance = new TransSwitches(context);
-        return instance;
-    }
-
-    private Symtab syms;
-    private Resolve rs;
-    private Names names;
-    private TypeEnvs typeEnvs;
-    private Target target;
-
-    /** The current method symbol.
-     */
-    private MethodSymbol currentMethodSym;
-
-    /** Environment for symbol lookup, set by translateTopLevelClass.
-     */
-    private Env<AttrContext> attrEnv;
-
-    private TreeMaker make;
-
-    public TransSwitches(Context context) {
-        context.put(transSwitchesKey, this);
-        syms = Symtab.instance(context);
-        rs = Resolve.instance(context);
-        names = Names.instance(context);
-        typeEnvs = TypeEnvs.instance(context);
-        target = Target.instance(context);
-    }
-
-    public void visitSwitch(JCSwitch tree) {
-        //expand multiple label cases:
-        ListBuffer<JCCase> cases = new ListBuffer<>();
-
-        for (JCCase c : tree.cases) {
-            switch (c.pats.size()) {
-                case 0: //default
-                case 1: //single label
-                    cases.append(c);
-                    break;
-                default: //multiple labels, expand:
-                    //case C1, C2, C3: ...
-                    //=>
-                    //case C1:
-                    //case C2:
-                    //case C3: ...
-                    List<JCPattern> patterns = c.pats;
-                    while (patterns.tail.nonEmpty()) {
-                        JCCase cse = make_at(c.pos()).Case(JCCase.STATEMENT,
-                                                           List.of(patterns.head),
-                                                           List.nil(),
-                                                           null);
-                        cse.completesNormally = true;
-                        cases.append(cse);
-                        patterns = patterns.tail;
-                    }
-                    c.pats = patterns;
-                    cases.append(c);
-                    break;
-            }
-        }
-
-        for (JCCase c : cases) {
-            if (c.caseKind == JCCase.RULE && c.completesNormally) {
-                JCBreak b = make_at(c.pos()).Break(null);
-                b.target = tree;
-                c.stats = c.stats.append(b);
-            }
-        }
-
-        tree.selector = translate(tree.selector);
-        tree.cases = translateCases(cases.toList());
-
-        result = tree;
-    }
-
-    @Override
-    public void visitSwitchExpression(JCSwitchExpression tree) {
-        //translates switch expression to statement switch:
-        //switch (selector) {
-        //    case C: break value;
-        //    ...
-        //}
-        //=>
-        //(letexpr T exprswitch$;
-        //         switch (selector) {
-        //             case C: { exprswitch$ = value; break; }
-        //         }
-        //         exprswitch$
-        //)
-        VarSymbol dollar_switchexpr = new VarSymbol(Flags.FINAL|Flags.SYNTHETIC,
-                           names.fromString("exprswitch" + tree.pos + target.syntheticNameChar()),
-                           tree.type,
-                           currentMethodSym);
-
-        ListBuffer<JCStatement> stmtList = new ListBuffer<>();
-
-        stmtList.append(make.at(tree.pos()).VarDef(dollar_switchexpr, null).setType(dollar_switchexpr.type));
-        JCSwitch switchStatement = make.Switch(tree.selector, null);
-        switchStatement.kind = tree.kind;
-        switchStatement.cases =
-                tree.cases.stream()
-                          .map(c -> convertCase(dollar_switchexpr, switchStatement, tree, c))
-                          .collect(List.collector());
-        if (tree.cases.stream().noneMatch(c -> c.pats.isEmpty())) {
-            JCThrow thr = make.Throw(makeNewClass(syms.incompatibleClassChangeErrorType,
-                                                  List.nil()));
-            JCCase c = make.Case(JCCase.STATEMENT, List.nil(), List.of(thr), null);
-            switchStatement.cases = switchStatement.cases.append(c);
-        }
-
-        stmtList.append(translate(switchStatement));
-
-        result = make.LetExpr(stmtList.toList(), make.Ident(dollar_switchexpr))
-                     .setType(dollar_switchexpr.type);
-    }
-        //where:
-        private JCCase convertCase(VarSymbol dollar_switchexpr, JCSwitch switchStatement,
-                                   JCSwitchExpression switchExpr, JCCase c) {
-            make.at(c.pos());
-            ListBuffer<JCStatement> statements = new ListBuffer<>();
-            statements.addAll(new TreeTranslator() {
-                @Override
-                public void visitLambda(JCLambda tree) {}
-                @Override
-                public void visitClassDef(JCClassDecl tree) {}
-                @Override
-                public void visitMethodDef(JCMethodDecl tree) {}
-                @Override
-                public void visitBreak(JCBreak tree) {
-                    if (tree.target == switchExpr) {
-                        tree.target = switchStatement;
-                        JCExpressionStatement assignment =
-                                make.Exec(make.Assign(make.Ident(dollar_switchexpr),
-                                                      translate(tree.value))
-                                              .setType(dollar_switchexpr.type));
-                        result = make.Block(0, List.of(assignment,
-                                                       tree));
-                        tree.value = null;
-                    } else {
-                        result = tree;
-                    }
-                }
-            }.translate(c.stats));
-            JCCase res = make.Case(c.caseKind, c.pats, statements.toList(), null);
-            res.completesNormally = c.completesNormally;
-            return res;
-        }
-
-    public void visitClassDef(JCClassDecl tree) {
-        MethodSymbol currentMethodSymPrev = currentMethodSym;
-        Env<AttrContext> prevEnv = attrEnv;
-
-        try {
-            currentMethodSym = null;
-            attrEnv = typeEnvs.get(tree.sym);
-            if (attrEnv == null)
-                attrEnv = prevEnv;
-            super.visitClassDef(tree);
-        } finally {
-            attrEnv = prevEnv;
-            currentMethodSym = currentMethodSymPrev;
-        }
-    }
-
-    public void visitMethodDef(JCMethodDecl tree) {
-        MethodSymbol prevMethodSym = currentMethodSym;
-        try {
-            currentMethodSym = tree.sym;
-            super.visitMethodDef(tree);
-        } finally {
-            currentMethodSym = prevMethodSym;
-        }
-    }
-
-    public JCTree translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make) {
-        try {
-            this.make = make;
-            translate(cdef);
-        } finally {
-            // note that recursive invocations of this method fail hard
-            this.make = null;
-        }
-
-        return cdef;
-    }
-
-    //from Lower (probably generalize):
-    private DiagnosticPosition make_pos;
-
-    /** Equivalent to make.at(pos.getStartPosition()) with side effect of caching
-     *  pos as make_pos, for use in diagnostics.
-     **/
-    TreeMaker make_at(DiagnosticPosition pos) {
-        make_pos = pos;
-        return make.at(pos);
-    }
-
-    /** Make an attributed class instance creation expression.
-     *  @param ctype    The class type.
-     *  @param args     The constructor arguments.
-     */
-    JCNewClass makeNewClass(Type ctype, List<JCExpression> args) {
-        JCNewClass tree = make.NewClass(null,
-            null, make.QualIdent(ctype.tsym), args, null);
-        tree.constructor = rs.resolveConstructor(
-            make_pos, attrEnv, ctype, TreeInfo.types(args), List.nil());
-        tree.type = ctype;
-        return tree;
-    }
-}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Tue Sep 11 12:40:55 2018 +0200
@@ -567,19 +567,13 @@
         result = tree;
     }
 
-    public void visitPatternTest(JCMatches tree) {
-        tree.expr = translate(tree.expr, null);
-        tree.pattern = translate(tree.pattern, null);
-        result = tree;
-    }
-
     public void visitBindingPattern(JCBindingPattern tree) {
         if (tree.vartype != null) {
             tree.vartype = translate(tree.vartype, null);
         }
         result = tree;
     }
-    
+
     public void visitSwitchExpression(JCSwitchExpression tree) {
         Type selsuper = types.supertype(tree.selector.type);
         boolean enumSwitch = selsuper != null &&
@@ -790,7 +784,7 @@
 
     public void visitTypeTest(JCInstanceOf tree) {
         tree.expr = translate(tree.expr, null);
-        tree.clazz = translate(tree.clazz, null);
+        tree.pattern = translate(tree.pattern, null);
         result = tree;
     }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TreeDiffer.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TreeDiffer.java	Tue Sep 11 12:40:55 2018 +0200
@@ -577,7 +577,7 @@
     @Override
     public void visitTypeTest(JCInstanceOf tree) {
         JCInstanceOf that = (JCInstanceOf) parameter;
-        result = scan(tree.expr, that.expr) && scan(tree.clazz, that.clazz);
+        result = scan(tree.expr, that.expr) && scan(tree.pattern, that.pattern);
     }
 
     @Override
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/CRTable.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/CRTable.java	Tue Sep 11 12:40:55 2018 +0200
@@ -459,7 +459,7 @@
         public void visitTypeTest(JCInstanceOf tree) {
             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
             sr.mergeWith(csp(tree.expr));
-            sr.mergeWith(csp(tree.clazz));
+            sr.mergeWith(csp(tree.pattern));
             result = sr;
         }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Tue Sep 11 12:40:55 2018 +0200
@@ -1151,7 +1151,7 @@
             for (int i = 0; i < labels.length; i++) {
                 if (l.head.pats.nonEmpty()) {
                     Assert.check(l.head.pats.size() == 1);
-                    int val = ((Number)l.head.pats.head.constExpression().type.constValue()).intValue();
+                    int val = ((Number)l.head.pats.head.type.constValue()).intValue();
                     labels[i] = val;
                     if (val < lo) lo = val;
                     if (hi < val) hi = val;
@@ -2022,7 +2022,7 @@
     public void visitTypeTest(JCInstanceOf tree) {
         genExpr(tree.expr, tree.expr.type).load();
         setTypeAnnotationPositions(tree.pos);
-        code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
+        code.emitop2(instanceof_, makeRef(tree.pos(), tree.pattern.type));
         result = items.makeStackItem(syms.booleanType);
     }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Sep 11 12:40:55 2018 +0200
@@ -1561,13 +1561,7 @@
                 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))
+            if (shouldStop(CompileState.TRANSPATTERNS))
                 return;
 
             env.tree = TransPatterns.instance(context).translateTopLevelClass(env, env.tree, localMake);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Sep 11 12:40:55 2018 +0200
@@ -361,7 +361,6 @@
                 case DO:
                 case TRY:
                 case SWITCH:
-                case MATCH:
                 case RETURN:
                 case THROW:
                 case BREAK:
@@ -584,11 +583,6 @@
             Name name = token.name();
             nextToken();
             return name;
-        } else if (token.kind == MATCHES || token.kind == TokenKind.MATCH || token.kind == VAR) {
-            //'matches', 'match', 'var' are just identifiers when inside other expressions
-            Name name = token.name();
-            nextToken();
-            return name;
         } else {
             accept(IDENTIFIER);
             if (advanceOnErrors) {
@@ -742,25 +736,6 @@
         return term(EXPR);
     }
 
-
-    /** parses patterns.
-     */
-
-    public JCPattern parsePattern() {
-        int pos = token.pos;
-        if (token.kind == VAR) {
-            nextToken();
-            return toP(F.at(pos).BindingPattern(ident(), null));
-        } else {
-            JCExpression e = term(EXPR | TYPE | NOLAMBDA);
-            if (token.kind == IDENTIFIER) {
-                return toP(F.at(pos).BindingPattern(ident(), e));
-            } else {
-                return toP(F.at(pos).LiteralPattern(e));
-            }
-        }
-    }
-
     /**
      * parses (optional) type annotations followed by a type. If the
      * annotations are present before the type and are not consumed during array
@@ -911,7 +886,7 @@
 
     /*  Expression2Rest = {infixop Expression3}
      *                  | Expression3 instanceof Type
-     *                  | Expression3 matches Pattern
+     *                  | Expression3 instanceof Pattern
      *  infixop         = "||"
      *                  | "&&"
      *                  | "|"
@@ -924,7 +899,6 @@
      *                  | "*" | "/" | "%"
      */
     JCExpression term2Rest(JCExpression t, int minprec) {
-
         JCExpression[] odStack = newOdStack();
         Token[] opStack = newOpStack();
 
@@ -939,13 +913,12 @@
             if (token.kind == INSTANCEOF) {
                 int pos = token.pos;
                 nextToken();
-                JCExpression typ = parseType();
-                odStack[top] = F.at(pos).TypeTest(odStack[top], typ);
-            } else if (token.kind == MATCHES) {
-                int pos = token.pos;
-                nextToken();
-                JCPattern pat = parsePattern();
-                odStack[top] = F.at(pos).PatternTest(odStack[top], pat);
+                int patternPos = token.pos;
+                JCTree pattern = parseType();
+                if (token.kind == IDENTIFIER) {
+                    pattern = toP(F.at(patternPos).BindingPattern(ident(), pattern));
+                }
+                odStack[top] = F.at(pos).TypeTest(odStack[top], pattern);
             } else {
                 topOp = token;
                 nextToken();
@@ -970,18 +943,6 @@
         return t;
     }
     //where
-        Filter<TokenKind> matchFilter = tk -> {
-            switch (tk) {
-                case LPAREN:
-                case DOT:
-                case EQ:
-                    return false;
-                case MATCHES:
-                    return true;
-                default: return optag(tk) == Tag.NO_TAG;
-            }
-        };
-
         /** If tree is a concatenation of string literals, replace it
          *  by a single literal representing the concatenated string.
          */
@@ -1248,7 +1209,7 @@
                 t = insertAnnotationsToMostInner(expr, typeAnnos, false);
             }
             break;
-        case UNDERSCORE: case IDENTIFIER: case ASSERT: case ENUM: case MATCH: case MATCHES: case VAR:
+        case UNDERSCORE: case IDENTIFIER: case ASSERT: case ENUM:
             if (typeArgs != null) return illegal();
             if ((mode & EXPR) != 0 && (mode & NOLAMBDA) == 0 && peekToken(ARROW)) {
                 t = lambdaExpressionOrStatement(false, false, pos);
@@ -1446,14 +1407,14 @@
     private List<JCCase> switchExpressionStatementGroup() {
         ListBuffer<JCCase> caseExprs = new ListBuffer<>();
         int casePos = token.pos;
-        ListBuffer<JCPattern> pats = new ListBuffer<>();
+        ListBuffer<JCExpression> pats = new ListBuffer<>();
 
         if (token.kind == DEFAULT) {
             nextToken();
         } else {
             accept(CASE);
             while (true) {
-                pats.append(parsePattern());
+                pats.append(term(EXPR | NOLAMBDA));
                 if (token.kind != COMMA) break;
                 checkSourceLevel(Feature.SWITCH_MULTIPLE_CASE_LABELS);
                 nextToken();
@@ -1692,7 +1653,6 @@
                         case DOUBLELITERAL: case CHARLITERAL: case STRINGLITERAL:
                         case TRUE: case FALSE: case NULL:
                         case NEW: case IDENTIFIER: case ASSERT: case ENUM: case UNDERSCORE:
-                        case VAR: case MATCH: case MATCHES:
                         case BYTE: case SHORT: case CHAR: case INT:
                         case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID:
                             return ParensResult.CAST;
@@ -1703,21 +1663,6 @@
                 case ASSERT:
                 case ENUM:
                 case IDENTIFIER:
-                case VAR:
-                case MATCH: // ??
-                case MATCHES: // ??
-                    if (tk == IDENTIFIER && S.token(lookahead + 1).kind == MATCHES) {
-                        // Identifier, "matches" -> ! explicit lambda
-                        return ParensResult.PARENS;
-                    }
-                    if (peekToken(lookahead, MATCHES)) {
-                        Token next = S.token(lookahead + 1);
-                        if (next.kind == COMMA || next.kind == RPAREN) {
-                            // Identifier matches ','|')' -> explicit lambda
-                            return ParensResult.EXPLICIT_LAMBDA;
-                        }
-                        return ParensResult.PARENS;
-                    }
                     if (peekToken(lookahead, LAX_IDENTIFIER)) {
                         // Identifier, Identifier/'_'/'assert'/'enum' -> explicit lambda
                         return ParensResult.EXPLICIT_LAMBDA;
@@ -1818,8 +1763,7 @@
     }
 
     /** Accepts all identifier-like tokens */
-    protected Filter<TokenKind> LAX_IDENTIFIER = t -> t == IDENTIFIER || t == UNDERSCORE || t == ASSERT || t == ENUM ||
-            t == MATCHES || t == TokenKind.MATCH || t == VAR;
+    protected Filter<TokenKind> LAX_IDENTIFIER = t -> t == IDENTIFIER || t == UNDERSCORE || t == ASSERT || t == ENUM;
 
     enum ParensResult {
         CAST,
@@ -2577,13 +2521,6 @@
         case CONTINUE: case SEMI: case ELSE: case FINALLY: case CATCH:
         case ASSERT:
             return List.of(parseSimpleStatement());
-        case MATCH:
-            //is it a match statement?
-            if (isMatchStatement()) {
-                return List.of(parseSimpleStatement());
-            } else {
-                break;
-            }
         case MONKEYS_AT:
         case FINAL: {
             Comment dc = token.comment(CommentStyle.JAVADOC);
@@ -2631,33 +2568,7 @@
             return List.of(expr);
         }
     }
-
     //where
-        boolean isMatchStatement() {
-            //we need a LPAREN
-            if (!peekToken(LPAREN)) {
-                return false;
-            }
-            //then we scan through the contents of the '(...)', looking for a matching closing parens,
-            //followed by an '{'.
-            int depth = 1;
-            for (int lookahead = 2 ; ; lookahead++) {
-                TokenKind tk = S.token(lookahead).kind;
-                switch (tk) {
-                    case LPAREN:
-                        depth++;
-                        break;
-                    case RPAREN:
-                        depth--;
-                        if (depth == 0) {
-                            return S.token(lookahead + 1).kind == LBRACE;
-                        }
-                        break;
-                    case EOF:
-                        return false;
-                }
-            }
-        }
         private List<JCStatement> localVariableDeclarations(JCModifiers mods, JCExpression type) {
             ListBuffer<JCStatement> stats =
                     variableDeclarators(mods, type, new ListBuffer<>(), true);
@@ -2764,7 +2675,6 @@
             }
             return F.at(pos).Try(resources, body, catchers.toList(), finalizer);
         }
-        case MATCH:
         case SWITCH: {
             nextToken();
             JCExpression selector = parExpression();
@@ -2883,7 +2793,7 @@
 
     /** SwitchBlockStatementGroups = { SwitchBlockStatementGroup }
      *  SwitchBlockStatementGroup = SwitchLabel BlockStatements
-     *  SwitchLabel = CASE Pattern ":" | DEFAULT ":"
+     *  SwitchLabel = CASE ConstantExpression ":" | DEFAULT ":"
      */
     List<JCCase> switchBlockStatementGroups() {
         ListBuffer<JCCase> cases = new ListBuffer<>();
@@ -2911,9 +2821,9 @@
         switch (token.kind) {
         case CASE: {
             nextToken();
-            ListBuffer<JCPattern> pats = new ListBuffer<>();
+            ListBuffer<JCExpression> pats = new ListBuffer<>();
             while (true) {
-                pats.append(parsePattern());
+                pats.append(term(EXPR | NOLAMBDA));
                 if (token.kind != COMMA) break;
                 nextToken();
                 checkSourceLevel(Feature.SWITCH_MULTIPLE_CASE_LABELS);
@@ -4310,7 +4220,7 @@
     /** Return precedence of operator represented by token,
      *  -1 if token is not a binary operator. @see TreeInfo.opPrec
      */
-    int prec(TokenKind token) {
+    static int prec(TokenKind token) {
         JCTree.Tag oc = optag(token);
         return (oc != NO_TAG) ? TreeInfo.opPrec(oc) : -1;
     }
@@ -4330,7 +4240,7 @@
     /** Return operation tag of binary operator represented by token,
      *  No_TAG if token is not a binary operator.
      */
-    JCTree.Tag optag(TokenKind token) {
+    static JCTree.Tag optag(TokenKind token) {
         switch (token) {
         case BARBAR:
             return OR;
@@ -4394,8 +4304,6 @@
             return MOD_ASG;
         case INSTANCEOF:
             return TYPETEST;
-        case MATCHES:
-             return peekToken(matchFilter) ? PATTERNTEST : NO_TAG;
         default:
             return NO_TAG;
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java	Tue Sep 11 12:40:55 2018 +0200
@@ -145,8 +145,6 @@
         INT("int", Tag.NAMED),
         INTERFACE("interface"),
         LONG("long", Tag.NAMED),
-        MATCH("__match", Tag.NAMED),
-        MATCHES("__matches", Tag.NAMED),
         NATIVE("native"),
         NEW("new"),
         PACKAGE("package"),
@@ -165,7 +163,6 @@
         THROWS("throws"),
         TRANSIENT("transient"),
         TRY("try"),
-        VAR("var", Tag.NAMED),
         VOID("void", Tag.NAMED),
         VOLATILE("volatile"),
         WHILE("while"),
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Sep 11 12:40:55 2018 +0200
@@ -1323,9 +1323,6 @@
 compiler.err.unreachable.stmt=\
     unreachable statement
 
-compiler.err.pattern.dominated=\
-    the pattern is dominated by a preceding pattern
-
 compiler.err.not.exhaustive=\
     the switch expression does not cover all possible input values
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Tue Sep 11 12:40:55 2018 +0200
@@ -28,7 +28,6 @@
 import java.io.IOException;
 import java.io.StringWriter;
 import java.util.*;
-import java.util.stream.Collectors;
 
 import javax.lang.model.element.Modifier;
 import javax.lang.model.type.TypeKind;
@@ -153,18 +152,14 @@
          */
         SWITCH,
 
+        /** Case parts in switch statements/expressions, of type Case.
+         */
+        CASE,
+
         /** Switch expression statements, of type Switch.
          */
         SWITCH_EXPRESSION,
 
-        /** Case parts in switch statements/expressions, of type Case.
-         */
-        CASE,
-
-        /** Case parts in match statements, of type Clause.
-         */
-        CLAUSE,
-
         /** Synchronized statements, of type Synchonized.
          */
         SYNCHRONIZED,
@@ -241,14 +236,9 @@
          */
         TYPETEST,
 
-        /** Pattern test expression, of type PatternTest.
-         */
-        PATTERNTEST,
-
         /** Patterns.
          */
         BINDINGPATTERN,
-        LITERALPATTERN,
 
         /** Indexed array expressions, of type Indexed.
          */
@@ -1226,21 +1216,12 @@
         }
     }
 
-    public interface GenericSwitch {
-        public enum SwitchKind {
-            ORDINARY,
-            STRING,
-            ENUM,
-            MATCHING;
-        }
-    }
     /**
      * A "switch ( ) { }" construction.
      */
-    public static class JCSwitch extends JCStatement implements SwitchTree, GenericSwitch {
+    public static class JCSwitch extends JCStatement implements SwitchTree {
         public JCExpression selector;
         public List<JCCase> cases;
-        public SwitchKind kind;
         protected JCSwitch(JCExpression selector, List<JCCase> cases) {
             this.selector = selector;
             this.cases = cases;
@@ -1276,11 +1257,11 @@
         public static final CaseKind RULE = CaseKind.RULE;
         @SuppressWarnings("removal")
         public final CaseKind caseKind;
-        public List<JCPattern> pats;
+        public List<JCExpression> pats;
         public List<JCStatement> stats;
         public JCTree body;
         public boolean completesNormally;
-        protected JCCase(@SuppressWarnings("removal") CaseKind caseKind, List<JCPattern> pats,
+        protected JCCase(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pats,
                          List<JCStatement> stats, JCTree body) {
             Assert.checkNonNull(pats);
             Assert.check(pats.isEmpty() || pats.head != null);
@@ -1294,19 +1275,11 @@
 
         @Override @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() { return Kind.CASE; }
-        @DefinedBy(Api.COMPILER_TREE)
-        @Deprecated
-        public JCExpression getExpression() {
-            return pats.nonEmpty() ? pats.head.constExpression() : null;
-        }
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public JCExpression getExpression() { return pats.head; }
         @Override @DefinedBy(Api.COMPILER_TREE)
         @SuppressWarnings("removal")
-        public java.util.List<JCExpression> getExpressions() {
-            return pats.stream()
-                       .map(pat -> pat.constExpression())
-                       .collect(Collectors.toList());
-        }
-        public List<JCPattern> getPatterns() { return pats; }
+        public List<JCExpression> getExpressions() { return pats; }
         @Override @DefinedBy(Api.COMPILER_TREE)
         @SuppressWarnings("removal")
         public List<JCStatement> getStatements() {
@@ -1330,16 +1303,13 @@
         }
     }
 
-
-
     /**
      * A "switch ( ) { }" construction.
      */
     @SuppressWarnings("removal")
-    public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree, GenericSwitch {
+    public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree {
         public JCExpression selector;
         public List<JCCase> cases;
-        public SwitchKind kind;
         protected JCSwitchExpression(JCExpression selector, List<JCCase> cases) {
             this.selector = selector;
             this.cases = cases;
@@ -2146,10 +2116,10 @@
      */
     public static class JCInstanceOf extends JCExpression implements InstanceOfTree {
         public JCExpression expr;
-        public JCTree clazz;
-        protected JCInstanceOf(JCExpression expr, JCTree clazz) {
+        public JCTree pattern;
+        protected JCInstanceOf(JCExpression expr, JCTree pattern) {
             this.expr = expr;
-            this.clazz = clazz;
+            this.pattern = pattern;
         }
         @Override
         public void accept(Visitor v) { v.visitTypeTest(this); }
@@ -2157,7 +2127,13 @@
         @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() { return Kind.INSTANCE_OF; }
         @DefinedBy(Api.COMPILER_TREE)
-        public JCTree getType() { return clazz; }
+        public JCTree getType() { return pattern instanceof JCPattern ? pattern.hasTag(BINDINGPATTERN) ? ((JCBindingPattern) pattern).vartype : null : pattern; }
+
+        @Override @DefinedBy(Api.COMPILER_TREE)
+        public JCPattern getPattern() {
+            return pattern instanceof JCPattern ? (JCPattern) pattern : null;
+        }
+
         @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getExpression() { return expr; }
         @Override @DefinedBy(Api.COMPILER_TREE)
@@ -2171,52 +2147,22 @@
     }
 
     /**
-     * A pattern match test.
-     */
-    public static class JCMatches extends JCExpression
-            implements MatchesTree {
-        public JCExpression expr;
-        public JCPattern pattern;
-        protected JCMatches(JCExpression expr, JCPattern pattern) {
-            this.expr = expr;
-            this.pattern = pattern;
-        }
-        @Override
-        public void accept(Visitor v) { v.visitPatternTest(this); }
-
-        @DefinedBy(Api.COMPILER_TREE)
-        public Kind getKind() { return Kind.MATCHES; }
-        @DefinedBy(Api.COMPILER_TREE)
-        public JCPattern getPattern() { return pattern; }
-        @DefinedBy(Api.COMPILER_TREE)
-        public JCExpression getExpression() { return expr; }
-        @Override @DefinedBy(Api.COMPILER_TREE)
-        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
-            return v.visitMatches(this, d);
-        }
-        @Override
-        public Tag getTag() {
-            return PATTERNTEST;
-        }
-    }
-
-    /**
      * Pattern matching forms.
      */
     public static abstract class JCPattern extends JCTree
             implements PatternTree {
         public JCExpression constExpression() {
             return null;
-        }        
+        }
     }
 
     public static class JCBindingPattern extends JCPattern
             implements BindingPatternTree {
         public Name name;
         public BindingSymbol symbol;
-        public JCExpression vartype;   /** Null if var pattern */
-
-        protected JCBindingPattern(Name name, BindingSymbol symbol, JCExpression vartype) {
+        public JCTree vartype;
+
+        protected JCBindingPattern(Name name, BindingSymbol symbol, JCTree vartype) {
             this.name = name;
             this.symbol = symbol;
             this.vartype = vartype;
@@ -2254,60 +2200,6 @@
         }
     }
 
-    public static class JCLiteralPattern extends JCPattern
-            implements LiteralPatternTree {
-
-        public JCExpression value;
-        public LiteralPatternKind patternKind;
-
-        protected JCLiteralPattern(JCExpression value) {
-            Assert.checkNonNull(value);
-            this.value = value;
-        }
-
-        @DefinedBy(Api.COMPILER_TREE)
-        @Override
-        public Name getBinding() {
-            return null;
-        }
-
-        @Override
-        public void accept(Visitor v) {
-            v.visitLiteralPattern(this);
-        }
-
-        @DefinedBy(Api.COMPILER_TREE)
-        public Kind getKind() {
-            return Kind.LITERAL_PATTERN;
-        }
-
-        @DefinedBy(Api.COMPILER_TREE)
-        public JCExpression getValue() {
-            return value;
-        }
-
-        @Override
-        @DefinedBy(Api.COMPILER_TREE)
-        public <R, D> R accept(TreeVisitor<R, D> v, D d) {
-            return v.visitLiteralPattern(this, d);
-        }
-
-        @Override
-        public Tag getTag() {
-            return LITERALPATTERN;
-        }
-
-        @Override
-        public JCExpression constExpression() {
-            return value;
-        }
-
-        public enum LiteralPatternKind {
-            CONSTANTEXPRESSIONORNULL,
-            TYPE
-        }
-    }
-
     /**
      * An array selection
      */
@@ -3241,7 +3133,7 @@
         JCLabeledStatement Labelled(Name label, JCStatement body);
         JCSwitch Switch(JCExpression selector, List<JCCase> cases);
         JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases);
-        JCCase Case(@SuppressWarnings("removal") CaseKind caseKind, List<JCPattern> pat,
+        JCCase Case(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pat,
                     List<JCStatement> stats, JCTree body);
         JCSynchronized Synchronized(JCExpression lock, JCBlock body);
         JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
@@ -3278,9 +3170,7 @@
         JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
         JCTypeCast TypeCast(JCTree expr, JCExpression type);
         JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
-        JCMatches PatternTest(JCExpression expr, JCPattern clazz);
-        JCBindingPattern BindingPattern(Name name, JCExpression vartype);
-        JCLiteralPattern LiteralPattern(JCExpression cexp);
+        JCBindingPattern BindingPattern(Name name, JCTree vartype);
         JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
         JCFieldAccess Select(JCExpression selected, Name selector);
         JCIdent Ident(Name idname);
@@ -3344,9 +3234,7 @@
         public void visitBinary(JCBinary that)               { visitTree(that); }
         public void visitTypeCast(JCTypeCast that)           { visitTree(that); }
         public void visitTypeTest(JCInstanceOf that)         { visitTree(that); }
-        public void visitPatternTest(JCMatches that)         { visitTree(that); }
         public void visitBindingPattern(JCBindingPattern that) { visitTree(that); }
-        public void visitLiteralPattern(JCLiteralPattern that) { visitTree(that); }
         public void visitIndexed(JCArrayAccess that)         { visitTree(that); }
         public void visitSelect(JCFieldAccess that)          { visitTree(that); }
         public void visitReference(JCMemberReference that)   { visitTree(that); }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Tue Sep 11 12:40:55 2018 +0200
@@ -910,14 +910,6 @@
         }
     }
 
-    public void visitLiteralPattern(JCLiteralPattern patt) {
-        try {
-            print(patt.value);
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-
     public void visitSynchronized(JCSynchronized tree) {
         try {
             print("synchronized ");
@@ -1313,19 +1305,11 @@
             open(prec, TreeInfo.ordPrec);
             printExpr(tree.expr, TreeInfo.ordPrec);
             print(" instanceof ");
-            printExpr(tree.clazz, TreeInfo.ordPrec + 1);
-            close(prec, TreeInfo.ordPrec);
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-
-    public void visitPatternTest(JCMatches tree) {
-        try {
-            open(prec, TreeInfo.ordPrec);
-            printExpr(tree.expr, TreeInfo.ordPrec);
-            print(" matches ");
-            printPattern(tree.pattern);
+            if (tree.pattern instanceof JCPattern) {
+                printPattern(tree.pattern);
+            } else {
+                printExpr(tree.getType(), TreeInfo.ordPrec + 1);
+            }
             close(prec, TreeInfo.ordPrec);
         } catch (IOException e) {
             throw new UncheckedIOException(e);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Tue Sep 11 12:40:55 2018 +0200
@@ -146,7 +146,7 @@
     @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitCase(CaseTree node, P p) {
         JCCase t = (JCCase) node;
-        List<JCPattern> pats = copy(t.pats, p);
+        List<JCExpression> pats = copy(t.pats, p);
         List<JCStatement> stats = copy(t.stats, p);
         JCTree body = copy(t.body, p);
         return M.at(t.pos).Case(t.caseKind, pats, stats, body);
@@ -475,34 +475,18 @@
     public JCTree visitInstanceOf(InstanceOfTree node, P p) {
         JCInstanceOf t = (JCInstanceOf) node;
         JCExpression expr = copy(t.expr, p);
-        JCTree clazz = copy(t.clazz, p);
-        return M.at(t.pos).TypeTest(expr, clazz);
+        JCTree pattern = copy(t.pattern, p);
+        return M.at(t.pos).TypeTest(expr, pattern);
     }
 
     @DefinedBy(Api.COMPILER_TREE)
-    public JCTree visitMatches(MatchesTree node, P p) {
-        JCMatches t = (JCMatches) node;
-        JCExpression expr = copy(t.expr, p);
-        JCPattern pattern = copy(t.pattern, p);
-        return M.at(t.pos).PatternTest(expr, pattern);
-    }
-
-
-    @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitBindingPattern(BindingPatternTree node, P p) {
         JCBindingPattern t = (JCBindingPattern) node;
-        JCExpression vartype = copy(t.vartype, p);
+        JCTree vartype = copy(t.vartype, p);
         return M.at(t.pos).BindingPattern(t.name, vartype);
     }
 
     @DefinedBy(Api.COMPILER_TREE)
-    public JCTree visitLiteralPattern(LiteralPatternTree node, P p) {
-        JCLiteralPattern t = (JCLiteralPattern)node;
-        JCExpression value = copy(t.value, p);
-        return M.at(t.pos).LiteralPattern(value);
-    }
-    
-    @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitUnary(UnaryTree node, P p) {
         JCUnary t = (JCUnary) node;
         JCExpression arg = copy(t.arg, p);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Tue Sep 11 12:40:55 2018 +0200
@@ -454,8 +454,6 @@
                 return getStartPos(((JCArrayTypeTree) tree).elemtype);
             case TYPETEST:
                 return getStartPos(((JCInstanceOf) tree).expr);
-            case PATTERNTEST:
-                return getStartPos(((JCMatches) tree).expr);
             case ANNOTATED_TYPE: {
                 JCAnnotatedType node = (JCAnnotatedType) tree;
                 if (node.annotations.nonEmpty()) {
@@ -573,9 +571,7 @@
             case TYPECAST:
                 return getEndPos(((JCTypeCast) tree).expr, endPosTable);
             case TYPETEST:
-                return getEndPos(((JCInstanceOf) tree).clazz, endPosTable);
-            case PATTERNTEST:
-                return getEndPos(((JCMatches) tree).pattern, endPosTable);
+                return getEndPos(((JCInstanceOf) tree).pattern, endPosTable);
             case WHILELOOP:
                 return getEndPos(((JCWhileLoop) tree).body, endPosTable);
             case ANNOTATED_TYPE:
@@ -1012,8 +1008,7 @@
         case MUL:
         case DIV:
         case MOD: return mulPrec;
-        case TYPETEST:
-        case PATTERNTEST: return ordPrec;
+        case TYPETEST: return ordPrec;
         default: throw new AssertionError();
         }
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Tue Sep 11 12:40:55 2018 +0200
@@ -273,7 +273,7 @@
         return tree;
     }
 
-    public JCCase Case(@SuppressWarnings("removal") CaseKind caseKind, List<JCPattern> pats,
+    public JCCase Case(@SuppressWarnings("removal") CaseKind caseKind, List<JCExpression> pats,
                        List<JCStatement> stats, JCTree body) {
         JCCase tree = new JCCase(caseKind, pats, stats, body);
         tree.pos = pos;
@@ -441,24 +441,12 @@
         return tree;
     }
 
-    public JCMatches PatternTest(JCExpression expr, JCPattern patt) {
-        JCMatches tree = new JCMatches(expr, patt);
-        tree.pos = pos;
-        return tree;
-    }
-
-    public JCBindingPattern BindingPattern(Name name, JCExpression vartype) {
+    public JCBindingPattern BindingPattern(Name name, JCTree vartype) {
         JCBindingPattern tree = new JCBindingPattern(name, null, vartype);
         tree.pos = pos;
         return tree;
     }
 
-    public JCLiteralPattern LiteralPattern(JCExpression cexp) {
-        JCLiteralPattern tree = new JCLiteralPattern(cexp);
-        tree.pos = pos;
-        return tree;
-    }
-
     public JCArrayAccess Indexed(JCExpression indexed, JCExpression index) {
         JCArrayAccess tree = new JCArrayAccess(indexed, index);
         tree.pos = pos;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java	Tue Sep 11 12:40:55 2018 +0200
@@ -296,11 +296,6 @@
 
     public void visitTypeTest(JCInstanceOf tree) {
         scan(tree.expr);
-        scan(tree.clazz);
-    }
-
-    public void visitPatternTest(JCMatches tree) {
-        scan(tree.expr);
         scan(tree.pattern);
     }
 
@@ -309,10 +304,6 @@
             scan(tree.vartype);
     }
 
-    public void visitLiteralPattern(JCLiteralPattern tree) {
-        scan(tree.value);
-    }
-
     public void visitIndexed(JCArrayAccess tree) {
         scan(tree.indexed);
         scan(tree.index);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java	Tue Sep 11 12:40:55 2018 +0200
@@ -351,24 +351,12 @@
 
     public void visitTypeTest(JCInstanceOf tree) {
         tree.expr = translate(tree.expr);
-        tree.clazz = translate(tree.clazz);
-        result = tree;
-    }
-
-    public void visitPatternTest(JCMatches tree) {
-        tree.expr = translate(tree.expr);
         tree.pattern = translate(tree.pattern);
         result = tree;
     }
 
     public void visitBindingPattern(JCBindingPattern tree) {
-        if (tree.vartype != null) {
-            tree.vartype = translate(tree.vartype);
-        }
-        result = tree;
-    }
-
-    public void visitLiteralPattern(JCLiteralPattern tree) {
+        tree.vartype = translate(tree.vartype);
         result = tree;
     }
 
--- a/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Tue Sep 11 12:40:55 2018 +0200
@@ -210,7 +210,6 @@
         LONG(TokenKind.LONG, XEXPR1|XDECL1),  //  long
         SHORT(TokenKind.SHORT, XEXPR1|XDECL1),  //  short
         VOID(TokenKind.VOID, XEXPR1|XDECL1),  //  void
-        VAR(TokenKind.VAR, XEXPR1|XDECL1|XTERM),  //  var
 
         // Modifiers keywords
         ABSTRACT(TokenKind.ABSTRACT, XDECL1),  //  abstract
@@ -253,7 +252,6 @@
         THROW(TokenKind.THROW, XSTMT1|XSTART),  //  throw
         TRY(TokenKind.TRY, XSTMT1|XSTART),  //  try
         WHILE(TokenKind.WHILE, XSTMT1|XSTART),  //  while
-        MATCH(TokenKind.MATCH, XSTMT1|XSTART),  //  match
 
         // Statement keywords that we shouldn't see -- inside braces
         CASE(TokenKind.CASE, XSTMT|XSTART),  //  case
@@ -315,7 +313,6 @@
         LTLTEQ(TokenKind.LTLTEQ, XEXPR),  //  <<=
         GTGTEQ(TokenKind.GTGTEQ, XEXPR),  //  >>=
         GTGTGTEQ(TokenKind.GTGTGTEQ, XEXPR),  //  >>>=
-        MATCHES(TokenKind.MATCHES, XEXPR),
 
         // combined/processed kinds
         UNMATCHED(XERRO),
@@ -666,7 +663,6 @@
                         case BRACES:
                         case SEMI:
                             return Completeness.COMPLETE;
-                        case VAR:
                         case IDENTIFIER:
                             return isBracesNeeded
                                     ? Completeness.DEFINITELY_INCOMPLETE
--- a/test/langtools/jdk/jshell/CompletenessTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/jdk/jshell/CompletenessTest.java	Tue Sep 11 12:40:55 2018 +0200
@@ -80,7 +80,6 @@
         "i >= 0 && Character.isWhitespace(s.charAt(i))",
         "int.class",
         "String.class",
-        "var",
     };
 
     static final String[] complete_with_semi = new String[] {
@@ -123,7 +122,6 @@
         "int[] m = {1, 2}, n = null",
         "int[] m = {1, 2}, n",
         "int[] m = {1, 2}, n = {3, 4}",
-        "int var",
     };
 
     static final String[] considered_incomplete = new String[] {
@@ -188,8 +186,6 @@
         "int[] m = {1, 2},",
         "int[] m = {1, 2}, n = {3, 4},",
         "Map<String,",
-        "if (o __matches var",
-        "Map<String,",
         "switch (x) {",
         "var v = switch (x) {",
         "var v = switch (x) { case ",
--- a/test/langtools/tools/javac/api/TestGetElementReferenceData.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/api/TestGetElementReferenceData.java	Tue Sep 11 12:40:55 2018 +0200
@@ -36,7 +36,7 @@
         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*/) ;
+        if (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	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/diags/examples/MatchBindingExists.java	Tue Sep 11 12:40:55 2018 +0200
@@ -32,7 +32,7 @@
         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) {}
+        if (o1 instanceof String k && o2 instanceof Integer k) {}
+        if (o1 instanceof String k || o2 instanceof Integer k) {}
     }
 }
--- a/test/langtools/tools/javac/diags/examples/PatternBindingMayNotBeAssigned.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/diags/examples/PatternBindingMayNotBeAssigned.java	Tue Sep 11 12:40:55 2018 +0200
@@ -25,7 +25,7 @@
 
 class ResourceMayNotBeAssigned {
     void m(Object o) {
-        if (o __matches String s) {
+        if (o instanceof String s) {
             s = "";
         }
     }
--- a/test/langtools/tools/javac/diags/examples/PatternDominated.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * 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.pattern.dominated
-class PatternDominated {
-    void test(Object o) {
-        switch (o) {
-            case Integer i: //fall-through
-            case 42: break;
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/BindingsTest1.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/BindingsTest1.java	Tue Sep 11 12:40:55 2018 +0200
@@ -1,6 +1,6 @@
 /*
  * @test
- * @summary Basic tests for bindings from __matches
+ * @summary Basic tests for bindings from instanceof
  * @compile BindingsTest1.java
  * @run main BindingsTest1
  */
@@ -15,34 +15,34 @@
 
 
         // Test for (e matches P).T = { binding variables in P }
-        if (o1 __matches String s) {
+        if (o1 instanceof String s) {
             s.length();
         }
 
         // Test for e1 && e2.T = union(e1.T, e2.T)
-        if (o1 __matches String s && o2 __matches Integer in) {
+        if (o1 instanceof String s && o2 instanceof Integer in) {
             s.length();
             in.intValue();
         }
         // Test for e1 && e2.F = intersect(e1.F, e2.F)
-        if (!(o1 __matches String s) && !(o1 __matches String s)) {
+        if (!(o1 instanceof String s) && !(o1 instanceof String s)) {
 
         } else {
             s.length();
         }
 
         // test for e1&&e2 - include e1.T in e2
-        if (o1 __matches String s && s.length()>0) {
+        if (o1 instanceof String s && s.length()>0) {
             System.out.print("done");
         }
 
         // Test for (e1 || e2).T = intersect(e1.T, e2.T)
-        if (o1 __matches String s || o3 __matches String s){
+        if (o1 instanceof String s || o3 instanceof String s){
             System.out.println(s); // ?
         }
 
         // Test for (e1 || e2).F = union(e1.F, e2.F)
-        if (!(o1 __matches String s) || !(o3 __matches Integer in)){
+        if (!(o1 instanceof String s) || !(o3 instanceof Integer in)){
         } else {
             s.length();
             i.intValue();
@@ -50,62 +50,62 @@
 
         // Test for e1||e2 - include e1.F in e2
 
-        if (!(o1 __matches String s) || s.length()>0) {
+        if (!(o1 instanceof String s) || s.length()>0) {
             System.out.println("done");
         }
 
         // Test for (e1 ? e2 : e3).T contains intersect(e2.T, e3.T)
-        if (Ktrue() ? o2 __matches Integer x : o2 __matches Integer x) {
+        if (Ktrue() ? o2 instanceof Integer x : o2 instanceof Integer x) {
             x.intValue();
         }
 
         // Test for (e1 ? e2 : e3).T contains intersect(e1.T, e3.T)
-        if (o1 __matches String s ? true : o1 __matches String s) {
+        if (o1 instanceof String s ? true : o1 instanceof String s) {
             s.length();
         }
 
         // Test for (e1 ? e2 : e3).T contains intersect(e1.F, e2.T)
-        if (!(o1 __matches String s) ? (o1 __matches String s) : true) {
+        if (!(o1 instanceof String s) ? (o1 instanceof String s) : true) {
             s.length();
         }
 
         // Test for (e1 ? e2 : e3).F contains intersect(e2.F, e3.F)
-        if (Ktrue() ? !(o2 __matches Integer x) : !(o2 __matches Integer x)){
+        if (Ktrue() ? !(o2 instanceof Integer x) : !(o2 instanceof Integer x)){
         } else {
             x.intValue();
         }
 
         // Test for (e1 ? e2 : e3).F contains intersect(e1.T, e3.F)
-        if (o1 __matches String s ? true : !(o1 __matches String s)){
+        if (o1 instanceof String s ? true : !(o1 instanceof String s)){
         } else {
             s.length();
         }
 
         // Test for (e1 ? e2 : e3).F contains intersect(e1.F, e2.F)
-        if (!(o1 __matches String s) ? !(o1 __matches String s) : true){
+        if (!(o1 instanceof String s) ? !(o1 instanceof String s) : true){
         } else {
             s.length();
         }
 
         // Test for e1 ? e2: e3 - include e1.T in e2
-        if (o1 __matches String s ? s.length()>0 : false) {
+        if (o1 instanceof String s ? s.length()>0 : false) {
             System.out.println("done");
         }
 
         // Test for e1 ? e2 : e3 - include e1.F in e3
-        if (!(o1 __matches String s) ? false : s.length()>0){
+        if (!(o1 instanceof String s) ? false : s.length()>0){
             System.out.println("done");
         }
 
         // Test for (!e).T = e.F
 
-        if (!(!(o1 __matches String s) || !(o3 __matches Integer in))){
+        if (!(!(o1 instanceof String s) || !(o3 instanceof Integer in))){
             s.length();
             i.intValue();
         }
 
         // Test for (!e).F = e.T
-        if (!(o1 __matches String s)) {
+        if (!(o1 instanceof String s)) {
 
         } else {
             s.length();
--- a/test/langtools/tools/javac/patterns/BindingsTest2.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/BindingsTest2.java	Tue Sep 11 12:40:55 2018 +0200
@@ -12,103 +12,103 @@
         Object o3 = "there";
 
 
-        if (Ktrue() ? o2 __matches Integer x : o2 __matches String x) {
+        if (Ktrue() ? o2 instanceof Integer x : o2 instanceof String x) {
             x.intValue();
         }
-        if (Ktrue() ? o2 __matches Integer x : true) {
+        if (Ktrue() ? o2 instanceof Integer x : true) {
             x.intValue();
         }
 
-        if (o1 __matches String s ? true : true) {
+        if (o1 instanceof String s ? true : true) {
             s.length();
         }
-        if (o1 __matches String s ? true : o2 __matches Integer s) {
+        if (o1 instanceof String s ? true : o2 instanceof Integer s) {
             s.length();
         }
-        if (o1 __matches String s ? true : o2 __matches Integer i) {
+        if (o1 instanceof String s ? true : o2 instanceof Integer i) {
             s.length();
         }
 
         // Test for (e1 ? e2 : e3).T contains intersect(e1.F, e2.T)
-        if (!(o1 __matches String s) ? true : true) {
+        if (!(o1 instanceof String s) ? true : true) {
             s.length();
         }
-        if (!(o1 __matches String s) ? (o2 __matches Integer s) : true) {
+        if (!(o1 instanceof String s) ? (o2 instanceof Integer s) : true) {
             s.length();
         }
-        if (!(o1 __matches String s) ? (o2 __matches Integer i) : true) {
+        if (!(o1 instanceof String s) ? (o2 instanceof Integer i) : true) {
             s.length();
             i.intValue();
         }
-        if (!(o1 __matches String s) ? (o1 __matches String s2) : true) {
+        if (!(o1 instanceof String s) ? (o1 instanceof String s2) : true) {
             s.length();
             s2.length();
         }
 
 
         // Test for (e1 ? e2 : e3).F contains intersect(e2.F, e3.F)
-        if (Ktrue() ? !(o2 __matches Integer x) : !(o1 __matches String x)){
+        if (Ktrue() ? !(o2 instanceof Integer x) : !(o1 instanceof String x)){
         } else {
             x.intValue();
         }
-        if (Ktrue() ? !(o2 __matches Integer x) : !(o1 __matches String s)){
+        if (Ktrue() ? !(o2 instanceof Integer x) : !(o1 instanceof String s)){
         } else {
             x.intValue();
         }
-        if (Ktrue() ? !(o2 __matches Integer x) : !(o2 __matches Integer x1)){
+        if (Ktrue() ? !(o2 instanceof Integer x) : !(o2 instanceof Integer x1)){
         } else {
             x.intValue();
             x1.intValue();
         }
-        if (Ktrue() ? !(o2 __matches Integer x) : false){
+        if (Ktrue() ? !(o2 instanceof Integer x) : false){
         } else {
             x.intValue();
         }
 
         // Test for (e1 ? e2 : e3).F contains intersect(e1.T, e3.F)
-        if (o1 __matches String s ? true : !(o2 __matches Integer s)){
+        if (o1 instanceof String s ? true : !(o2 instanceof Integer s)){
         } else {
             s.length();
         }
-        if (o1 __matches String s ? true : !(o2 __matches Integer i)){
+        if (o1 instanceof String s ? true : !(o2 instanceof Integer i)){
         } else {
             s.length();
             i.intValue();
         }
-        if (o1 __matches String s ? true : !(o2 __matches String s1)){
+        if (o1 instanceof String s ? true : !(o2 instanceof String s1)){
         } else {
             s.length();
             s1.length();
         }
         // Test for (e1 ? e2 : e3).F contains intersect(e1.F, e2.F)
-        if (!(o1 __matches String s) ? !(o1 __matches String s1) : true){
+        if (!(o1 instanceof String s) ? !(o1 instanceof String s1) : true){
         } else {
             s.length();
             s1.length();
         }
-        if (!(o1 __matches String s) ? !(o2 __matches Integer s) : true){
+        if (!(o1 instanceof String s) ? !(o2 instanceof Integer s) : true){
         } else {
             s.length();
         }
-        if (!(o1 __matches String s) ? !(o2 __matches Integer i) : true){
+        if (!(o1 instanceof String s) ? !(o2 instanceof Integer i) : true){
         } else {
             s.length();
             i.intValue();
         }
 
         // Test for e1 ? e2: e3 - include e1.T in e2
-        if (o1 __matches String s ? false : s.length()>0) {
+        if (o1 instanceof String s ? false : s.length()>0) {
             System.out.println("done");
         }
-        if (o1 __matches String s ? false : s.intValue!=0) {
+        if (o1 instanceof String s ? false : s.intValue!=0) {
             System.out.println("done");
         }
 
         // Test for e1 ? e2 : e3 - include e1.F in e3
-        if (!(o1 __matches String s) ? s.length()>0 : false){
+        if (!(o1 instanceof String s) ? s.length()>0 : false){
             System.out.println("done");
         }
-        if (!(o1 __matches String s) ? s.intValue>0 : false){
+        if (!(o1 instanceof String s) ? s.intValue>0 : false){
             System.out.println("done");
         }
 
--- a/test/langtools/tools/javac/patterns/BindingsTest2.out	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/BindingsTest2.out	Tue Sep 11 12:40:55 2018 +0200
@@ -2,11 +2,11 @@
 BindingsTest2.java:16:13: compiler.err.cant.resolve.location: kindname.variable, x, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:19:13: compiler.err.cant.resolve.location: kindname.variable, x, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:23:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
-BindingsTest2.java:25:35: compiler.err.match.binding.exists.with.different.type
+BindingsTest2.java:25:36: compiler.err.match.binding.exists.with.different.type
 BindingsTest2.java:26:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:29:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:34:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
-BindingsTest2.java:36:38: compiler.err.match.binding.exists.with.different.type
+BindingsTest2.java:36:39: compiler.err.match.binding.exists.with.different.type
 BindingsTest2.java:37:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:40:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:41:13: compiler.err.cant.resolve.location: kindname.variable, i, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
@@ -18,7 +18,7 @@
 BindingsTest2.java:60:13: compiler.err.cant.resolve.location: kindname.variable, x, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:61:13: compiler.err.cant.resolve.location: kindname.variable, x1, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:65:13: compiler.err.cant.resolve.location: kindname.variable, x, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
-BindingsTest2.java:69:35: compiler.err.match.binding.exists.with.different.type
+BindingsTest2.java:69:36: compiler.err.match.binding.exists.with.different.type
 BindingsTest2.java:71:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:75:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:76:13: compiler.err.cant.resolve.location: kindname.variable, i, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
@@ -26,12 +26,12 @@
 BindingsTest2.java:81:13: compiler.err.cant.resolve.location: kindname.variable, s1, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:86:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:87:13: compiler.err.cant.resolve.location: kindname.variable, s1, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
-BindingsTest2.java:89:38: compiler.err.match.binding.exists.with.different.type
+BindingsTest2.java:89:39: compiler.err.match.binding.exists.with.different.type
 BindingsTest2.java:91:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:95:13: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 BindingsTest2.java:96:13: compiler.err.cant.resolve.location: kindname.variable, i, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
-BindingsTest2.java:100:45: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
-BindingsTest2.java:103:45: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
-BindingsTest2.java:108:40: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
-BindingsTest2.java:111:40: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
+BindingsTest2.java:100:46: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
+BindingsTest2.java:103:46: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
+BindingsTest2.java:108:41: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
+BindingsTest2.java:111:41: compiler.err.cant.resolve.location: kindname.variable, s, , , (compiler.misc.location: kindname.class, BindingsTest2, null)
 36 errors
--- a/test/langtools/tools/javac/patterns/BreakInsideMatch.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * @test
- * @summary testing break inside match clauses
- * @compile BreakInsideMatch.java
- * @run main BreakInsideMatch
- */
-
-public class BreakInsideMatch {
-    static int i = 42;
-
-    public static void test(Object o) {
-        switch (o) {
-            case String s:
-                i++;
-                break;
-            case Integer in:
-                i = 0;
-                break;
-            default:
-                i = 100;
-                break;
-        }
-        System.out.println(i);
-    }
-
-    public static void main(String[] args) {
-
-        System.out.println("< Tests started");
-
-        test("Hello");
-        test(42);
-        test(42.0);
-
-
-        System.out.println("> Tests completed");
-
-    }
-}
\ No newline at end of file
--- a/test/langtools/tools/javac/patterns/CastConversionMatch.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/CastConversionMatch.java	Tue Sep 11 12:40:55 2018 +0200
@@ -24,25 +24,17 @@
 /*
  * @test
  * @summary Match which involves a cast conversion
- * @compile CastConversionMatch.java
- * @run main CastConversionMatch
+ * @compile/fail/ref=CastConversionMatch.out -XDrawDiagnostics CastConversionMatch.java
  */
 
 public class CastConversionMatch {
     public static void main(String [] args) {
         Object o = 42;
-        if (o __matches int s) {
+        if (o instanceof int s) {
             System.out.println("Okay");
         } else {
             throw new AssertionError("broken");
         }
-        switch (o) {
-            case int i: {
-                System.out.println("Okay;");
-                break;
-            }
-            default: throw new AssertionError("broken");
-        }
         System.out.println(">Test complete");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/patterns/CastConversionMatch.out	Tue Sep 11 12:40:55 2018 +0200
@@ -0,0 +1,2 @@
+CastConversionMatch.java:33:26: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array)
+1 error
--- a/test/langtools/tools/javac/patterns/ConstantPatternTest1.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,440 +0,0 @@
-/*
- * @test
- * @summary Basic tests for constant patterns
- * @compile ConstantPatternTest1.java
- * @run main ConstantPatternTest1
- */
-
-public class ConstantPatternTest1 {
-    static int counter = 0;
-
-    public static void message() {
-        System.out.println("Test "+ counter);
-        counter++;
-    }
-
-    public static void fortyTwoTester(Object o) {
-        switch (o) {
-            case true: System.out.println("Boolean - wat no 42?"); break;
-            case 42f: System.out.println("42 float");break;
-            case '4': System.out.println("an f char"); break;
-            case 42.0: System.out.println("42.0"); break;
-            case 42: System.out.println("42"); break;
-            case "42": System.out.println("42 string"); break;
-            default: System.out.println("Something else"); break;
-        }
-    }
-    public static double valueOfD(){
-        return 41.0;
-    }
-
-    public static void main(String[] args) {
-
-        int i = 41;
-        i++;
-        final int constantInt = 42;
-
-
-        // Simple literal constant pattern
-        if (i __matches 42) {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        // Simple constant expression pattern
-        if (i __matches 41+1) {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        // Constant expression pattern using a final local
-        if (i __matches constantInt) {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        //--- Tests for match statement
-
-        // Simple literal constant pattern
-        switch (i){
-            case 42: {
-                message();
-            }
-        }
-
-        // Simple constant expression pattern
-        switch (i){
-            case 41+1: {
-                message();
-            }
-        }
-
-        // Constant expression pattern using a final local
-        switch (i){
-            case constantInt: {
-                message();
-            }
-        }
-
-        // Multiple constant pattern clauses
-
-        switch (i){
-            case 41: {
-                throw new AssertionError("Broken");
-            }
-            case 42: {
-                message();
-                break;
-            }
-        }
-
-        switch (i){
-            case 42: {
-                message();
-                break;
-            }
-            case 41: {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        switch (i){
-            case 42: {
-                message();
-                break;
-            }
-            case 41: {
-                throw new AssertionError("Broken");
-            }
-            default: {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        switch (i){
-            case 41: {
-                throw new AssertionError("Broken");
-            }
-            case 42: {
-                message();
-                break;
-            }
-            default: {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        // Multiple constant expression pattern clauses
-
-        switch (i){
-            case 41-1: {
-                throw new AssertionError("Broken");
-            }
-            case 42: {
-                message();
-                break;
-            }
-        }
-
-
-//--- DOUBLE TYPED CONSTANT EXPRESSIONS
-
-        double d = valueOfD();
-        d++;
-        final double constant = 42.0;
-        Object o = d;
-
-        //--- Tests for matches expression
-
-
-        // Simple literal constant pattern
-        if (d __matches 42.0) {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        // Simple constant expression pattern
-        if (d __matches 41.0+1.0) {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        // Constant expression pattern using a final local
-        if (d __matches constant) {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        //--- Tests for match statement
-
-        // Simple literal constant pattern
-        switch (d) {
-            case 42.0: {
-                message();
-            }
-        }
-
-        // Simple constant expression pattern
-        switch (d) {
-            case 41.0+1.0: {
-                message();
-                break;
-            }
-        }
-
-        // Constant expression pattern using a final local
-        switch (d) {
-            case constant: {
-                message();
-                break;
-            }
-        }
-
-        // Multiple constant pattern clauses
-
-        switch (d) {
-            case 41.0: {
-                throw new AssertionError("Broken");
-            }
-            case 42.0: {
-                message();
-                break;
-            }
-        }
-
-        switch (d) {
-            case 42.0: {
-                message();
-                break;
-            }
-            case 41.0: {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        switch (d) {
-            case 42.0: {
-                message();
-                break;
-            }
-            case 41.0: {
-                throw new AssertionError("Broken");
-            }
-            default: {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        switch (d) {
-            case 41.0: {
-                throw new AssertionError("Broken");
-            }
-            case 42.0: {
-                message();
-                break;
-            }
-            default: {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        // Multiple constant expression pattern clauses
-
-        switch (d) {
-            case 41.0-1.0: {
-                throw new AssertionError("Broken");
-            }
-            case 42.0: {
-                message();
-            }
-        }
-
-//--- STRING TYPED CONSTANT EXPRESSIONS ----
-
-        String s = "Hello";
-        final String hello = "Hello";
-
-        // Simple literal constant pattern
-        if (s __matches "Hello") {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        // Simple constant expression pattern
-        if (s __matches "Hell"+"o") {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        // Constant expression pattern using a final local
-        if (s __matches hello) {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        //--- Tests for match statement
-
-        // Simple literal constant pattern
-        switch (s) {
-            case "Hello": {
-                message();
-            }
-        }
-
-        // Simple constant expression pattern
-        switch (s) {
-            case "Hell"+"o": {
-                message();
-            }
-        }
-
-        // Constant expression pattern using a final local
-        switch (s) {
-            case hello: {
-                message();
-            }
-        }
-
-        // Multiple constant pattern clauses
-
-        switch (s) {
-            case "Hi": {
-                throw new AssertionError("Broken");
-            }
-            case "Hello": {
-                message();
-                break;
-            }
-        }
-
-        switch (s) {
-            case "Hello": {
-                message();
-                break;
-            }
-            case "Hi": {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        switch (s) {
-            case "Hello": {
-                message();
-                break;
-            }
-            case "Hi": {
-                throw new AssertionError("Broken");
-            }
-            default: {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        switch (s) {
-            case "Hi": {
-                throw new AssertionError("Broken");
-            }
-            case "Hello": {
-                message();
-                break;
-            }
-            default: {
-                throw new AssertionError("Broken");
-            }
-        }
-
-        // Multiple constant expression pattern clauses
-
-        switch (s) {
-            case "Hello"+"-": {
-                throw new AssertionError("Broken");
-            }
-            case "Hello": {
-                message();
-                break;
-            }
-        }
-
-        // Constant expression and a var pattern of the same type
-
-
-        switch(s){
-            case "Hello ": {
-                throw new AssertionError("Broken");
-            }
-            case String s1: {
-                message();
-            }
-        }
-
-        switch(s){
-            case "Hello": {
-                message();
-                break;
-            }
-            case String s1: {
-                throw new AssertionError("Broken");
-            }
-        }
-// ----- Constant expression patterns and reference typed expressions
-
-        Object obj = "Hello";
-
-        if (obj __matches "Hello") {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-        if (obj __matches null) {
-            throw new AssertionError("Broken");
-        }
-        obj = 42;
-        if (obj __matches 42) {
-            message();
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        if (obj __matches var x) {
-            if (obj __matches 42) {
-                message();
-            } else {
-                throw new AssertionError("Broken");
-            }
-        } else {
-            throw new AssertionError("Broken");
-        }
-
-        if (obj __matches 42) {
-            if (obj __matches var x) {
-                message();
-            }
-        }
-        if (obj __matches null) {
-            throw new AssertionError("Broken");
-        }
-        if (null __matches "Hello") {
-            throw new AssertionError("Broken");
-        }
-
-
-        fortyTwoTester(42);
-        fortyTwoTester(42.0);
-        fortyTwoTester("42");
-        fortyTwoTester(42L);
-        fortyTwoTester(true);
-        fortyTwoTester('4');
-        fortyTwoTester('x');
-        fortyTwoTester(0x2a);
-    }
-
-}
--- a/test/langtools/tools/javac/patterns/DefaultClauseMustBeLast.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @summary Ensure that in a matching switch statement, the default clause must be the last.
- * @compile/fail/ref=DefaultClauseMustBeLast.out -XDrawDiagnostics DefaultClauseMustBeLast.java
- */
-public class DefaultClauseMustBeLast {
-    public static void main(String[] args) {
-        Object o = (Long)42L;
-        switch (o) {
-            default: System.out.println("default"); break;
-            case Long l: System.out.println("It's a long"); break;
-        }
-        switch (o) {
-            case Long l: System.out.println("It's a long"); break;
-            default : System.out.println("default"); break;
-            case Double d: System.out.println("It's a double"); break;
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/DefaultClauseMustBeLast.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-DefaultClauseMustBeLast.java:11:13: compiler.err.pattern.dominated
-DefaultClauseMustBeLast.java:16:13: compiler.err.pattern.dominated
-2 errors
--- a/test/langtools/tools/javac/patterns/DuplicateBindingTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/DuplicateBindingTest.java	Tue Sep 11 12:40:55 2018 +0200
@@ -12,19 +12,10 @@
 
         if (args != null) {
             int s;
-            if (args[0] __matches String s) { // NOT OK. Redef same scope.
+            if (args[0] instanceof String s) { // NOT OK. Redef same scope.
             }
-            int k;
-            switch(args[0]) {
-                case String k: // NOT OK: Redef outer scope.
-                    break;
-                case var args: // NOT OK: Redef outer scope.
-                    break;
-                case Integer f: // OK to redef field, but BAD type.
-                    break;
-                default:
-                    break;
+            if (args[0] instanceof String f) { // OK to redef field.
             }
         }
     }
-}
\ No newline at end of file
+}
--- a/test/langtools/tools/javac/patterns/DuplicateBindingTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/DuplicateBindingTest.out	Tue Sep 11 12:40:55 2018 +0200
@@ -1,5 +1,2 @@
-DuplicateBindingTest.java:15:35: 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)
-4 errors
+DuplicateBindingTest.java:15:36: compiler.err.already.defined: kindname.variable, s, kindname.method, main(java.lang.String[])
+1 error
--- a/test/langtools/tools/javac/patterns/DuplicateConstantPatternTests.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @summary Checking for duplicate constant patterns test
- * @compile/fail/ref=DuplicateConstantPatternTests.out -XDrawDiagnostics DuplicateConstantPatternTests.java
- */
-
-public class DuplicateConstantPatternTests {
-
-    public static void main(String[] args) {
-        int i = 47;
-        switch (i) {
-            case 45: throw new AssertionError("broken");
-            case 45: throw new AssertionError("broken");
-        }
-
-        switch (i) {
-            case 45: throw new AssertionError("broken");
-            case 44+1: throw new AssertionError("broken");
-        }
-
-        switch (i) {
-            case 45: throw new AssertionError("broken");
-            case 46-1: throw new AssertionError("broken");
-            default: System.out.println("Default");
-        }
-
-        Object o = "hello";
-        switch (o) {
-            case null: throw new AssertionError("broken");
-            case null: throw new AssertionError("broken");
-        }
-    }
-
-}
--- a/test/langtools/tools/javac/patterns/DuplicateConstantPatternTests.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-DuplicateConstantPatternTests.java:13:13: compiler.err.duplicate.case.label
-DuplicateConstantPatternTests.java:18:13: compiler.err.duplicate.case.label
-DuplicateConstantPatternTests.java:23:13: compiler.err.duplicate.case.label
-DuplicateConstantPatternTests.java:30:13: compiler.err.duplicate.case.label
-4 errors
\ No newline at end of file
--- a/test/langtools/tools/javac/patterns/EnsureTypesOrderTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/EnsureTypesOrderTest.java	Tue Sep 11 12:40:55 2018 +0200
@@ -5,9 +5,9 @@
  * @compile/fail/ref=EnsureTypesOrderTest.out -XDrawDiagnostics EnsureTypesOrderTest.java
  */
 public class EnsureTypesOrderTest {
-    public static void main(String [] args) { 
-        if (args __matches String s) { 
-            System.out.println("Broken"); 
-        } 
-    } 
-}
\ No newline at end of file
+    public static void main(String [] args) {
+        if (args instanceof String s) {
+            System.out.println("Broken");
+        }
+    }
+}
--- a/test/langtools/tools/javac/patterns/ErasureDominationTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 8187428
- * @summary javac fails to reject dominated pattern with the same erased type
- * @compile/fail/ref=ErasureDominationTest.out -XDrawDiagnostics ErasureDominationTest.java
- */
-import java.util.ArrayList;
-
-public class ErasureDominationTest {
-    public static void main(String [] args) {
-        Object o = new ArrayList<ErasureDominationTest>();
-        switch (o) {
-            case ArrayList<Integer> ai:
-                System.out.println("ArrayList<Integer>");
-                break;
-            case ArrayList<String> as:
-                System.out.println("ArrayList<String>");
-                break;
-        }
-    }
-}
\ No newline at end of file
--- a/test/langtools/tools/javac/patterns/ErasureDominationTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-ErasureDominationTest.java:16:13: compiler.err.pattern.dominated
-- compiler.note.unchecked.filename: ErasureDominationTest.java
-- compiler.note.unchecked.recompile
-1 error
\ No newline at end of file
--- a/test/langtools/tools/javac/patterns/ExamplesFromProposal.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/ExamplesFromProposal.java	Tue Sep 11 12:40:55 2018 +0200
@@ -1,6 +1,6 @@
 /*
  * @test
- * @summary All example code from "Pattern Matching for Java" document, released April 2017 (with switch renamed as match)
+ * @summary All example code from "Pattern Matching for Java" document, released April 2017, adjusted to current state (no switches, etc)
  * @compile ExamplesFromProposal.java
  * @run main ExamplesFromProposal
  */
@@ -49,50 +49,48 @@
     }
 
     public static int eval(Node n) {
-        switch (n) {
-            case IntNode in: return in.value;
-            case NegNode nn: return -eval(nn.node);
-            case AddNode an: return eval(an.left) + eval(an.right);
-            case MulNode mn: return eval(mn.left) * eval(mn.right);
-        };
-        // should never happen
-        throw new AssertionError("broken");
+        if (n instanceof IntNode in) return in.value;
+        else if (n instanceof NegNode nn) return -eval(nn.node);
+        else if (n instanceof AddNode an) return eval(an.left) + eval(an.right);
+        else if (n instanceof MulNode mn) return eval(mn.left) * eval(mn.right);
+        else {
+            // should never happen
+            throw new AssertionError("broken");
+        }
     }
 
     public static String toString(Node n) {
-        switch (n) {
-            case IntNode in: return String.valueOf(in.value);
-            case NegNode nn: return "-"+eval(nn.node);
-            case AddNode an: return eval(an.left) + " + " + eval(an.right);
-            case MulNode mn: return eval(mn.left) + " * " + eval(mn.right);
-        };
-        // should never happen
-        throw new AssertionError("broken");
+        if (n instanceof IntNode in) return String.valueOf(in.value);
+        else if (n instanceof NegNode nn) return "-"+eval(nn.node);
+        else if (n instanceof AddNode an) return eval(an.left) + " + " + eval(an.right);
+        else if (n instanceof MulNode mn) return eval(mn.left) + " * " + eval(mn.right);
+        else {
+            // should never happen
+            throw new AssertionError("broken");
+        }
     }
 
     public static Node simplify(Node n) {
-        switch (n) {
-            case IntNode in:
-                return n;
-
-            case NegNode nn:
-                return new NegNode(simplify(nn.node));
-
-            case AddNode ad: switch (simplify(ad.left)) {
-                case IntNode intn:
-                    if (intn.value == 0)
-                        return simplify(ad.right);
-                    else
-                        return new AddNode(intn, simplify(ad.right));
-                default:
-                    return new AddNode(simplify(ad.left), simplify(ad.right));
+        if (n instanceof IntNode in) {
+            return n;
+        } else if (n instanceof NegNode nn) {
+            return new NegNode(simplify(nn.node));
+        } else if (n instanceof AddNode ad) {
+            n = simplify(ad.left);
+            if (n instanceof IntNode intn) {
+                if (intn.value == 0)
+                    return simplify(ad.right);
+                else
+                    return new AddNode(intn, simplify(ad.right));
+            } else {
+                return new AddNode(simplify(ad.left), simplify(ad.right));
             }
-
-            case MulNode mn:
-                return new MulNode(simplify(mn.left), simplify(mn.right));
+        } else if (n instanceof MulNode mn) {
+            return new MulNode(simplify(mn.left), simplify(mn.right));
+        } else {
+            //should never happen
+            throw new AssertionError("broken");
         }
-        //should never happen
-        throw new AssertionError("broken");
     }
 
     public static void testNode(Node n, int expected) {
@@ -103,7 +101,7 @@
     public static void main(String[] args) {
         Object x = new Integer(42);
 
-        if (x __matches Integer i) {
+        if (x instanceof Integer i) {
             // can use i here
             System.out.println(i.intValue());
         }
@@ -111,48 +109,31 @@
         Object obj = getSomething();
 
         String formatted = "unknown";
-        if (obj __matches Integer i) {
+        if (obj instanceof Integer i) {
             formatted = String.format("int %d", i);
         }
-        else if (obj __matches Byte b) {
+        else if (obj instanceof Byte b) {
             formatted = String.format("byte %d", b);
         }
-        else if (obj __matches Long l) {
+        else if (obj instanceof Long l) {
             formatted = String.format("long %d", l);
         }
-        else if (obj __matches Double d) {
+        else if (obj instanceof Double d) {
             formatted = String.format("double %f", d);
         }
-        else if (obj __matches String s) {
+        else if (obj instanceof String s) {
             formatted = String.format("String %s", s);
         }
         System.out.println(formatted);
 
-        formatted="";
-        switch (obj) {
-            case Integer i: formatted = String.format("int %d", i); break;
-            case Byte b:    formatted = String.format("byte %d", b); break;
-            case Long l:    formatted = String.format("long %d", l); break;
-            case Double d:  formatted = String.format("double %f", d); break;
-            case String s:  formatted = String.format("String %s", s); break;
-            default:        formatted = String.format("Something else "+ obj.toString()); break;
-        }
+        if (obj instanceof Integer i) formatted = String.format("int %d", i);
+        else if (obj instanceof Byte b) formatted = String.format("byte %d", b);
+        else if (obj instanceof Long l) formatted = String.format("long %d", l);
+        else if (obj instanceof Double d) formatted = String.format("double %f", d);
+        else if (obj instanceof String s) formatted = String.format("String %s", s);
+        else formatted = String.format("Something else "+ obj.toString());
         System.out.println(formatted);
 
-        // Rewritten from an expression switch
-        String s="";
-        short srt = 100;
-        int num = (int)srt;
-
-        switch (num) {
-            case 0: s = "zero"; break;
-            case 1: s = "one"; break;
-        //    case int i: s = "some other integer";
-            default: s = "not an Integer"; break;
-        }
-        System.out.println(s);
-
-
         Node zero = new IntNode(0);
         Node one = new IntNode(1);
         Node ft = new IntNode(42);
@@ -189,19 +170,19 @@
 
         x = "Hello";
 
-        if (x __matches String s1) {
+        if (x instanceof String s1) {
             System.out.println(s1);
         }
-        if (x __matches String s1 && s1.length() > 0) {
+        if (x instanceof String s1 && s1.length() > 0) {
             System.out.println(s1);
         }
-        if (x __matches String s1) {
+        if (x instanceof String s1) {
             System.out.println(s1 + " is a string");
         } else {
             System.out.println("not a string");
         }
 
-        if (!(x __matches String s1)) {
+        if (!(x instanceof String s1)) {
             System.out.println("not a string");
         } else {
             System.out.println(s1 + " is a string");
--- a/test/langtools/tools/javac/patterns/FlowAnalysisAndConstantPatterns.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @summary Stress test flow analysis with constant patterns
- * @compile/fail/ref=FlowAnalysisAndConstantPatterns.out -XDrawDiagnostics FlowAnalysisAndConstantPatterns.java
- */
-public class FlowAnalysisAndConstantPatterns {
-    public static int getInt(){
-        return 43;
-    }
-    public static void main(String[] args) {
-        int i = getInt();
-        switch (i) {
-            case int j: System.out.println("it's an int!"); break;
-            case 42: System.out.println("42!"); break;
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/FlowAnalysisAndConstantPatterns.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-FlowAnalysisAndConstantPatterns.java:14:13: compiler.err.pattern.dominated
-1 error
--- a/test/langtools/tools/javac/patterns/FlowAnalysisAndConstantPatterns2.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @summary Stress test flow analysis with constant patterns
- * @compile/fail/ref=FlowAnalysisAndConstantPatterns2.out -XDrawDiagnostics FlowAnalysisAndConstantPatterns2.java
- */
-public class FlowAnalysisAndConstantPatterns2 {
-    public static int getInt(){
-        return 42;
-    }
-    public static void main(String[] args) {
-
-        int i = getInt();
-        switch (i) {
-            case 42+1: System.out.println("42+1!");
-            case 43: System.out.println("43!");
-        }
-
-        switch (i) {
-            case 43: System.out.println("43!");
-            case 42+1: System.out.println("42+1!");
-        }
-
-        switch (i) {
-            case 43: System.out.println("43!");
-            case 42+1: System.out.println("42+1!");
-            case int j: System.out.println("it's an int!");
-        }
-
-        switch (i) {
-            case 43: System.out.println("43!");
-            case int j: System.out.println("it's an int!");
-            case 42+1: System.out.println("42+1!");
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/FlowAnalysisAndConstantPatterns2.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-FlowAnalysisAndConstantPatterns2.java:15:13: compiler.err.duplicate.case.label
-FlowAnalysisAndConstantPatterns2.java:20:13: compiler.err.duplicate.case.label
-FlowAnalysisAndConstantPatterns2.java:25:13: compiler.err.duplicate.case.label
-FlowAnalysisAndConstantPatterns2.java:32:13: compiler.err.duplicate.case.label
-4 errors
\ No newline at end of file
--- a/test/langtools/tools/javac/patterns/FlowAnalysisTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @summary Stress test flow analysis with patterns
- * @compile/fail/ref=FlowAnalysisTest.out -XDrawDiagnostics FlowAnalysisTest.java
- */
-
-class FlowAnalysisTest {
-    void foo(Object object) {
-        
-        switch (object) {
-            case Object o: break;
-            case String s: break;
-        }
-        switch (object) {
-            case var o: break;
-            case String s: break;
-            case "Hello" : break;
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/FlowAnalysisTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-FlowAnalysisTest.java:12:13: compiler.err.pattern.dominated
-FlowAnalysisTest.java:16:13: compiler.err.pattern.dominated
-FlowAnalysisTest.java:17:13: compiler.err.pattern.dominated
-3 errors
--- a/test/langtools/tools/javac/patterns/ImpossibleTypeTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/ImpossibleTypeTest.java	Tue Sep 11 12:40:55 2018 +0200
@@ -10,10 +10,10 @@
         int in = 42;
         Integer i = 42;
 
-        if (i __matches String s ) {
+        if (i instanceof String s ) {
             System.out.println("Broken");
         }
-        if (i __matches Undefined u ) {
+        if (i instanceof Undefined u ) {
             System.out.println("Broken");
         }
     }
--- a/test/langtools/tools/javac/patterns/ImpossibleTypeTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/ImpossibleTypeTest.out	Tue Sep 11 12:40:55 2018 +0200
@@ -1,3 +1,3 @@
 ImpossibleTypeTest.java:13:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String)
-ImpossibleTypeTest.java:16:25: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, ImpossibleTypeTest, null)
+ImpossibleTypeTest.java:16:26: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, ImpossibleTypeTest, null)
 2 errors
--- a/test/langtools/tools/javac/patterns/MatchBindingScopeTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/MatchBindingScopeTest.java	Tue Sep 11 12:40:55 2018 +0200
@@ -11,18 +11,18 @@
     static Object o2 = i;
 
     public static void main(String[] args) {
-    
-        if (o1 __matches String j && j.length() == 5) { // OK
+
+        if (o1 instanceof String j && j.length() == 5) { // OK
             System.out.println(j); // OK
         } else {
             System.out.println(j); // NOT OK
         }
 
         // NOT OK, name reused.
-        if (o1 __matches String j && o2 __matches Integer j) {
+        if (o1 instanceof String j && o2 instanceof Integer j) {
         }
 
-        if (o1 __matches String j && j.length() == 5 && o2 __matches Integer k && k == 42) { // OK
+        if (o1 instanceof String j && j.length() == 5 && o2 instanceof Integer k && k == 42) { // OK
             System.out.println(j); // OK
             System.out.println(k); // OK
         } else {
@@ -30,46 +30,37 @@
             System.out.println(k); // NOT OK
         }
 
-        if (o1 __matches String j || j.length() == 5) { // NOT OK
+        if (o1 instanceof String j || j.length() == 5) { // NOT OK
             System.out.println(j); // NOT OK
         }
 
-        if (o1 __matches String j || o2 __matches Integer j) { // NOT OK, types differ
+        if (o1 instanceof String j || o2 instanceof Integer j) { // NOT OK, types differ
             System.out.println(j); // NOT OK
         } else {
             System.out.println(j); // NOT OK.
         }
 
-        while (o1 __matches String j && j.length() == 5) { // OK
+        while (o1 instanceof String j && j.length() == 5) { // OK
             System.out.println(j); // OK
         }
 
-        while (o1 __matches String j || true) {
+        while (o1 instanceof String j || true) {
             System.out.println(j); // Not OK
         }
 
-        for (; o1 __matches String j; j.length()) { // OK
+        for (; o1 instanceof String j; j.length()) { // OK
             System.out.println(j); // OK
         }
 
-        for (; o1 __matches String j || true; j.length()) { // NOT OK
+        for (; o1 instanceof String j || true; j.length()) { // NOT OK
             System.out.println(j); // Not OK
         }
 
-        switch (o1) {
-            case String x:
-                    x.length(); // OK.
-                    break;
-            default:
-                    x.length(); // NOT OK.
-                    break;
-        }
-
-        int x = o1 __matches String j ?
+        int x = o1 instanceof String j ?
                       j.length() : // OK.
                       j.length();  // NOT OK.
 
-        x = !(o1 __matches String j) ?
+        x = !(o1 instanceof String j) ?
                       j.length() : // NOT OK.
                       j.length();  // OK.
     }
--- a/test/langtools/tools/javac/patterns/MatchBindingScopeTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/MatchBindingScopeTest.out	Tue Sep 11 12:40:55 2018 +0200
@@ -1,17 +1,16 @@
 MatchBindingScopeTest.java:18:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
-MatchBindingScopeTest.java:22:51: compiler.err.already.defined: kindname.variable, j, kindname.method, main(java.lang.String[])
-MatchBindingScopeTest.java:22:35: compiler.err.match.binding.exists
+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)
-MatchBindingScopeTest.java:33:38: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
+MatchBindingScopeTest.java:33:39: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
 MatchBindingScopeTest.java:34:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
-MatchBindingScopeTest.java:37:35: compiler.err.match.binding.exists.with.different.type
+MatchBindingScopeTest.java:37:36: compiler.err.match.binding.exists.with.different.type
 MatchBindingScopeTest.java:38:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
 MatchBindingScopeTest.java:40:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
 MatchBindingScopeTest.java:48:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
-MatchBindingScopeTest.java:55:47: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
+MatchBindingScopeTest.java:55:48: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
 MatchBindingScopeTest.java:56:32: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
-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
+MatchBindingScopeTest.java:61:23: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
+MatchBindingScopeTest.java:64:23: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, MatchBindingScopeTest, null)
+15 errors
--- a/test/langtools/tools/javac/patterns/MatchStmtTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * @test
- * @summary Basic positive test for match statement
- * @compile MatchStmtTest.java
- * @run main MatchStmtTest
- */
-
-public class MatchStmtTest {
-
-    static Integer i = 42;
-    static String output = "";
-
-    public static void main(String[] args) {
-
-        String s = "Hello";
-        Object o = s;
-
-        match(s);
-        match(i);
-
-        if (i != 152) {
-            throw new AssertionError("Broken");
-        }
-        if (!output.equals("String Integer"))
-            throw new AssertionError("Broken");
-
-    }
-    private static void match (Object o) {
-        switch (o) {
-            case String j:
-                i += 10;
-                output += "String ";
-                System.out.println("String length = " + j.length());
-                break;
-            case Integer k:
-                i += 100;
-                output += "Integer";
-                System.out.println("Int value = " + k);
-                break;
-            default:
-                i += 1000;
-                System.out.println("Broken !!!");
-                break;
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/MatchesToken.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/**
- * @test
- * @compile MatchesToken.java
- */
-public class MatchesToken {
-    public void test(Object o) {
-        final int __matches = 1;
-        boolean b1 = __matches __matches __matches;
-        boolean b2 = o __matches __matches;
-        boolean b3 = __matches __matches Integer i;
-        boolean b4 = (__matches __matches __matches) __matches true;
-    }
-
-    private void test() {
-        I1 i1 = (int __matches) -> {};
-        I2 i2 = (int __matches, int other) -> {};
-    }
-
-    interface I1 {
-        public void m(int i);
-    }
-
-    interface I2 {
-        public void m(int i1, int i2);
-    }
-}
-
--- a/test/langtools/tools/javac/patterns/NestingMatchAndMatches.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*
- * @test
- * @summary testing various permutations of matches insides match etc.
- * @compile NestingMatchAndMatches.java
- * @run main NestingMatchAndMatches
- */
-public class NestingMatchAndMatches {
-
-    public static void main(String[] args) {
-
-        Object o = "Hello";
-
-        //Nested matches
-        if ((o __matches String s) __matches boolean b) {
-            System.out.println("String!");
-        } else {
-            throw new AssertionError("broken");
-        }
-        if ((o __matches String s) __matches false) {
-            throw new AssertionError("broken");
-        } else {
-            System.out.println("String ");
-        }
-
-        if ((o __matches String s) __matches true) {
-            System.out.println("String!");
-        } else {
-            throw new AssertionError("broken");
-        }
-
-        boolean b = (o __matches String s) ? (s __matches "Hello") : false;
-
-        if (b) {
-            System.out.println("yes!");
-        } else {
-            throw new AssertionError("broken");
-        }
-
-        //matches inside a match
-        switch (o) {
-            case String s:
-                if (s __matches String t) {
-                    System.out.println(s+"-"+t);
-                }
-        }
-        switch (o) {
-            case String s:
-                if (o __matches Integer t) {
-                    System.out.println(s+"-"+t);
-                    throw new AssertionError("broken");
-                } else {
-                    System.out.println(s);
-                }
-        }
-
-        //match inside a match
-        Object o2 = o;
-
-        switch (o) {
-            case String s:
-                switch (o2) {
-                    case String t:
-                        System.out.println(s+"-"+t);
-                        break;
-                }
-                break;
-        }
-        switch (o) {
-            case String s:
-                switch (o2) {
-                    case String t:
-                        System.out.println(s+"-"+t);
-                        break;
-                    default:
-                        throw new AssertionError("broken");
-                }
-                break;
-        }
-
-        switch (o) {
-            case String s:
-                switch (o2) {
-                    case Integer in:
-                        throw new AssertionError("broken");
-                    case String t:
-                        System.out.println(s+"-"+t);
-                        break;
-                }
-                break;
-        }
-        switch (o) {
-            case String s:
-                switch (o2) {
-                    case Integer in:
-                        throw new AssertionError("broken");
-                    case String t:
-                        System.out.println(s+"-"+t);
-                        break;
-                    default:
-                        throw new AssertionError("broken");
-                }
-                break;
-        }
-        //matches inside a match inside a match
-
-        switch (o) {
-            case String s:
-                switch (o2) {
-                    case String t:
-                        if (t __matches String u) {
-                            System.out.println(s+"-"+t+"--"+u);
-                        } else {
-                            throw new AssertionError("broken");
-                        }
-                }
-                break;
-        }
-        System.out.println("> Test completed");
-    }
-}
--- a/test/langtools/tools/javac/patterns/NullPatternTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * @test
- * @summary Basic positive test for match statement
- * @compile NullPatternTest.java
- * @run main NullPatternTest
- */
-
-public class NullPatternTest {
-    public static void main(String[] args) {
-        Object o = "Hello world";
-        switch (o) {
-            case null: throw new AssertionError("broken");
-            case String s : System.out.println("String"); break;
-            default: throw new AssertionError("broken");
-        }
-
-        o = null;
-
-        switch (o) {
-            case null: System.out.println("null"); break;
-            default: throw new AssertionError("broken");
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/NullsInPatterns.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/NullsInPatterns.java	Tue Sep 11 12:40:55 2018 +0200
@@ -29,32 +29,22 @@
 import java.util.List;
 
 public class NullsInPatterns {
-    
+
     public static void main(String[] args) {
-        if (null __matches List t) {
+        if (null instanceof List t) {
             throw new AssertionError("broken");
         } else {
             System.out.println("null does not match List type pattern");
         }
-        if (null __matches List<Integer> l) {
+        if (null instanceof List<Integer> l) {
             throw new AssertionError("broken");
         } else {
             System.out.println("null does not match List<Integer> type pattern");
         }
-        if (null __matches List<?> l) {
+        if (null instanceof List<?> l) {
             throw new AssertionError("broken");
         } else {
             System.out.println("null does not match List<?> type pattern");
         }
-        if (null __matches var x) {
-            System.out.println("null matches var type pattern");
-        } else {
-            throw new AssertionError("broken");
-        }
-        if (null __matches null) {
-            System.out.println("null matches null constant pattern");
-        } else {
-            throw new AssertionError("broken");
-        }
     }
 }
--- a/test/langtools/tools/javac/patterns/PatternMatchPosTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/PatternMatchPosTest.java	Tue Sep 11 12:40:55 2018 +0200
@@ -61,7 +61,7 @@
             SourcePositions sp = trees.getSourcePositions();
             TreePath dataPath = trees.getPath(data);
             String text = dataPath.getCompilationUnit().getSourceFile().getCharContent(true).toString();
-            
+
             new TreeScanner<Void, Void>() {
                 boolean print;
                 @Override
@@ -77,19 +77,6 @@
                     scan(node.getElseStatement(), p);
                     return null;
                 }
-
-                @Override
-                public Void visitCase(CaseTree node, Void p) {
-                    boolean prevPrint = print;
-                    try {
-                        print = true;
-                        scan(node.getPatterns(), p);
-                    } finally {
-                        print = prevPrint;
-                    }
-                    scan(node.getStatements(), p);
-                    return null;
-                }
                 @Override
                 public Void scan(Tree tree, Void p) {
                     if (tree == null)
@@ -117,13 +104,6 @@
 
 class PatternMatchPosTestData {
     void data(Object o) {
-        if (o __matches 1) { }
-        if (o __matches var s) { }
-        if (o __matches String s) { }
-        switch (o) {
-            case 1: break;
-            case String s: break;
-            case var s: break;
-        }
+        if (o instanceof String s) { }
     }
 }
--- a/test/langtools/tools/javac/patterns/PatternMatchPosTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/PatternMatchPosTest.out	Tue Sep 11 12:40:55 2018 +0200
@@ -1,19 +1,5 @@
-(o __matches 1)
-o __matches 1
-o
-1
-1
-(o __matches var s)
-o __matches var s
-o
-var s
-(o __matches String s)
-o __matches String s
+(o instanceof String s)
+o instanceof String s
 o
 String s
 String
-1
-1
-String s
-String
-var s
--- a/test/langtools/tools/javac/patterns/PatternMatchTest1.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * @test
- * @summary Basic pattern switch test
- * @run main PatternMatchTest1
- */
-public class PatternMatchTest1 {
-
-    public static void main(String[] args) {
-
-        Integer i = 42;
-        String s = "Hello";
-        Object o = i;
-
-        switch (o) {
-            case var j: {
-                System.out.println("Matches a var!");
-                i++;
-                break;
-            }
-            default:
-                throw new AssertionError("Broken");
-        }
-
-        switch (o) {
-            case String j:
-                throw new AssertionError("Broken");
-            default:
-                System.out.println("Good");
-                i++;
-                break;
-        }
-        if (i != 44) {
-            throw new AssertionError("Broken");
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/PatternMatchTest2.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * @test
- * @summary Basic pattern switch test
- * @run main PatternMatchTest2
- */
-public class PatternMatchTest2 {
-
-    public static void main(String[] args) {
-
-        Integer i = 42;
-        String s = "Hello";
-        Object o = i;
-
-        switch (o) {
-            case Integer j: {
-                System.out.println("Matches a var!");
-                i++;
-                break;
-            }
-            default:
-                throw new AssertionError("Broken");
-        }
-
-        switch (o) {
-            case String j:
-                throw new AssertionError("Broken");
-            default:
-                System.out.println("Good");
-                i++;
-                break;
-        }
-        if (i != 44) {
-            throw new AssertionError("Broken");
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/PatternTypeTest1.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * @test
- * @summary Basic pattern test
- * @run main PatternTypeTest1
- */
-public class PatternTypeTest1 {
-
-    public static void main(String[] args) {
-
-        Integer i = 42;
-        String s = "Hello";
-        Object o = i;
-
-        if (o __matches var j) {
-            System.out.println("Match all");
-        } else {
-            throw new AssertionError("Broken");
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/PatternTypeTest2.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/PatternTypeTest2.java	Tue Sep 11 12:40:55 2018 +0200
@@ -34,7 +34,7 @@
         String s = "Hello";
         Object o = i;
 
-        if (o __matches Integer j) {
+        if (o instanceof Integer j) {
             System.out.println("It's an Integer");
         } else {
             throw new AssertionError("Broken");
--- a/test/langtools/tools/javac/patterns/PatternVariablesAreFinal.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/PatternVariablesAreFinal.java	Tue Sep 11 12:40:55 2018 +0200
@@ -6,19 +6,10 @@
 public class PatternVariablesAreFinal {
     public static void main(String[] args) {
         Object o = 32;
-        if (o __matches String s) {
+        if (o instanceof String s) {
             s = "hello again";
             System.out.println(s);
         }
-        switch (o) {
-            case Integer i: i++; break;
-        }
-        int i = 42;
-        i++;
-        switch (o) {
-            case String s: break;
-            case Integer s: s = null; break;
-        }
         System.out.println("test complete");
     }
 }
--- a/test/langtools/tools/javac/patterns/PatternVariablesAreFinal.out	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/PatternVariablesAreFinal.out	Tue Sep 11 12:40:55 2018 +0200
@@ -1,4 +1,2 @@
 PatternVariablesAreFinal.java:10:13: compiler.err.pattern.binding.may.not.be.assigned: s
-PatternVariablesAreFinal.java:14:29: compiler.err.pattern.binding.may.not.be.assigned: i
-PatternVariablesAreFinal.java:20:29: compiler.err.pattern.binding.may.not.be.assigned: s
-3 errors
+1 error
--- a/test/langtools/tools/javac/patterns/PatternVariablesAreFinal2.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/PatternVariablesAreFinal2.java	Tue Sep 11 12:40:55 2018 +0200
@@ -6,7 +6,7 @@
 public class PatternVariablesAreFinal2 {
     public static void main(String[] args) {
         Object o = "42";
-        if (o __matches String s) {
+        if (o instanceof String s) {
             new Object() {
                 void run() { System.err.println(s); }
             }.run();
--- a/test/langtools/tools/javac/patterns/PrimitiveSelectorTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * @test
- * @summary Test match behavior with primitive selector
- * @compile PrimitiveSelectorTest.java
- * @run main PrimitiveSelectorTest
- */
-
-public class PrimitiveSelectorTest {
-    public static void main(String [] args) {
-        boolean worked;
-        double d = 0.0;
-        switch (d) {
-            case double d2:
-                worked = true;
-                break;
-            default:
-                worked = false;
-                break;
-		}
-        if (!worked)
-            throw new AssertionError("Unexpected control flow");
-    }
-}
--- a/test/langtools/tools/javac/patterns/SwitchExpressionWithPatterns.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2018, 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 Basic test for patterns in switch expression
- * @compile --enable-preview -source 12 SwitchExpressionWithPatterns.java
- * @run main/othervm --enable-preview SwitchExpressionWithPatterns
- */
-
-import java.util.List;
-import java.util.function.ToIntFunction;
-
-public class SwitchExpressionWithPatterns {
-
-    public static void main(String[] args) {
-        List<ToIntFunction<Object>> tests = List.of(
-            SwitchExpressionWithPatterns::test1,
-            SwitchExpressionWithPatterns::test2,
-            SwitchExpressionWithPatterns::test3,
-            SwitchExpressionWithPatterns::test4
-        );
-        for (ToIntFunction<Object> f : tests) {
-            assertEquals(2, f.applyAsInt(41));
-            assertEquals(1, f.applyAsInt((Integer) 42));
-            assertEquals(3, f.applyAsInt((long) 0));
-            assertEquals(3, f.applyAsInt((float) 0));
-            assertEquals(4, f.applyAsInt((byte) 13));
-        }
-    }
-
-    private static int test1(Object in) {
-        int check = 0;
-        return switch (in) {
-            case 41: check++; //fall-through
-            case Integer i: check++; break check;
-            case Long l, Float f: break 3;
-            default: break 4;
-        };
-
-    }
-
-    private static int test2(Object in) {
-        int check = 0;
-        return switch (in) {
-            case 41 -> 2;
-            case Integer j -> { break 1; }
-            case Long l, Float f -> 3;
-            default -> { break 4; }
-        };
-    }
-
-    private static int test3(Object in) {
-        int check = 0;
-        switch (in) {
-            case 41: check++; //fall-through
-            case Integer j: check++; break;
-            case Long l, Float f: check = 3; break;
-            default: check = 4; break;
-        }
-        return check;
-    }
-
-    private static int test4(Object in) {
-        int check = 0;
-        switch (in) {
-            case 41 -> check = 2;
-            case Integer j -> { check = 1; }
-            case Long l, Float f -> check = 3;
-            default -> { check = 4; }
-        };
-        return check;
-    }
-
-    private static void assertEquals(int expected, int actual) {
-        if (expected != actual)
-            throw new AssertionError("Expected: " + expected + ", actual: " + actual);
-    }
-}
--- a/test/langtools/tools/javac/patterns/SwitchFallThrough1.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * @test
- * @summary Basic test for fall through in switch
- * @compile SwitchFallThrough1.java
- * @run main SwitchFallThrough1
- */
-public class SwitchFallThrough1 {
-
-    public static void main(String[] args) {
-        int check;
-        Object i = 42;
-
-        check = 0;
-
-        switch (i) {
-            case 41: check++; //fall-through
-            case Integer j: check++; break;
-        }
-
-        if (check != 1) {
-            throw new AssertionError("Incorrect check value: " + check);
-        }
-
-        check = 0;
-
-        switch (i) {
-            case 42: check++; //fall-through
-            case Integer j: check++; break;
-        }
-
-        if (check != 2) {
-            throw new AssertionError("Incorrect check value: " + check);
-        }
-
-        check = 0;
-
-        switch (i) {
-            case Integer j: check++; break;
-            case String  j: check = 45; break; //legal?
-        }
-
-        if (check != 1) {
-            throw new AssertionError("Incorrect check value: " + check);
-        }
-
-        check = 0;
-
-        switch (i) {
-            case 41: check++;
-            case Integer j: check++;
-            case "": check++; break;
-        }
-
-        if (check != 2) {
-            throw new AssertionError("Incorrect check value: " + check);
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/SwitchFallThrough2.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * @test
- * @summary Basic test for fall through in switch
- * @compile/fail/ref=SwitchFallThrough2.out -XDrawDiagnostics -XDshould-stop.at=FLOW SwitchFallThrough2.java
- */
-public class SwitchFallThrough2 {
-
-    public static void main(String[] args) {
-        Object i = 42;
-
-        switch (i) {
-            case Integer j: System.err.println(j); //fall-through
-            case 41: System.err.println(j); break;
-        }
-
-        switch (i) {
-            case 41: System.err.println(j); //fall-through
-            case Integer j: System.err.println(j); break;
-        }
-
-        switch (i) {
-            case Integer j: System.err.println(j); //fall-through
-            case String j: System.err.println(j); break;
-        }
-
-        switch (i) {
-            case Integer j:
-            case Integer j: break;
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/SwitchFallThrough2.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-SwitchFallThrough2.java:36:41: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, SwitchFallThrough2, null)
-SwitchFallThrough2.java:40:41: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, SwitchFallThrough2, null)
-SwitchFallThrough2.java:41:48: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, SwitchFallThrough2, null)
-SwitchFallThrough2.java:46:18: compiler.err.match.binding.exists.with.different.type
-SwitchFallThrough2.java:46:47: compiler.err.cant.resolve.location: kindname.variable, j, , , (compiler.misc.location: kindname.class, SwitchFallThrough2, null)
-SwitchFallThrough2.java:36:13: compiler.err.pattern.dominated
-SwitchFallThrough2.java:51:13: compiler.err.pattern.dominated
-7 errors
--- a/test/langtools/tools/javac/patterns/UncheckedWarningOnMatchesTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/UncheckedWarningOnMatchesTest.java	Tue Sep 11 12:40:55 2018 +0200
@@ -11,13 +11,8 @@
     public static void main(String [] args) {
 
         Object o = new ArrayList<UncheckedWarningOnMatchesTest>();
-        if (o __matches ArrayList<Integer> ai) {  // unchecked conversion
+        if (o instanceof ArrayList<Integer> ai) {  // unchecked conversion
             System.out.println("Blah");
         }
-        switch (o) {
-            case ArrayList<Integer> ai:  // unchecked conversion
-                System.out.println("ArrayList<Integer>");
-                break;
-        }
     }
-}
\ No newline at end of file
+}
--- a/test/langtools/tools/javac/patterns/UncheckedWarningOnMatchesTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ b/test/langtools/tools/javac/patterns/UncheckedWarningOnMatchesTest.out	Tue Sep 11 12:40:55 2018 +0200
@@ -1,5 +1,4 @@
 UncheckedWarningOnMatchesTest.java:14:13: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Object, java.util.ArrayList<java.lang.Integer>
-UncheckedWarningOnMatchesTest.java:17:16: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Object, java.util.ArrayList<java.lang.Integer>
 - compiler.err.warnings.and.werror
 1 error
-2 warnings
\ No newline at end of file
+1 warning
--- a/test/langtools/tools/javac/patterns/UnreachableCasesTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @summary Ensure that unreachable cases of a pattern switch are diagnosed.
- * @compile/fail/ref=UnreachableCasesTest.out -XDrawDiagnostics UnreachableCasesTest.java
- */
-
-public class UnreachableCasesTest {
-
-    class X {}
-    class Y extends X {}
-    class Z extends Y {}
-
-    public static void main(String [] args) {
-
-        switch (10) {
-            case Integer i:
-                System.out.println("i = " + i);
-                break;
-            default:
-                System.out.println("Unreachable");
-                break;
-        }
-
-        Y y = null;
-        switch (y) {
-            case Z z1: break;
-            case Y y1: break;
-            case X x1: break;
-        }
-    }
-}
\ No newline at end of file
--- a/test/langtools/tools/javac/patterns/UnreachableCasesTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-UnreachableCasesTest.java:28:13: compiler.err.pattern.dominated
-1 error
\ No newline at end of file
--- a/test/langtools/tools/javac/patterns/UnreachableStatementInMatchClause.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @summary Ensure that unreachable statements in match clauses are detected corrected.
- * @compile/fail/ref=UnreachableStatementInMatchClause.out -XDrawDiagnostics UnreachableStatementInMatchClause.java
- */
-public class UnreachableStatementInMatchClause {
-    public static void main(String[] args) {
-        Object o = "Hello world";
-        switch (o) {
-            case String s:
-                System.out.println(s);
-                break;
-                throw new AssertionError("oops");
-            default:
-                System.out.println("hmm");
-                break;
-                throw new AssertionError("oops once more");
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/UnreachableStatementInMatchClause.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-UnreachableStatementInMatchClause.java:13:17: compiler.err.unreachable.stmt
-UnreachableStatementInMatchClause.java:17:17: compiler.err.unreachable.stmt
-2 errors
--- a/test/langtools/tools/javac/patterns/VoidTest.java	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @summary Ensure that void expressions passed to switch statement are rejected
- * @compile/fail/ref=VoidTest.out -XDrawDiagnostics VoidTest.java
- */
-public class VoidTest {
-    public static void test() {
-        switch (test()) {
-        }
-    }
-}
--- a/test/langtools/tools/javac/patterns/VoidTest.out	Mon Sep 03 15:48:33 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-VoidTest.java:8:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: void, int)
-1 error