changeset 52359:17179e37aa12 patterns-stage-1

Must do a postattr/preflow before calling into Flow to determine liveness.
author jlahoda
date Tue, 11 Sep 2018 14:18:44 +0200
parents 9eb968074157
children c773d57ab8db
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Sep 11 12:42:39 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Sep 11 14:18:44 2018 +0200
@@ -1938,6 +1938,7 @@
             thenEnv.info.scope.leave();
         }
 
+        preFlow(tree.thenpart);
         boolean aliveAfterThen = flow.aliveAfter(env, tree.thenpart, make);
         boolean aliveAfterElse;
         List<BindingSymbol> elseBindings = List.nil();
@@ -1951,6 +1952,7 @@
             } finally {
                 elseEnv.info.scope.leave();
             }
+            preFlow(tree.elsepart);
             aliveAfterElse = flow.aliveAfter(env, tree.elsepart, make);
         } else {
             aliveAfterElse = true;
@@ -1972,6 +1974,21 @@
         result = null;
     }
 
+        void preFlow(JCTree tree) {
+            new PostAttrAnalyzer() {
+                @Override
+                public void scan(JCTree tree) {
+                    if (tree == null ||
+                            (tree.type != null &&
+                            tree.type == Type.stuckType)) {
+                        //don't touch stuck expressions!
+                        return;
+                    }
+                    super.scan(tree);
+                }
+            }.scan(tree);
+        }
+
     public void visitExec(JCExpressionStatement tree) {
         //a fresh environment is required for 292 inference to work properly ---
         //see Infer.instantiatePolymorphicSignatureInstance()