[
https://issues.apache.org/jira/browse/GROOVY-12827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149816#comment-18149816
]
ASF GitHub Bot commented on GROOVY-12827:
-----------------------------------------
codecov-commenter commented on PR #3350:
URL: https://github.com/apache/groovy/pull/3350#issuecomment-7102605721
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3350?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 `91.80328%` with `10 lines` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 74.9672%. Comparing base
([`09e84fa`](https://app.codecov.io/gh/apache/groovy/commit/09e84fa4b0d4c37a5ac2efc48dfd2db93a84cab7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`343e77e`](https://app.codecov.io/gh/apache/groovy/commit/343e77edb63b844ed66bf837e83fc94135406b00?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on master.
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3350?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Patch % | Lines |
|---|---|---|
|
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/3350?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)
| 80.0000% | [0 Missing and 5 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...groovy/classgen/asm/sc/StaticInvocationWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticInvocationWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNJbnZvY2F0aW9uV3JpdGVyLmphdmE=)
| 90.6250% | [0 Missing and 3 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...ovy/classgen/asm/sc/StaticTypesLambdaAnalyzer.java](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesLambdaAnalyzer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc0xhbWJkYUFuYWx5emVyLmphdmE=)
| 96.2963% | [0 Missing and 1 partial :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...roovy/classgen/asm/sc/StaticTypesLambdaWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesLambdaWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc0xhbWJkYVdyaXRlci5qYXZh)
| 97.2973% | [0 Missing and 1 partial :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3350?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>
[](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3350 +/- ##
==================================================
+ Coverage 74.9518% 74.9672% +0.0154%
- Complexity 48908 48979 +71
==================================================
Files 1768 1768
Lines 161213 161356 +143
Branches 31728 31772 +44
==================================================
+ Hits 120832 120964 +132
+ Misses 28968 28966 -2
- Partials 11413 11426 +13
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3350?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...ovy/classgen/asm/sc/StaticTypesCallSiteWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3350?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=)
| `76.3636% <100.0000%> (-0.2129%)` | :arrow_down: |
|
[...ovy/classgen/asm/sc/StaticTypesLambdaAnalyzer.java](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesLambdaAnalyzer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc0xhbWJkYUFuYWx5emVyLmphdmE=)
| `94.7917% <96.2963%> (+1.3785%)` | :arrow_up: |
|
[...roovy/classgen/asm/sc/StaticTypesLambdaWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticTypesLambdaWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNUeXBlc0xhbWJkYVdyaXRlci5qYXZh)
| `90.9091% <97.2973%> (+0.7682%)` | :arrow_up: |
|
[...groovy/classgen/asm/sc/StaticInvocationWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3350?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticInvocationWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNJbnZvY2F0aW9uV3JpdGVyLmphdmE=)
| `78.5366% <90.6250%> (+0.2904%)` | :arrow_up: |
|
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/3350?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.9340% <80.0000%> (+0.0169%)` | :arrow_up: |
... and [16 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3350/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: a delegate method or property used in a lambda inside a closure throws
> ClassCastException
> ---------------------------------------------------------------------------------------------
>
> Key: GROOVY-12827
> URL: https://issues.apache.org/jira/browse/GROOVY-12827
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 5.1.3, 6.0.0
> Reporter: Paul King
> Priority: Major
> Labels: breaking
>
> Under \{{@CompileStatic}}, a native lambda inside a closure can compile an
> implicit call to a method or property of the closure's delegate, but the call
> fails at run time. Dynamic Groovy runs the same code correctly.
> {code:groovy}
> import java.util.function.Supplier
> class D {
> String hi() \{ 'hi from D' }
> }
> @groovy.transform.CompileStatic
> class C {
> def m() {
> new D().with {
> Supplier<String> s = () -> hi()
> s.get()
> }
> }
> }
> assert new C().m() == 'hi from D'
> {code}
> Actual result:
> {noformat}
> java.lang.ClassCastException: class C cannot be cast to class
> groovy.lang.Closure
> {noformat}
> h3. Cause
> The type checker records a receiver path through the enclosing closure, such
> as \{{owner.delegate}}. The owner of a native lambda is the enclosing
> instance rather than that closure, so the path cannot be followed at run time.
> h3. Proposed fix
> A lambda that resolves a name through the enclosing closure captures that
> closure. The name then resolves as it would directly in the closure,
> honouring the resolve strategy and the delegate at call time, including a
> later \{{setDelegate}}. The lambda's own \{{owner}}, \{{delegate}} and
> \{{thisObject}} remain the enclosing instance. Other lambdas keep their
> current shape.
> A serializable lambda that captures the closure is generated as a
> \{{ConvertedClosure}} proxy, as in dynamic Groovy. The JDK's
> \{{SerializedLambda}} is replaced only after its captured values are read, so
> a delegate that refers back to the lambda would otherwise receive the
> \{{SerializedLambda}} and fail on deserialization. A functional interface
> that is or implements a trait still uses the metafactory, so this
> deserialization failure remains possible there.
> h3. Compatibility
> These affect only a serializable lambda containing such a delegate reference.
> The reference could not run successfully before.
> * If the closure's delegate, or another value held by the closure, is not
> serializable, writing the lambda now throws \{{NotSerializableException}},
> even if the delegate call is on a branch that never runs. Dynamic Groovy
> behaves the same way.
> * An undeclared checked exception thrown from the lambda now reaches the
> caller as \{{UndeclaredThrowableException}}. Dynamic Groovy behaves the same
> way.
> h3. Known limitation
> A map-key property on a \{{Map}} delegate still fails with
> \{{MissingPropertyException}}, because it is resolved dynamically and has no
> receiver path:
> {code:groovy}
> [a: 'A'].with {
> Supplier<String> s = () -> a
> s.get()
> }
> {code}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)