[PATCH] 8164327: Attr should implement method visitCase
bsrbnd
bsrbnd at gmail.com
Tue Oct 4 13:08:19 UTC 2016
Hi,
Next is a suggestion for the refactoring of Attr.visitSwitch() using a
visitor method for the case statement conforming to issue 8164327
description.
The labels' handling still belongs to visitSwitch() while the case
statements are handled by the new visitCase() method.
All javac tests have been run and nothing seems to be broken...
Bernard
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -1320,14 +1320,7 @@
} else {
hasDefault = true;
}
- Env<AttrContext> caseEnv =
- switchEnv.dup(c, env.info.dup(switchEnv.info.scope.dup()));
- try {
- attribStats(c.stats, caseEnv);
- } finally {
- caseEnv.info.scope.leave();
- addVars(c.stats, switchEnv.info.scope);
- }
+ attribTree(c, switchEnv, statInfo);
}
result = null;
@@ -1336,6 +1329,18 @@
switchEnv.info.scope.leave();
}
}
+
+ @Override
+ public void visitCase(JCCase tree) {
+ Env<AttrContext> caseEnv =
+ env.dup(tree, env.info.dup(env.info.scope.dup()));
+ try {
+ attribStats(tree.stats, caseEnv);
+ } finally {
+ caseEnv.info.scope.leave();
+ addVars(tree.stats, env.info.scope);
+ }
+ }
// where
/** Add any variables defined in stats to the switch scope. */
private static void addVars(List<JCStatement> stats,
WriteableScope switchScope) {
More information about the compiler-dev
mailing list