<div dir="ltr"><div dir="ltr">On Wed, Nov 26, 2025 at 7:02 AM Liam Miller-Cushon <<a href="mailto:cushon@google.com">cushon@google.com</a>> wrote:</div><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>As I understand it, the goal is to save memory in the case where end positions aren't needed.</div></div></blockquote><div><br></div><div>From what I remember, that was indeed the only counter-argument to what you're suggesting, and I'm also curious how significant the extra storage would be.</div><div><br></div><div>Rhetorical question: if space really is so precious, then why not get rid of all the "Tag" fields and just use <span style="font-family:monospace">instanceof</span> instead?</div><div><br></div><div>I'm assuming the original rationale for "Tag" fields was because instanceof was too slow? If so, is that still true? What if <span style="font-family:monospace">JCTree</span> was <span style="font-family:monospace">sealed</span>?</div><div><br></div><div>Perhaps such a change could be (mostly) automated, i.e., by doing this kind of transformation everywhere:</div><div><br></div><div><div style="margin-left:40px"><span style="font-family:monospace">--- i/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java</span><br><span style="font-family:monospace">+++ w/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java</span><br><span style="font-family:monospace">@@ -1925,8 +1925,8 @@ private ResultInfo caseLabelResultInfo(Type seltype) {</span><br><span style="font-family:monospace">         private static void addVars(List<JCStatement> stats, WriteableScope switchScope) {</span><br><span style="font-family:monospace">             for (;stats.nonEmpty(); stats = stats.tail) {</span><br><span style="font-family:monospace">                 JCTree stat = stats.head;</span><br><span style="font-family:monospace">-                if (stat.hasTag(VARDEF))</span><br><span style="font-family:monospace">-                    switchScope.enter(((JCVariableDecl) stat).sym);</span><br><span style="font-family:monospace">+                if (stat instanceof JCVariableDecl varDef)</span><br><span style="font-family:monospace">+                    switchScope.enter(varDef.sym);</span><br><span style="font-family:monospace">             }</span><br><span style="font-family:monospace">         }</span><br><span style="font-family:monospace">     // where</span><br><span style="font-family:monospace"></span></div><br></div><div>-Archie</div></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>