About `char` type in STC

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

About `char` type in STC

Daniel.Sun
Hi all,

       STC can not coerce string with single character to char when passing
parameters, e.g.
```
@groovy.transform.CompileStatic
class Test {
    static s(char delimiter) {}
   
    static void main(String[] args) {
        char a = 'x'   // works
        s(',' as char) // works
        s(',')  // [Static type checking] - Cannot find matching method
Test#s(java.lang.String).
    }
}

```

        I wonder it is designed on purpose or a bug?

Cheers,
Daniel.Sun




-----
Daniel Sun
Apache Groovy committer
Blog: http://blog.sunlan.me 
Twitter: @daniel_sun

--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Daniel Sun
Apache Groovy committer

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

Re: About `char` type in STC

Jochen Theodorou
On 08.09.2018 02:12, Daniel.Sun wrote:
> Hi all,
>
>         STC can not coerce string with single character to char when passing
> parameters, e.g.
[...]
>          I wonder it is designed on purpose or a bug?

I recall that being on purpose, sadly I do not recall why.

bye Jochen
Reply | Threaded
Open this post in threaded view
|

Re: About `char` type in STC

Daniel.Sun
Hi Jochen,

      It is in my TODO list too... Now I will remove the task.
      If somebody could tell me the reason, it would be great...

Cheers,
Daniel.Sun




-----
Daniel Sun
Apache Groovy committer
Blog: http://blog.sunlan.me 
Twitter: @daniel_sun

--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Daniel Sun
Apache Groovy committer

Blog: http://blog.sunlan.me
Twitter: @daniel_sun