groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: About type inference of method return value
Date Thu, 06 Sep 2018 10:56:20 GMT
Daniel, I am not 100% sure what you have in mind - the devil is always in
the detail. Can it be written as a normal type checking extension class?

Cheers, Paul.

On Wed, Sep 5, 2018 at 2:50 PM Daniel Sun <realbluesun@hotmail.com> wrote:

> Hi all,
>
>       I am going to refine the type inference of method return value, the
> methods should match one of the following charactristics:
> 1) `final`
> 2) `private`
> 3) `static`
> 4)  method defined in Script
>
>       The above methods will not be overrided and have exact method return
> type.
>
>       Any thoughts?
>
>       P.S. Currently the following code will fail to compile, but it's
> obiviously valid.
> ```
> @groovy.transform.CompileStatic
> class Test {
>     static m() {
>         return 'abc'
>     }
>
>     static a() {
>         return m().length()
>     }
>
>     static void main(String[] args) {
>         assert 3 == a()
>     }
> }
> ```
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
>

Mime
View raw message