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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3357?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 74.9504%. Comparing base 
([`575c0d3`](https://app.codecov.io/gh/apache/groovy/commit/575c0d3a696ce0e9c35185258eb210627d874156?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`463b437`](https://app.codecov.io/gh/apache/groovy/commit/463b43786113744aaff9bbd784edbddeb57d2b3e?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.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3357/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/3357?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3357        +/-   ##
   ==================================================
   - Coverage     74.9583%   74.9504%   -0.0079%     
   + Complexity      48935      48931         -4     
   ==================================================
     Files            1768       1768                
     Lines          161255     161256         +1     
     Branches        31743      31742         -1     
   ==================================================
   - Hits           120874     120862        -12     
   - Misses          28972      28978         +6     
   - Partials        11409      11416         +7     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3357?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/3357?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.4302% <100.0000%> (+0.0044%)` | :arrow_up: |
   
   ... and [13 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3357/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)

Reply via email to