Thodoris Sotiropoulos created GROOVY-11042:
----------------------------------------------

             Summary: Wrong method is chosen from the Groovy runtime
                 Key: GROOVY-11042
                 URL: https://issues.apache.org/jira/browse/GROOVY-11042
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


I have the following code

{code}
class Main {
  static final void test() {
    String[] p1 = new String[]{"v2"};
    String[] p2 = new String[]{"v1"};
    java.util.TreeMap<String[], Number> x = null;
    x.subMap(p1, p2);
  }
}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 6: [Static type checking] - Cannot call <K,V> 
org.codehaus.groovy.runtime.DefaultGroovyMethods#subMap(java.util.Map<K, V>, 
K[]) with arguments [java.util.TreeMap<java.lang.String[], java.lang.Number>, 
java.lang.String[], java.lang.String[]]
 @ line 6, column 5.
       x.subMap(p1, p2);
       ^

1 error
{code}

h3. Expected behavior

Compile successfully

h3. Notes

Tested against master (commit: ce357be7e43542480a8e01f383aac69b19e1fe8f)

Perhaps, an incorrect method is chosen (see 
https://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html#subMap(java.util.Map,K%5B%5D))
 instead of 
https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/util/TreeMap.html#subMap(K,K).



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

Reply via email to