You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2022/07/08 19:05:31 UTC

[GitHub] [groovy] eric-milles opened a new pull request, #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

eric-milles opened a new pull request, #1742:
URL: https://github.com/apache/groovy/pull/1742

   As discussed under 8965 and 10668, check LUB type first for common method (fixes `testMultipleInstanceOf4`).  Duck-typing (`testMultipleInstanceOf1` and `testMultipleInstanceOf5`) is incomplete; currently reported as ambiguous method error.
   
   https://issues.apache.org/jira/browse/GROOVY-8965
   https://issues.apache.org/jira/browse/GROOVY-10180
   https://issues.apache.org/jira/browse/GROOVY-10668


-- 
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


[GitHub] [groovy] eric-milles commented on pull request #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

Posted by GitBox <gi...@apache.org>.
eric-milles commented on PR #1742:
URL: https://github.com/apache/groovy/pull/1742#issuecomment-1180735207

   Another thing that surprised me is that LUB(Integer,Double) is Double, not Number.  I'm not sure why this is the case: https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java#L349


-- 
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


[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1742:
URL: https://github.com/apache/groovy/pull/1742#discussion_r918148023


##########
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java:
##########
@@ -4702,37 +4703,36 @@ protected MethodNode findMethodOrFail(final Expression expr, final ClassNode rec
         return null;
     }
 
-    private List<MethodNode> disambiguateMethods(List<MethodNode> methods, final ClassNode receiver, final ClassNode[] argTypes, final Expression call) {
-        if (methods.size() > 1 && receiver != null && argTypes != null) {
+    private List<MethodNode> disambiguateMethods(List<MethodNode> methods, final ClassNode receiver, final ClassNode[] arguments, final Expression call) {

Review Comment:
   *[MixedMutabilityReturnType](https://errorprone.info/bugpattern/MixedMutabilityReturnType):*  This method returns both mutable and immutable collections or maps from different paths. This may be confusing for users of the method.
   
   
   ```suggestion
       private ImmutableList<MethodNode> disambiguateMethods(List<MethodNode> methods, final ClassNode receiver, final ClassNode[] arguments, final Expression call) {
   ```
   
   
   
   Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
   Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the above finding from this PR.
   Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.
   
   When talking to LiftBot, you need to **refresh** the page to see its response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get to know more about LiftBot commands.
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=295433288&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=295433288&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=295433288&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=295433288&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=295433288&lift_comment_rating=5) ]



-- 
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


[GitHub] [groovy] blackdrag commented on pull request #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

Posted by GitBox <gi...@apache.org>.
blackdrag commented on PR #1742:
URL: https://github.com/apache/groovy/pull/1742#issuecomment-1181626022

   > Another thing that surprised me is that LUB(Integer,Double) is Double, not Number. I'm not sure why this is the case: https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java#L349
    
   WideningCategories was initially for assignment and in some cases compares. Like: you can assign an Integer to a Double, but you cannot assign a Double to an Integer. I highly doubt this will give you the right results for the instanceof|| problem


-- 
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


[GitHub] [groovy] eric-milles merged pull request #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

Posted by GitBox <gi...@apache.org>.
eric-milles merged PR #1742:
URL: https://github.com/apache/groovy/pull/1742


-- 
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


[GitHub] [groovy] eric-milles commented on pull request #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

Posted by GitBox <gi...@apache.org>.
eric-milles commented on PR #1742:
URL: https://github.com/apache/groovy/pull/1742#issuecomment-1180578513

   Updated to support duck-typing scenario.  I'm still trying to figure how to support 6790, 8142 and `(x instanceof Map || x instanceof List) ? x.size() : 1` at the same time.
   
   https://issues.apache.org/jira/browse/GROOVY-6790
   https://issues.apache.org/jira/browse/GROOVY-8142


-- 
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


[GitHub] [groovy] eric-milles commented on pull request #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

Posted by GitBox <gi...@apache.org>.
eric-milles commented on PR #1742:
URL: https://github.com/apache/groovy/pull/1742#issuecomment-1180716117

   STC still does not produce an error for `o instanceof Map || o instanceof List ? o.entrySet() : null` -- this is not a new issue.


-- 
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


[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1742:
URL: https://github.com/apache/groovy/pull/1742#discussion_r918218361


##########
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java:
##########
@@ -4702,37 +4703,36 @@ protected MethodNode findMethodOrFail(final Expression expr, final ClassNode rec
         return null;
     }
 
-    private List<MethodNode> disambiguateMethods(List<MethodNode> methods, final ClassNode receiver, final ClassNode[] argTypes, final Expression call) {
-        if (methods.size() > 1 && receiver != null && argTypes != null) {
+    private List<MethodNode> disambiguateMethods(List<MethodNode> methods, final ClassNode receiver, final ClassNode[] arguments, final Expression call) {

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [groovy] eric-milles commented on a diff in pull request #1742: GROOVY-8965, GROOVY-10180, GROOVY-10668: STC: `instanceof` and `||`

Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1742:
URL: https://github.com/apache/groovy/pull/1742#discussion_r918218290


##########
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java:
##########
@@ -4702,37 +4703,36 @@ protected MethodNode findMethodOrFail(final Expression expr, final ClassNode rec
         return null;
     }
 
-    private List<MethodNode> disambiguateMethods(List<MethodNode> methods, final ClassNode receiver, final ClassNode[] argTypes, final Expression call) {
-        if (methods.size() > 1 && receiver != null && argTypes != null) {
+    private List<MethodNode> disambiguateMethods(List<MethodNode> methods, final ClassNode receiver, final ClassNode[] arguments, final Expression call) {

Review Comment:
   @sonatype-lift ignore



-- 
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