[
https://issues.apache.org/jira/browse/GROOVY-12831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150577#comment-18150577
]
ASF GitHub Bot commented on GROOVY-12831:
-----------------------------------------
codecov-commenter commented on PR #3358:
URL: https://github.com/apache/groovy/pull/3358#issuecomment-7147574680
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3358?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.6957%. Comparing base
([`cc5c714`](https://app.codecov.io/gh/apache/groovy/commit/cc5c714a3e3a9053a783763fb6917b537ae7873e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`f2eefda`](https://app.codecov.io/gh/apache/groovy/commit/f2eefda39955f0392ed612e77be3e339913d1d05?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 GROOVY_6_0_X.
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/3358?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## GROOVY_6_0_X #3358 +/- ##
======================================================
- Coverage 72.6997% 72.6957% -0.0040%
+ Complexity 40310 40307 -3
======================================================
Files 1595 1595
Lines 141819 141820 +1
Branches 26886 26885 -1
======================================================
- Hits 103102 103097 -5
- Misses 29465 29467 +2
- Partials 9252 9256 +4
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3358?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/3358?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAstBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0FzdEJ1aWxkZXIuamF2YQ==)
| `87.3801% <100.0000%> (+0.0046%)` | :arrow_up: |
... and [12 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3358/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>
> await(x) followed by a method call, property or index awaits the whole chain
> instead of x
> -----------------------------------------------------------------------------------------
>
> Key: GROOVY-12831
> URL: https://issues.apache.org/jira/browse/GROOVY-12831
> Project: Groovy
> Issue Type: Bug
> Components: parser-antlr4
> Affects Versions: 6.0.0
> Reporter: Paul King
> Priority: Major
>
> A method call, property access or index written after \{{await(x)}} is taken
> into the operand of \{{await}}, so \{{await(task).toString()}} is read as
> \{{await((task).toString())}}. The same code with a binary operator,
> \{{await(task) + 1}}, is read as \{{(await task) + 1}}.
> {code:groovy}
> def t = async \{ 7 }
> assert await(t) + 1 == 8 // ok
> assert (await(t)).plus(1) == 8 // ok
> assert await(t).plus(1) == 8 // MissingMethodException: No
> signature of method: plus for class: GroovyPromise
> assert await(t).toString() == '7' // IllegalArgumentException: No
> Awaitable adapter found for type: java.lang.String
> def l = async \{ [3, 1, 2] }
> assert await(l).sort() == [1, 2, 3] // MissingMethodException: No
> signature of method: sort for class: GroovyPromise
> assert await(l)[0] == 3 // MissingMethodException
> {code}
> The behaviour is the same at script level, in a method and inside an
> \{{async}} closure, on 6.0.0, the current 6.0.x branch and master.
> h3. Cause
> {\{awaitExprAlt}} in \{{GroovyParser.g4}} offers two forms:
> {code}
> AWAIT NL* ( LPAREN expression (COMMA NL* expression)* RPAREN
> | expression (COMMA NL* expression)*
> )
> {code}
> When a binary operator follows \{{await(t)}}, both forms parse and the first
> wins. When \{{.}}, \{{?.}}, \{{[}} or an argument list follows, the first
> form cannot continue, because a path element cannot follow an expression at
> that level, so the second form takes \{{(t).toString()}} as a full
> expression. GROOVY-12715 copied the same alternatives into
> \{{castOperandExpression}}, so \{{(String) await(t).toString()}} behaves the
> same way.
> {\{core-grammar.adoc}} documents that \{{await a + b}} is \{{await (a + b)}},
> and that is not in question here. The problem is the parenthesised form:
> \{{await(t)}} looks like, and mostly behaves like, a call, so a member access
> after it is expected to apply to the awaited result.
> The only existing test using this shape,
> \{{ChannelCompositionTest.testSplit}} (\{{await(bigTask).sort()}}), is
> \{{@Disabled}}.
> h3. Proposed fix
> Make the parenthesised form bind like a method call: a path element
> (\{{.m()}}, \{{?.p}}, \{{[i]}}, a call or closure argument) after
> \{{await(...)}} applies to the awaited value. The unparenthesised form keeps
> taking a full expression, so \{{await a.b()}} is still \{{await (a.b())}}.
> Apply the same change to the \{{castOperandExpression}} alternative.
> h3. Compatibility
> Code that relies on the current reading, such as \{{await(x).m()}} meaning
> "await the result of \{{x.m()}}", changes meaning. That reading contradicts
> the binary-operator case and is unlikely to be intended; \{{await x.m()}}
> keeps that meaning. Async/await is incubating.
> h3. Tests
> * \{{await(t).m()}}, \{{await(t)?.p}}, \{{await(t)[0]}} and \{{await(t).m {
> ... }}} apply to the awaited value, at script level, in a method and inside
> an \{{async}} closure.
> * The multi-argument form \{{await(a, b)}} is unchanged.
> * \{{await a.m()}} is still \{{await (a.m())}}.
> * \{{(T) await(t).m()}} under the cast rule.
> * Re-enable or rewrite \{{ChannelCompositionTest.testSplit}}'s assertions so
> the shape is covered.
> * \{{await}} with its operand on the same line, and \{{await(}} with
> arguments on following lines, are unchanged.
> ```
> Both propose 6.0.1. Draft 1 matters more: I'd expect
> `await(task).someMethod()` to be common. Draft 2 could slip to a later
> release if you prefer. Once you've filed them, send me the keys and I'll
> record them in the task.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)