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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2148?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   Attention: Patch coverage is `93.33333%` with `2 lines` in your changes 
missing coverage. Please review.
   > Project coverage is 68.8271%. Comparing base 
[(`6dff05e`)](https://app.codecov.io/gh/apache/groovy/commit/6dff05eec5f645e0a7eaf0221f724e376615e8da?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 to head 
[(`7ba1012`)](https://app.codecov.io/gh/apache/groovy/commit/7ba1012b0539990f2bdb47d70ff830d12a958807?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2148?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[src/main/groovy/groovy/grape/GrapeIvy.groovy](https://app.codecov.io/gh/apache/groovy/pull/2148?src=pr&el=tree&filepath=src%2Fmain%2Fgroovy%2Fgroovy%2Fgrape%2FGrapeIvy.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vZ3Jvb3Z5L2dyb292eS9ncmFwZS9HcmFwZUl2eS5ncm9vdnk=)
 | 50.0000% | [1 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...ovy/classgen/asm/sc/StaticTypesCallSiteWriter.java](https://app.codecov.io/gh/apache/groovy/pull/2148?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesCallSiteWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc0NhbGxTaXRlV3JpdGVyLmphdmE=)
 | 0.0000% | [1 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2148?src=pr&el=tree&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/2148/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/2148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2148        +/-   ##
   ==================================================
   - Coverage     68.8286%   68.8271%   -0.0016%     
   + Complexity      29443      29439         -4     
   ==================================================
     Files            1420       1420                
     Lines          113168     113188        +20     
     Branches        19550      19555         +5     
   ==================================================
   + Hits            77892      77904        +12     
   - Misses          28737      28738         +1     
   - Partials         6539       6546         +7     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2148?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/2148?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.6373% <100.0000%> (-0.0433%)` | :arrow_down: |
   | 
[src/main/groovy/groovy/grape/GrapeIvy.groovy](https://app.codecov.io/gh/apache/groovy/pull/2148?src=pr&el=tree&filepath=src%2Fmain%2Fgroovy%2Fgroovy%2Fgrape%2FGrapeIvy.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vZ3Jvb3Z5L2dyb292eS9ncmFwZS9HcmFwZUl2eS5ncm9vdnk=)
 | `39.1429% <50.0000%> (ø)` | |
   | 
[...ovy/classgen/asm/sc/StaticTypesCallSiteWriter.java](https://app.codecov.io/gh/apache/groovy/pull/2148?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesCallSiteWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc0NhbGxTaXRlV3JpdGVyLmphdmE=)
 | `74.0125% <0.0000%> (ø)` | |
   
   ... and [6 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2148/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   </details>




> CompileStatic does not detect type mismatch on "+="
> ---------------------------------------------------
>
>                 Key: GROOVY-11563
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11563
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 4.0.25
>            Reporter: Martin Häusler
>            Assignee: Eric Milles
>            Priority: Major
>
> Hello,
> I'm using Groovy 4.0.25 on OpenJDK 21. I'm using static compilation. It seems 
> like the static typechecker is unable to find type issues related to the "+=" 
> operator. I have a full self-contained JUnit test for you below.
> In the test class, there are two test methods that check the output of the 
> type checker.
> Please note that "<number> += <string>" compiles without problems (and it 
> really should report an issue here), but "<number> = <number> + <string>" 
> produces the expected compilation issue.
>  
> {code:java}
> import groovy.lang.GroovyClassLoader;
> import groovy.transform.CompileStatic;
> import org.codehaus.groovy.control.CompilationFailedException;
> import org.codehaus.groovy.control.CompilationUnit;
> import org.codehaus.groovy.control.CompilerConfiguration;
> import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
> import org.codehaus.groovy.control.messages.Message;
> import org.codehaus.groovy.control.messages.WarningMessage;
> import org.junit.jupiter.api.Test;
> import java.util.List;
> import java.util.UUID;
> import static org.junit.jupiter.api.Assertions.fail;
> public class GroovyCompilerStandaloneExampleTest {
>     @Test
>     public void testWithPlusEquals() throws Exception {
>         try {
>             compileGroovy(
>                 "Number x = 0\n" +
>                     "x += \"hello\""
>             );
>             fail("No compile error!");
>         } catch (CompilationFailedException e) {
>             // success!
>         }
>     }
>     @Test
>     public void testWithAssignment() throws Exception {
>         try {
>             compileGroovy(
>                 "Number x = 0\n" +
>                     "x = x + \"hello\""
>             );
>             fail("No compile error!");
>         } catch (CompilationFailedException e) {
>             // success!
>         }
>     }
>     private Class<?> compileGroovy(String source) throws Exception {
>         ClassLoader classLoader = 
> Thread.currentThread().getContextClassLoader();
>         CompilerConfiguration compilerConfig = createCompilerConfig();
>         try (GroovyClassLoader gcl = new GroovyClassLoader(classLoader, 
> compilerConfig)) {
>             List<? extends Class<?>> classes = 
> compileInternal(compilerConfig, gcl, source);
>             return classes.getFirst();
>         }
>     }
>     private CompilerConfiguration createCompilerConfig() {
>         CompilerConfiguration config = new CompilerConfiguration();
>         config.setWarningLevel(WarningMessage.PARANOIA);
>         config.addCompilationCustomizers(
>             new ASTTransformationCustomizer(CompileStatic.class)
>         );
>         return config;
>     }
>     private List<? extends Class<?>> compileInternal(
>         CompilerConfiguration config,
>         GroovyClassLoader gcl,
>         String sourceCode
>     ) throws Exception {
>         CompilationUnit compilationUnit = new CompilationUnit(config, null, 
> gcl);
>         compilationUnit.addSource("script-" + UUID.randomUUID().toString(), 
> sourceCode);
>         compilationUnit.compile();
>         List<? extends Message> errors = 
> compilationUnit.getErrorCollector().getErrors();
>         if (errors != null && !errors.isEmpty()) {
>             fail("Groovy compilation has failed with " + errors.size() + " 
> errors:\n" +
>                 String.join("\n - ", errors.toString()));
>         }
>         return compilationUnit.getClasses().stream().map(groovyClass -> {
>             gcl.defineClass(groovyClass.getName(), groovyClass.getBytes());
>             try {
>                 return gcl.loadClass(groovyClass.getName());
>             } catch (ClassNotFoundException e) {
>                 throw new RuntimeException(e);
>             }
>         }).toList();
>     }
> } {code}



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

Reply via email to