[
https://issues.apache.org/jira/browse/GROOVY-9843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-9843:
--------------------------------
Description:
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 change 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.
was:
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.
> 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: 4.0.0-alpha-1, 2.5.13, 3.0.6
> Reporter: Eric Milles
> Priority: Major
>
> 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 change 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)