[
https://issues.apache.org/jira/browse/GROOVY-10355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18106771#comment-18106771
]
ASF GitHub Bot commented on GROOVY-10355:
-----------------------------------------
blackdrag commented on code in PR #2817:
URL: https://github.com/apache/groovy/pull/2817#discussion_r3833359952
##########
src/main/java/org/codehaus/groovy/control/ResolveVisitor.java:
##########
@@ -110,6 +110,15 @@ public class ResolveVisitor extends
ClassCodeExpressionTransformer {
* Placeholder name used for wildcard generic arguments.
*/
public static final String QUESTION_MARK = "?";
+ /**
+ * Node-metadata key under which a parser may store an explanatory suffix
for a
+ * {@link CastExpression} whose type it suspects may fail to resolve — for
example a
+ * cast produced by a grammar ambiguity. When the cast's type cannot be
resolved, the
+ * stored text is appended to the {@code unable to resolve class} error
message.
+ * The value is the complete hint text; this visitor attaches no meaning
to it.
+ */
+ @Internal
+ public static final String CAST_RESOLVE_HINT = "_CAST_RESOLVE_HINT";
Review Comment:
It looks better that way, but I am still not happy about this being such a
specialized mechanism for just one thing, but spanning so much across packages
and compilation phases. If we made this a more general mechanism and for
example call it "_RESOLVE_HINT", then it would look better, but is it better?
If it stays a single use case, then probably not. So I guess in combination
with @Internal this is ok. We can still change it later if we really want to.
> Compiler interpret variable name as class name when in parentheses.
> --------------------------------------------------------------------
>
> Key: GROOVY-10355
> URL: https://issues.apache.org/jira/browse/GROOVY-10355
> Project: Groovy
> Issue Type: Bug
> Components: parser-antlr4
> Affects Versions: 3.0.0, 4.0.0, 5.0.0
> Environment: JDK 11.0.12
> Reporter: Olof Asbrink
> Priority: Major
> Attachments: GROOVY-10355-Assessment.pdf, screenshot-1.png,
> screenshot-2.png
>
>
> This behavior seems unexpected:
> {code:java}
> String b = "B"
> System.out.println("A" + (b) + "C")
> {code}
> Throws this exception:
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> /tmp/repo1.gm: 2: unable to resolve class b
> @ line 2, column 26.
> System.out.println("A" + (b) + "C")
> ^{code}
> However these examples work:
> {code:java}
> String b = "B"
> System.out.println("A" + b + "C")
> {code}
> and
> {code:java}
> String b = "B"
> System.out.println("A" + (b))
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)