changeset 56935:201fed33aa8f patterns

Post-merge fixes.
author jlahoda
date Mon, 15 Jul 2019 15:53:06 +0200
parents f3e3e9e47ade
children 22e1747208b6 1c6121460b51
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MatchBindingsComputer.java
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jul 15 12:50:29 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jul 15 15:53:06 2019 +0200
@@ -1603,7 +1603,7 @@
                                 }
                                 break;
                         }
-                        matchBindings = getMatchBindings(types, log, pat, true, matchBindings);
+                        matchBindings = matchBindingsComputer.getMatchBindings(pat, true, matchBindings);
                     }
                 } else {
                     if (hasDefault) {
@@ -1611,7 +1611,7 @@
                     } else {
                         hasDefault = true;
                     }
-                    matchBindings = getMatchBindings(types, log, null, true, matchBindings);
+                    matchBindings = matchBindingsComputer.getMatchBindings(null, true, matchBindings);
                 }
 
                 Env<AttrContext> caseEnv = bindingEnv(switchEnv, matchBindings);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MatchBindingsComputer.java	Mon Jul 15 12:50:29 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MatchBindingsComputer.java	Mon Jul 15 15:53:06 2019 +0200
@@ -71,6 +71,14 @@
         return bindings;
     }
 
+    public List<BindingSymbol> getMatchBindings(JCTree expression, boolean whenTrue, List<BindingSymbol> intersectWith) {
+        List<BindingSymbol> bindings = getMatchBindings(expression, whenTrue);
+        if (intersectWith != null) {
+            bindings = intersection(expression, intersectWith, bindings);
+        }
+        return bindings;
+    }
+
     @Override
     public void visitBindingPattern(JCBindingPattern tree) {
         bindings = whenTrue ? List.of(tree.symbol) : List.nil();