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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3068?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `60.82090%` with `105 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 73.5873%. Comparing base 
([`cfd9b2f`](https://app.codecov.io/gh/apache/groovy/commit/cfd9b2f0222a8e1a74473f7c5b2cb45b5bdd3b5b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`aaa9600`](https://app.codecov.io/gh/apache/groovy/commit/aaa96009b052bb5ba9695e77421c954da5ea130d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 commits behind head on master.
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3068?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...ransform/stc/SharedVariableExpressionRewriter.java](https://app.codecov.io/gh/apache/groovy/pull/3068?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FSharedVariableExpressionRewriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU2hhcmVkVmFyaWFibGVFeHByZXNzaW9uUmV3cml0ZXIuamF2YQ==)
 | 59.7701% | [72 Missing and 33 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3068?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/3068/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/3068?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3068        +/-   ##
   ==================================================
   - Coverage     73.6047%   73.5873%   -0.0175%     
   - Complexity      42348      42424        +76     
   ==================================================
     Files            1657       1658         +1     
     Lines          145708     145975       +267     
     Branches        27498      27573        +75     
   ==================================================
   + Hits           107248     107419       +171     
   - Misses          28479      28543        +64     
   - Partials         9981      10013        +32     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3068?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/3068?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.4653% <100.0000%> (-0.0057%)` | :arrow_down: |
   | 
[...ransform/stc/SharedVariableExpressionRewriter.java](https://app.codecov.io/gh/apache/groovy/pull/3068?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FSharedVariableExpressionRewriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU2hhcmVkVmFyaWFibGVFeHByZXNzaW9uUmV3cml0ZXIuamF2YQ==)
 | `59.7701% <59.7701%> (ø)` | |
   
   ... and [10 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3068/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 gets confused when THIS_EXPRESSION is used
> ----------------------------------------------
>
>                 Key: GROOVY-12441
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12441
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.23, 3.0.25, 4.0.33, 5.1.3, 6.0.0
>            Reporter: Björn Kautler
>            Assignee: Daniel Sun
>            Priority: Major
>
> If you use {{VariableExpression.THIS_EXPRESSION}} the STC  and thus 
> static-compile gets confused.
> I assume this is a bug, if it is expected, sorry for the noise.
> We use this at some places in the Spock transform.
> While trying to make Spock specs compatible with STC and SC, it was observed 
> that STC stores type information at the current node and using 
> {{VariableExpression.THIS_EXPRESSION}} then causes conflicting casts when 
> used inside and outside a closure.
> As a work-around we can instead use {{{}new VariableExpression("this"){}}}, 
> but I guess this actually is a bug, thus this report.
> As an example.
> {code:java}
> class ASpec extends Specification {
>   def "mock init closure"() {
>     given:
>     List<String> list = Mock(List) {
>       size() >> 3
>     }
>     when:
>     int size = list.size()
>     then:
>     size == 3
>   }
> }
> {code}
> compiles in semantic analysis to
> {code:java}
> import spock.lang.*
> @org.spockframework.runtime.model.SpecMetadata(filename = 'script.groovy', 
> line = 1)
> public class ASpec extends spock.lang.Specification {
>     @org.spockframework.runtime.model.FeatureMetadata(name = 'mock init 
> closure', ordinal = 0, line = 2, blocks = 
> [@org.spockframework.runtime.model.BlockMetadata(kind = 
> org.spockframework.runtime.model.BlockKind.SETUP, texts = []), 
> @org.spockframework.runtime.model.BlockMetadata(kind = 
> org.spockframework.runtime.model.BlockKind.WHEN, texts = []), 
> @org.spockframework.runtime.model.BlockMetadata(kind = 
> org.spockframework.runtime.model.BlockKind.THEN, texts = [])], parameterNames 
> = [])
>     public void $spock_feature_0_0() {
>         org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new 
> org.spockframework.runtime.ValueRecorder()
>         org.spockframework.runtime.ErrorCollector $spock_errorCollector = 
> org.spockframework.runtime.ErrorRethrower.INSTANCE
>         org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 0)
>         java.util.List<String> list = 
> org.spockframework.runtime.SpecInternals.MockImpl(this, 'list', 
> java.util.List, java.util.List, { ->
>             
> this.getSpecificationContext().getMockController().addInteraction(new 
> org.spockframework.mock.runtime.InteractionBuilder(5, 7, 'size() >> 
> 3').addEqualTarget(it).addEqualMethodName('size').setArgListKind(true, 
> false).addConstantResponse(3).build())
>         })
>         org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0)
>         org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 1)
>         java.lang.Integer size = list.size()
>         org.spockframework.runtime.SpockRuntime.callBlockExited(this, 1)
>         org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 2)
>         try {
>             
> org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector,
>  $spock_valueRecorder.reset(), 'size == 3', 12, 5, null, 
> $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), 
> $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 
> size) == 
> $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), 3)))
>         }
>         catch (java.lang.Throwable $spock_condition_throwable) {
>             
> org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector,
>  $spock_valueRecorder, 'size == 3', 12, 5, null, $spock_condition_throwable)}
>         finally {
>         }
>         org.spockframework.runtime.SpockRuntime.callBlockExited(this, 2)
>         this.getSpecificationContext().getMockController().leaveScope()
>     }
> }
> {code}
> The important part here is the two {{getSpecificationContext()}} calls, one 
> inside the mock init closure, one as last line in the feature method, both 
> added by the Spock transform.
> If those use {{VariableExpression.THIS_EXPRESSION}} then at runtime you get 
> {{{}java.lang.ClassCastException: apackage.ASpec cannot be cast to 
> apackage.ASpec$__spock_feature_0_0_closure1{}}}.
> If you use {{new VariableExpression("this")}} instead, it works as intended.



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

Reply via email to