You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by gi...@apache.org on 2026/05/02 03:54:04 UTC

(groovy-dev-site) branch asf-site updated: 2026/05/02 03:54:00: Generated dev website from groovy-website@efd8190

This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-dev-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new f1056f1  2026/05/02 03:54:00: Generated dev website from groovy-website@efd8190
f1056f1 is described below

commit f1056f1b80af748db2a123be2b9235585f1abde1
Author: jenkins <bu...@apache.org>
AuthorDate: Sat May 2 03:54:00 2026 +0000

    2026/05/02 03:54:00: Generated dev website from groovy-website@efd8190
---
 search/search-index.json |  2 +-
 wiki/GEP-16.html         | 33 ++++++++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/search/search-index.json b/search/search-index.json
index e5b2d06..f4bf0f7 100644
--- a/search/search-index.json
+++ b/search/search-index.json
@@ -905,7 +905,7 @@
     {
         "id": "wiki/GEP-16.html",
         "title": "The Apache Groovy programming language - Developer docs - GEP-16",
-        "content": "The Apache Groovy programming language - Developer docs - GEP-16 Socialize Discuss on the mailing list Groovy on X Groovy on Bluesky Groovy on Mastodon Groovy on LinkedIn Events and conferences Source code on GitHub Report issues in Jira Stack Overflow questions Slack Community You are using an outdated browser. Please upgrade your browser to improve your experience. Apache Groovy&trade; Learn Documentation Download Support Contribute Ecosystem Blog posts Socialize GE [...]
+        "content": "The Apache Groovy programming language - Developer docs - GEP-16 Socialize Discuss on the mailing list Groovy on X Groovy on Bluesky Groovy on Mastodon Groovy on LinkedIn Events and conferences Source code on GitHub Report issues in Jira Stack Overflow questions Slack Community You are using an outdated browser. Please upgrade your browser to improve your experience. Apache Groovy&trade; Learn Documentation Download Support Contribute Ecosystem Blog posts Socialize GE [...]
         "url": "wiki/GEP-16.html",
         "site": "dev"
     },
diff --git a/wiki/GEP-16.html b/wiki/GEP-16.html
index 7498298..244b138 100644
--- a/wiki/GEP-16.html
+++ b/wiki/GEP-16.html
@@ -614,18 +614,45 @@ as a variable name. But, since <code>val</code> will be in the <code>identifier<
 <code>SemanticPredicates.isInvalidLocalVariableDeclaration()</code> to check
 what follows. <code>val = 42</code> is an assignment; <code>val x = 42</code> is a declaration.</p>
 </div>
+<div class="paragraph">
+<p>The remaining edge cases all share the same root: <code>val</code> (and <code>var</code>)
+are contextual keywords, so a few positions where they could be either
+keyword or identifier have to resolve one way. In summary:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Field named <code>val</code> (or <code>var</code>) before a method or constructor declaration&#8201;&#8212;&#8201;parsed as modifiers on the member that follows</p>
+</li>
+<li>
+<p><code>val</code> as a cast expression&#8201;&#8212;&#8201;<code>val as Type</code> reads <code>val</code> as the keyword</p>
+</li>
+<li>
+<p>Java class named <code>val</code>&#8201;&#8212;&#8201;the keyword wins in declared-type positions</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Each is detailed below with workarounds.</p>
+</div>
 <div class="sect3">
-<h4 id="_field_named_val_or_var_before_a_method_declaration">Field named <code>val</code> (or <code>var</code>) before a method declaration</h4>
+<h4 id="_field_named_val_or_var_before_a_method_or_constructor_declaration">Field named <code>val</code> (or <code>var</code>) before a method or constructor declaration</h4>
 <div class="paragraph">
 <p>A field declared as <code>def val</code> (or <code>def var</code>) immediately before a method
-declaration is misinterpreted by the parser as modifiers on the method.
-This is a pre-existing issue with <code>var</code> that equally applies to <code>val</code>:</p>
+or constructor declaration is misinterpreted by the parser as modifiers
+on the member that follows. This is a pre-existing issue with <code>var</code> that
+equally applies to <code>val</code>:</p>
 </div>
 <div class="listingblock">
 <div class="content">
 <pre class="prettyprint highlight"><code data-lang="groovy">class Foo {
     def val            // intended as field, but parsed as
     void doSomething() {} // modifiers for this method -&gt; error
+}
+
+class Bar {
+    def val            // intended as field, but parsed as
+    Bar() {}           // return type for a method named Bar -&gt; error
 }</code></pre>
 </div>
 </div>