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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2630?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 `92.85714%` with `1 line` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 68.4983%. Comparing base 
([`1d5213e`](https://app.codecov.io/gh/apache/groovy/commit/1d5213e9bcafa70b1730ced10bba4f894b7c045e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`6c2721e`](https://app.codecov.io/gh/apache/groovy/commit/6c2721e49e2e22785114ce055d2abf96c4eafd64?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/2630?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...oovy/transform/trait/TraitReceiverTransformer.java](https://app.codecov.io/gh/apache/groovy/pull/2630?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Ftrait%2FTraitReceiverTransformer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS90cmFpdC9UcmFpdFJlY2VpdmVyVHJhbnNmb3JtZXIuamF2YQ==)
 | 92.8571% | [0 Missing and 1 partial :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2630?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/2630/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/2630?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2630        +/-   ##
   ==================================================
   - Coverage     68.4996%   68.4983%   -0.0012%     
   - Complexity      33566      33569         +3     
   ==================================================
     Files            1518       1518                
     Lines          127284     127298        +14     
     Branches        23105      23109         +4     
   ==================================================
   + Hits            87189      87197         +8     
   - Misses          32354      32357         +3     
   - Partials         7741       7744         +3     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2630?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...oovy/transform/trait/TraitReceiverTransformer.java](https://app.codecov.io/gh/apache/groovy/pull/2630?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Ftrait%2FTraitReceiverTransformer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS90cmFpdC9UcmFpdFJlY2VpdmVyVHJhbnNmb3JtZXIuamF2YQ==)
 | `89.4180% <92.8571%> (+0.2751%)` | :arrow_up: |
   
   ... and [6 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2630/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>




> Trait body with T.this.* qualifier produces VerifyError (4.x) / 
> ClassCastException (5.x/6.x) — should be a compile error
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12104
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12104
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>            Priority: Major
>
> bq. *Editorial*: the description here was incorrectly populated with 
> GROOVY-12105's content when filed. Corrected now to describe the intended 
> T.this.* bytecode bug.
> Inside a trait body, the qualifier syntax `T.this.<member>` (where T
> is the enclosing trait) compiles successfully but produces invalid or
> mis-typed bytecode that fails at runtime.
> Minimal reproducer:
> {code:groovy}
> trait V {
>     static boolean defaultNullable() { false }
>     static seen() { V.this.defaultNullable() }
> }
> class Over implements V { static boolean defaultNullable() { true } }
> Over.seen()
> {code}
> Expected: either return a value matching a defined semantic, or
> reject at compile time as a syntax error (T.this has no coherent
> meaning in trait code per GEP-22, where `this` is the implementing
> instance and the trait is not an enclosing scope).
> Actual:
> * Groovy 4.0.32: java.lang.VerifyError "Bad type on operand stack"
>   (Type 'java/lang/Class' not assignable to 'groovy/lang/Closure' at
>   V$Trait$Helper.seen(Ljava/lang/Class;)Ljava/lang/Object; @1:
>   invokevirtual)
> * Groovy 5.0.6 / 6.0.0-alpha-1: java.lang.ClassCastException: Cannot
>   cast java.lang.Class to V
> * Bytecode disassembly: {{2ab6 0032 c000 09ba 003f 0000 b0}}
>   (aload_0 of $static$self (Class) → invokevirtual expecting Closure)
> The bug shape changed between 4.x and 5.x — the verifier-level
> mismatch on 4.x was apparently fixed but the underlying transform
> still produces wrong code (now ClassCastException at runtime).
> Adjacent cases (helps scope the bug):
> ||Variant||4.0.32||5.0.6 / 6.0.0-alpha-1||
> |Trait static T.this.method()|VerifyError|ClassCastException|
> |Trait static T.this.staticField|VerifyError|VerifyError (still)|
> |Trait *instance* T.this.method()|VerifyError|AbstractMethodError|
> |Plain (non-trait) class T.this.method() in static|Compile error|Compile 
> error|
> |Trait static OtherTrait.this.method() (wrong trait)|Compile error|Compile 
> error|
> Discovered during the GROOVY-11985 / GROOVY-12093 thread when
> enumerating candidate alternatives Grails could use as workarounds
> for trait-body static dispatch (Eric Milles' comment of 25-Jun-2026
> asked whether `Validateable.this.defaultNullable()` would work).
> *Recommended fix*: reject `T.this.*` in trait code at compile time.
> For "force the trait's own implementation", `T.super.m(...)` is the
> existing supported form. For normal dispatch, `this.m(...)` (which
> follows row-1 override-visible dispatch).
> This aligns with Eric's framing on the companion GROOVY-12105 ticket
> ("Cannot use super in a static context") — Java doesn't have a T.this
> analogue meaningful for traits (T.this is for inner/anonymous-class
> enclosing-instance access; a trait isn't an enclosing scope of its
> implementer), so "reject" is the right answer for the same JLS-
> alignment reason.
> Proposed spec text: GEP-22 v5 § "this, super, and stackable traits"
> item 4 (already drafted in a working branch, would land alongside the
> fix).
> *Related*: GROOVY-11985 (the regression discussion that surfaced
> this), GROOVY-12093 (the @Anchored proposal, where Eric Milles'
> question prompted the empirical sweep), GROOVY-12105 (the companion
> ticket — same workstream, different bug shape).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to