groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cazacu Mihai (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (GROOVY-7927) Static type checking
Date Sat, 03 Sep 2016 07:06:20 GMT

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

Cazacu Mihai edited comment on GROOVY-7927 at 9/3/16 7:05 AM:
--------------------------------------------------------------

No, it is not a regression. We recently switched (manually modified hundreds of classes) from
synchronous to async calls and we had to use a lot of this kind of code:

{code}
Function<Integer, Future<String>> asyncFct1 = { ... }
Function<String, Future<Integer>> asyncFct2 = { ... }
Function<Integer, Future<String>> asyncFct3 = { ... }
chain(asyncFct1, asyncFct2, asyncFct3) { ... } 
{code}

IntellijIdea did not find any syntax problems in code until we run it. If we remove _@CompileStatic_
annotation everything it works fine but I prefer do not do this.

About ETA, it will be nice to have it ASAP. Until then we can comment that _@CompileStatic_.
But, if you think that the fix of this issue will take some significant time, we will port
our code (only the affected one) to Java (because of the performance reason).

Thank you!


was (Author: cazacugmihai):
No, it is not a regression. We recently switched (manually modified hundreds of classes) from
synchronous to async calls and we had to use a lot of this kind of code:

{code}
Function<Integer, String> asyncFct1 = { ... }
Function<String, Integer> asyncFct2 = { ... }
Function<Integer, String> asyncFct3 = { ... }
chain(asyncFct1, asyncFct2, asyncFct3) { ... } 
{code}

IntellijIdea did not find any syntax problems in code until we run it. If we remove _@CompileStatic_
annotation everything it works fine but I prefer do not do this.

About ETA, it will be nice to have it ASAP. Until then we can comment that _@CompileStatic_.
But, if you think that the fix of this issue will take some significant time, we will port
our code (only the affected one) to Java (because of the performance reason).

Thank you!

> Static type checking
> --------------------
>
>                 Key: GROOVY-7927
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7927
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.7
>            Reporter: Cazacu Mihai
>
> I have a problem running this code: 
>   
> {code:title=Test.groovy|borderStyle=solid}
> import groovy.transform.CompileStatic 
> import java.util.function.Function 
>   
> @CompileStatic 
> class Test { 
>         static void main(String[] args) { 
>                // this code fails 
>                 Function<Integer, Integer> fct = { Integer n -> 
>                         -n 
>                 } 
>   
>                 // this one works but it is too verbose 
>                 // Function<Integer, Integer> fct = ({ Integer n -> 
>                 // -n 
>                 // } as Function<Integer, Integer>) 
>   
>                 println fct.apply(10) 
>         } 
> } 
> {code}
> Error: 
> {quote}
> Test.groovy: 9: [Static type checking] - Incompatible generic argument types. Cannot
assign java.util.function.Function <java.lang.Integer, groovy.lang.Closure> to: java.util.function.Function
<Integer, Integer>
>  @ line 9, column 36. 
>    	Function<Integer, Integer> fct = { Integer n -> 
>                                       ^ 
> 1 error 
> {quote}



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

Mime
View raw message