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

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

codecov-commenter commented on PR #3290:
URL: https://github.com/apache/groovy/pull/3290#issuecomment-6775372760

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3290?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 74.4429%. Comparing base 
([`856b28a`](https://app.codecov.io/gh/apache/groovy/commit/856b28a961ca5964568c77034b98b6adde2e8f99?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`491ceeb`](https://app.codecov.io/gh/apache/groovy/commit/491ceebe7ff93358c7151667dd1643c2210ffbc1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3290/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/3290?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@              Coverage Diff              @@
   ##               master      #3290   +/-   ##
   =============================================
     Coverage     74.4429%   74.4429%           
     Complexity      44774      44774           
   =============================================
     Files            1702       1702           
     Lines          151891     151891           
     Branches        29091      29091           
   =============================================
     Hits           113072     113072           
   + Misses          28413      28411    -2     
   - Partials        10406      10408    +2     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3290?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/3290?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nVmlzaXRvci5qYXZh)
 | `87.9704% <100.0000%> (ø)` | |
   
   ... and [9 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3290/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> STC: a lambda result naming a type parameter of the calling method takes the 
> receiver's type argument for that name
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12757
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12757
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> When a generic method of a generic receiver is called with a lambda whose 
> result names a type parameter of the calling method, and the receiver's class 
> has a type parameter of the same name, static type checking replaces the 
> caller's type parameter with the receiver's type argument:
> {code:groovy}
> import java.util.concurrent.CompletableFuture
> import java.util.function.Function
> @groovy.transform.CompileStatic
> class C {
>     static <T> Optional<List<T>> wrap(Optional<String> value, T item) {
>         Optional<List<T>> result = value.map((String s) -> [item] as List<T>)
>         result
>     }
>     static <T> CompletableFuture<List<T>> 
> each(CompletableFuture<List<Object>> future, Function<Object, T> fn) {
>         CompletableFuture<List<T>> result = future.thenApply((List<Object> 
> values) -> values.collect { fn.apply(it) } as List<T>)
>         result
>     }
> }
> {code}
> {noformat}
> [Static type checking] - Incompatible generic argument types. Cannot assign 
> java.util.Optional<java.util.List<java.lang.String>> to: 
> java.util.Optional<java.util.List<T>>
> [Static type checking] - Incompatible generic argument types. Cannot assign 
> java.util.concurrent.CompletableFuture<java.util.List<java.util.List<java.lang.Object>>>
>  to: java.util.concurrent.CompletableFuture<java.util.List<T>>
> {noformat}
> {{map}}'s {{U}} is inferred from the lambda as {{List<T>}}, with the calling 
> method's {{T}}, and then {{Optional}}'s own {{T}}, here {{String}}, is 
> applied to the result. Groovy before GROOVY-12714 inferred the same wrong 
> type, but its assignment check accepted it. Renaming the calling method's 
> type parameter avoids the problem, and javac accepts the equivalent Java.
> {{StaticTypeCheckingVisitor#inferReturnTypeGenerics}} resolves the method's 
> type parameters from the arguments first, and then applies the receiver's 
> type arguments to the result. Applying the receiver's type arguments to the 
> declared return type first keeps them away from the types the arguments 
> supply. {{extractPlaceHoldersVisibleToDeclaration}} already leaves out the 
> method's own type parameters (GROOVY-10322), so a method type parameter that 
> shadows the class's is unaffected.
> Grails' {{AwaitablePromiseFactory}}, which calls 
> {{groovy.concurrent.Awaitable#then}} that way, no longer compiles against 
> GROOVY_6_0_X because of this.
> Pull request: https://github.com/apache/groovy/pull/3290



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to