[ 
https://issues.apache.org/jira/browse/GROOVY-7435?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14564564#comment-14564564
 ] 

Paul King commented on GROOVY-7435:
-----------------------------------

Actually, this has nothing to do (per se) with the Chinese characters but a 
return type efficient rule in the current parser which wants all return types 
to start with a capital letter, e.g.:
{code}
class x {
  public x y = null   // unexpected token public
  x z = null   // unexpected token x
  x foo() {}   // unexpected token x
}

def myVar = new x()
println myVar.y
{code}

Unfortunately, Chinese characters typically don't have case, so all Chinese 
only variants are going to fail currently. I think we have thought about 
removing this limitation at some point, currently prioritised for no earlier 
than moving to the new version of antlr.

I don't know whether using some upper-case ASCII or other language character 
would be a suitable workaround, e.g.:
{code}
class Ø对象 {
  private Ø对象 y = null
  Ø对象 对象
  Ø对象() { 对象 = this }
  Ø对象 foo() { println new Date() }
}

def myVar = new Ø对象()
println myVar.y
println myVar.对象
myVar.foo()
{code}

> Compilation failure when using non-ASCII chars as method return type
> --------------------------------------------------------------------
>
>                 Key: GROOVY-7435
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7435
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser
>    Affects Versions: 2.1.6, 2.4.3
>            Reporter: Rodolfo Cruz
>            Priority: Critical
>         Attachments: InternationalizationTest.groovy
>
>
> When trying to declare the return type of a method having non-ASCII 
> characters, such as in the following example:
> {code:title=InternationalizationTest.groovy|borderStyle=solid}
> @groovy.transform.ThreadInterrupt
> @groovy.transform.TypeChecked
> public class 对象 {
> public 对象 get对象()
> {
>     return new 对象()
> }
> }
> def myVar = new 对象()
> {code}
> the compilation fails with the message:
> {{unexpected token: public at line: 6, column: 1}}
> Those characters are valid according to the [official 
> documentation|http://docs.groovy-lang.org/latest/html/documentation/#_identifiers]
>  and using them in other places such as a class or variable declaration works 
> as expected.
> I'm attaching the example in order to provide an easy way to test the issue.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to