[PATCH] 8164327: Attr should implement method visitCase
Vicente-Arturo Romero-Zaldivar
vicente.romero at oracle.com
Tue Oct 4 13:58:36 UTC 2016
Hi Bernard,
Thanks for the patch. The issue is assigned to me and I already provided
a patch. It's not closed yet because we are waiting for other bigger
refactoring in the area.
Thanks,
Vicente
On 10/04/2016 09:08 AM, bsrbnd wrote:
> 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