[
https://issues.apache.org/jira/browse/GROOVY-12767?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18145563#comment-18145563
]
ASF GitHub Bot commented on GROOVY-12767:
-----------------------------------------
codecov-commenter commented on PR #3307:
URL: https://github.com/apache/groovy/pull/3307#issuecomment-6913850381
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3307?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 `90.00000%` with `2 lines` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 74.5026%. Comparing base
([`676988f`](https://app.codecov.io/gh/apache/groovy/commit/676988f7fe63594fde73cb5c08c07e2d6892820b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`2c389d2`](https://app.codecov.io/gh/apache/groovy/commit/2c389d2575cc10f4ca9d1d2f894cc611f377e269?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/3307?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/3307?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)
| 90.0000% | [0 Missing and 2 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3307?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/3307?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3307 +/- ##
==================================================
+ Coverage 74.4993% 74.5026% +0.0033%
- Complexity 44949 44963 +14
==================================================
Files 1703 1703
Lines 152333 152353 +20
Branches 29187 29193 +6
==================================================
+ Hits 113487 113507 +20
Misses 28411 28411
Partials 10435 10435
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3307?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/3307?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)
| `88.0366% <90.0000%> (+0.0677%)` | :arrow_up: |
... and [12 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3307/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: the element type of a for await loop is always Object
> ----------------------------------------------------------
>
> Key: GROOVY-12767
> URL: https://issues.apache.org/jira/browse/GROOVY-12767
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Priority: Major
>
> Under {{@CompileStatic}} or {{@TypeChecked}}, the loop variable of a {{for
> await}} loop is typed {{Object}}, whatever the source. A typed loop variable
> is rejected, and an untyped one can't call the element's methods. The
> equivalent plain {{for}} loop compiles.
> {code:groovy}
> @groovy.transform.CompileStatic
> void m() {
> List<Integer> src = [1, 2]
> for (Integer x in src) { } // ok
> for await (Integer x in src) { } // [Static type checking] - Cannot
> loop with element of type java.lang.Integer
> // with collection of type
> java.lang.Iterable<java.lang.Object>
> for await (x in src) { x.intValue() } // Cannot find matching method
> java.lang.Object#intValue()
> }
> {code}
> The same happens for {{Iterator<Integer>}}, {{Integer[]}},
> {{AsyncChannel<Integer>}} and {{Flow.Publisher<Integer>}} (for example
> {{SubmissionPublisher<Integer>}}). Seen on 6.0.0 and master.
> Cause: the parser rewrites the loop to iterate over
> {{AsyncSupport.toIterable(source)}}
> ({{AsyncTransformHelper.wrapForAwaitLoop}}), declared as {{<T> Iterable<T>
> toIterable(Object source)}}. Nothing binds {{T}}, so the type checker sees
> {{Iterable<Object>}}. The error message also names that rewritten type rather
> than the type of the source.
> Expected: the element type of the source, as for a plain {{for}} loop: {{E}}
> for an {{Iterable<E>}}, {{Iterator<E>}}, {{E[]}} or {{Stream<E>}} (an
> {{AsyncChannel<E>}} is an {{Iterable<E>}}), and {{T}} for a
> {{Flow.Publisher<T>}}. Other sources, such as types handled through an
> {{AwaitableAdapter}}, stay {{Object}}.
> Possible fixes:
> * *Type checker* (preferred): {{wrapForAwaitLoop}} records the original
> source expression on the {{ForStatement}} as node metadata, and
> {{StaticTypeCheckingVisitor.visitForLoop}} takes the element type from that
> expression's type: {{inferLoopElementType}} as for a plain loop, plus
> {{Flow.Publisher<T>}}. Covers typed and untyped loop variables and corrects
> the error message. It changes no runtime methods or generated calls, so code
> compiled with the fix still runs on a 6.0.0 runtime.
> * *Typed temporary variable*: declare the temporary as {{Iterable<V>}} when
> the loop variable has a type {{V}}. A smaller change, but an untyped loop
> variable stays {{Object}}.
> * *Typed {{toIterable}} overloads* ({{Iterable<T>}}, {{Iterator<T>}},
> {{T[]}}, {{Flow.Publisher<T>}}): new {{@GroovyABI}} methods, so statically
> compiled code would need the newer runtime.
> Workaround: use an untyped loop variable and cast in the body.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)