You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/11/29 16:51:00 UTC
[jira] [Created] (GROOVY-9843) Line-wrapped assignment, typecast,
method call parsed as class literal assignment
Eric Milles created GROOVY-9843:
-----------------------------------
Summary: Line-wrapped assignment, typecast, method call parsed as class literal assignment
Key: GROOVY-9843
URL: https://issues.apache.org/jira/browse/GROOVY-9843
Project: Groovy
Issue Type: Bug
Components: parser
Affects Versions: 3.0.6, 2.5.13, 4.0.0-alpha-1
Reporter: Eric Milles
Consider the following:
{code:groovy}
def foo() {
}
@groovy.transform.TypeChecked
def bar() {
Number n = (java.lang.Number)
foo()
}
{code}
In our case "java.lang.Number" is quite a long type name and "foo" is quite a long method name, so we tried adding a newline between the typecast and the method call. This cahneg causes Groovy to parse the sequence as two statements: "Number n = Number.class" and "foo()".
I'm guessing that "(TypeName)" is very rarely a class literal, except for maybe in a map literal. Preference for a typecast seems needed.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)