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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2999?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 72.4327%. Comparing base 
([`8778bce`](https://app.codecov.io/gh/apache/groovy/commit/8778bce1a0da05b5bffe27f02819262c849f9d56?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`7347739`](https://app.codecov.io/gh/apache/groovy/commit/7347739ce485fcfa062ba094002aca248522fe66?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/2999/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/2999?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2999        +/-   ##
   ==================================================
   + Coverage     72.4290%   72.4327%   +0.0037%     
   - Complexity      40622      40635        +13     
   ==================================================
     Files            1643       1643                
     Lines          142686     142698        +12     
     Branches        26799      26803         +4     
   ==================================================
   + Hits           103346     103360        +14     
   + Misses          29830      29829         -1     
   + Partials         9510       9509         -1     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2999?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...us/groovy/classgen/asm/BinaryExpressionHelper.java](https://app.codecov.io/gh/apache/groovy/pull/2999?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2FBinaryExpressionHelper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9CaW5hcnlFeHByZXNzaW9uSGVscGVyLmphdmE=)
 | `89.3048% <100.0000%> (+0.1156%)` | :arrow_up: |
   | 
[...sc/StaticTypesMethodReferenceExpressionWriter.java](https://app.codecov.io/gh/apache/groovy/pull/2999?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesMethodReferenceExpressionWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc01ldGhvZFJlZmVyZW5jZUV4cHJlc3Npb25Xcml0ZXIuamF2YQ==)
 | `89.4587% <100.0000%> (+0.1215%)` | :arrow_up: |
   
   ... and [13 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2999/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>




> SC: static compilation inserts wrong cast, derived from generic return type 
> when assigned to a variable
> -------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12469
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12469
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.23, 3.0.25, 5.0.3, 4.0.33, 5.1.3, 6.0.0
>            Reporter: Björn Kautler
>            Priority: Major
>
> Given the following snippet:
> {code:groovy}
> import java.lang.annotation.Annotation
> import java.lang.annotation.Retention
> import java.lang.annotation.Target
> import groovy.transform.CompileStatic
> @CompileStatic
> <T extends Annotation> T getRetention(Class<T> clazz) {
>   Target.getAnnotation(Target)
> }
> @CompileStatic
> def foo() {
>   Annotation x = getRetention(Retention) /*as Annotation*/
> }
> foo().toString()
> {code}
> This compiles fine under all versions, but fails with a 
> {{GroovyCastException}} in all versions.
>  
> The generated byte-code under SC has a cast on {{Retention}} in this, even 
> though the variable is of type {{Annotation}} explicitly.
> Commenting in the {{as Annotation}} cast makes it work.
> Removing the {{Annotation x =}} also makes it work.
> Removing the {{@CompileStatic}} or replacing it by {{@TypeChecked}} of course 
> also makes it work.
>  
> I'd say static-compilation should here not insert an unnecessary cast to 
> {{{}Retention{}}}, but at most a cast to {{Annotation}} as that is, what the 
> variable needs and which should be consistent with JVM type-erasure, and also 
> with the variant without the variable. Even with the method returning 
> {{Annotation}} instead of {{def}} it works just fine. Just if the method 
> declares to return {{Retention}} explicitly, the cast exception comes, but 
> then rightfully.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to