Thodoris Sotiropoulos created GROOVY-11430:
----------------------------------------------

             Summary: Inconsistent behavior when encountering overloaded methods
                 Key: GROOVY-11430
                 URL: https://issues.apache.org/jira/browse/GROOVY-11430
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation, Static Type Checker
            Reporter: Thodoris Sotiropoulos


I have the following program
{code:java}
import java.util.*;
import java.util.function.*;

class A<T> {
  void m(T x) { System.out.println("there"); }
  void m(Integer x) { System.out.println("here"); }
}
class Test {
  public static void main(String[] args) {
    A<Integer> x = new A<>();
    Consumer<Integer> y = x::m;
    y.accept(1)
  }
} {code}
h3. Actual behavior

Depending on the order in which methods "m()" appear in the program, the 
outcome is different. So, if "m( T x)" is first, the outcome is "there". 
Otherwise, if "m( Integer x)" is first, the outcome is "here".
h3. Expected behavior

I would expect that the reference "x::m" is ambiguous, so the program should 
have been rejected.

Tested against master (commit: d3c07b8416743545ebb81fda43768f2cec4ca59b)



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

Reply via email to