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

ASF GitHub Bot commented on GROOVY-8917:
----------------------------------------

Github user danielsun1106 commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/837#discussion_r240445739
  
    --- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
    @@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
             long.class, Long.class,
             short.class, Short.class
         );
    +
    +    private static final Map<ClassNode, ClassNode> 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
    +            ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
    +            ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
    +            ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
    +            ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
    +            ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
    +            ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
    +            ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
    +            ClassHelper.short_TYPE, ClassHelper.Short_TYPE
    +    );
    --- End diff --
    
    @paulk-asert As we can see, the existing type mapping is Class to Class,  
but we need map ClassNode to ClassNode. Though we can convert ClassNode to 
Class and get the mapping result then convert the result to ClassNode, it is 
less efficient.
    
    
https://github.com/apache/groovy/blob/9cea59b95367c1d563e719ebeddcdecb58199750/src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java#L213


> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---------------------------------------------------------------
>
>                 Key: GROOVY-8917
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8917
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Daniel Sun
>            Assignee: Daniel Sun
>            Priority: Major
>
> {code:java}
>         import groovy.transform.CompileStatic
>         import java.util.stream.Collectors
>         import java.util.stream.Stream
>         
>         @CompileStatic
>         public class Test1 {
>             public static void main(String[] args) {
>                 p();
>             }
>             
>             public static void p() {
>                 // If we do not explicitly declare the type of parameter, STC 
> fails
>                 assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
>             }
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to