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/07/27 16:09:00 UTC

[jira] [Commented] (GROOVY-9659) Support auto type conversion for char type

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

Eric Milles commented on GROOVY-9659:
-------------------------------------

There is a similar issue with "1.0" giving an STC error for BigDecimal not converting to Double.  So there are a few of these user-friendly coercions that could be made.

> Support auto type conversion for char type
> ------------------------------------------
>
>                 Key: GROOVY-9659
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9659
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Priority: Major
>
> The following code will cause errors, which is not friendly to Java developers who are used to use single char {{'<char>'}} to represent character, so it's better support char type natively
> *Dynamic groovy:*
> {code:java}
> // groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.lang.Character(String)
> //@groovy.transform.CompileStatic
> def x() {
>      new Character('c')
> }
> x()
> {code}
> *Static groovy:*
> {code:java}
> // [Static type checking] - Cannot find matching method java.lang.Character#<init>(java.lang.String). Please check if the declared type is correct and if the method exists.
> @groovy.transform.CompileStatic
> def x() {
>      new Character('c')
> }
> x()
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)