You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "paulk-asert (via GitHub)" <gi...@apache.org> on 2026/03/30 01:10:53 UTC

[PR] GROOVY-11888: STC: method resolution fails for UnionTypeClassNode due… [groovy]

paulk-asert opened a new pull request, #2415:
URL: https://github.com/apache/groovy/pull/2415

   … to premature covariant elimination


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-11888: STC: method resolution fails for UnionTypeClassNode due… [groovy]

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on code in PR #2415:
URL: https://github.com/apache/groovy/pull/2415#discussion_r3018732133


##########
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java:
##########
@@ -953,8 +953,8 @@ public static List<MethodNode> chooseBestMethod(final ClassNode receiver, Collec
 
         // GROOVY-8965: type disjunction
         boolean duckType = receiver instanceof UnionTypeClassNode;
-        if (methods.size() > 1 && !first(methods).isConstructor())
-            methods = removeCovariantsAndInterfaceEquivalents(methods, duckType);
+        if (!duckType && methods.size() > 1 && !first(methods).isConstructor())
+            methods = removeCovariantsAndInterfaceEquivalents(methods, false);
 
         if (!duckType && argumentTypes == null) {
             return asList(methods); // GROOVY-11683: no covariants or equivalents

Review Comment:
   done



##########
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java:
##########
@@ -965,6 +965,8 @@ public static List<MethodNode> chooseBestMethod(final ClassNode receiver, Collec
             var view = methods;
             if (duckType) {
                 view = methods.stream().filter(m -> implementsInterfaceOrSubclassOf(rcvr, m.getDeclaringClass())).toList();
+                if (view.size() > 1)
+                    view = removeCovariantsAndInterfaceEquivalents(view, true);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-11888: STC: method resolution fails for UnionTypeClassNode due… [groovy]

Posted by "eric-milles (via GitHub)" <gi...@apache.org>.
eric-milles commented on PR #2415:
URL: https://github.com/apache/groovy/pull/2415#issuecomment-4162404155

   Let me have a look at the unit test cases.  I wasn't familiar with cases that failed.  Were these cases that came from some project?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-11888: STC: method resolution fails for UnionTypeClassNode due… [groovy]

Posted by "eric-milles (via GitHub)" <gi...@apache.org>.
eric-milles commented on code in PR #2415:
URL: https://github.com/apache/groovy/pull/2415#discussion_r3016831614


##########
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java:
##########
@@ -965,6 +965,8 @@ public static List<MethodNode> chooseBestMethod(final ClassNode receiver, Collec
             var view = methods;
             if (duckType) {
                 view = methods.stream().filter(m -> implementsInterfaceOrSubclassOf(rcvr, m.getDeclaringClass())).toList();
+                if (view.size() > 1)
+                    view = removeCovariantsAndInterfaceEquivalents(view, true);

Review Comment:
   Can you add a GROOVY-11888 comment to this line?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-11888: STC: method resolution fails for UnionTypeClassNode due… [groovy]

Posted by "eric-milles (via GitHub)" <gi...@apache.org>.
eric-milles commented on code in PR #2415:
URL: https://github.com/apache/groovy/pull/2415#discussion_r3016829805


##########
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java:
##########
@@ -953,8 +953,8 @@ public static List<MethodNode> chooseBestMethod(final ClassNode receiver, Collec
 
         // GROOVY-8965: type disjunction
         boolean duckType = receiver instanceof UnionTypeClassNode;
-        if (methods.size() > 1 && !first(methods).isConstructor())
-            methods = removeCovariantsAndInterfaceEquivalents(methods, duckType);
+        if (!duckType && methods.size() > 1 && !first(methods).isConstructor())
+            methods = removeCovariantsAndInterfaceEquivalents(methods, false);
 
         if (!duckType && argumentTypes == null) {
             return asList(methods); // GROOVY-11683: no covariants or equivalents

Review Comment:
   Can you combine with this block?  
   ```java
           if (!duckType) {
               if (methods.size() > 1 && !first(methods).isConstructor())
                   methods = removeCovariantsAndInterfaceEquivalents(methods, false);
               if (argumentTypes == null)
                   return asList(methods); // GROOVY-11683: no covariants or equivalents
           }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-11888: STC: method resolution fails for UnionTypeClassNode due… [groovy]

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on PR #2415:
URL: https://github.com/apache/groovy/pull/2415#issuecomment-4165984804

   > ... Were these cases that came from some project?
   
   I actually asked AI to help me review any edge cases that might be missing for PR #2397. It came up with those test cases and they were applicable to master not just GROOVY_5_0_X.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-11888: STC: method resolution fails for UnionTypeClassNode due… [groovy]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2415:
URL: https://github.com/apache/groovy/pull/2415#issuecomment-4151596666

   ## [Codecov](https://app.codecov.io/gh/apache/groovy/pull/2415?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 `75.00000%` with `1 line` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 66.3719%. Comparing base ([`3b4d02f`](https://app.codecov.io/gh/apache/groovy/commit/3b4d02f5aeaecb8eda64e5243047af1376c88e74?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ffdb59a`](https://app.codecov.io/gh/apache/groovy/commit/ffdb59ae8ce6d7bc3e037ddc30e3591ca7d2e5c1?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/2415?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/StaticTypeCheckingSupport.java](https://app.codecov.io/gh/apache/groovy/pull/2415?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingSupport.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nU3VwcG9ydC5qYXZh) | 75.0000% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2415?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/2415/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/2415?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2415        +/-   ##
   ==================================================
   - Coverage     66.3773%   66.3719%   -0.0054%     
   + Complexity      29877      29874         -3     
   ==================================================
     Files            1392       1392                
     Lines          116799     116801         +2     
     Branches        20665      20666         +1     
   ==================================================
   - Hits            77528      77523         -5     
   - Misses          32916      32918         +2     
   - Partials         6355       6360         +5     
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/groovy/pull/2415?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/StaticTypeCheckingSupport.java](https://app.codecov.io/gh/apache/groovy/pull/2415?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingSupport.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nU3VwcG9ydC5qYXZh) | `81.4324% <75.0000%> (-0.1443%)` | :arrow_down: |
   
   ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/apache/groovy/pull/2415/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>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-11888: STC: method resolution fails for UnionTypeClassNode due… [groovy]

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert merged PR #2415:
URL: https://github.com/apache/groovy/pull/2415


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org