I have following classes
interface 1
package test;
public interface TODO {
boolean test();
}
interface 2
package test;
@FunctionalInterface
public interface FuncN {
State zip(State ...states);
}
class 1
package test;
public class Test {
public static Test define(FuncN zipperFunc,TODO... tasks) {
return null;
}
public static Test define(TODO... tasks) {
return null;
}
}
class 2
package test;
public class State {
public static State mergeStates(State ...states) {
return null;
}
}
main class
package test;
public class Main {
public static void main(String[] args) {
Test.define(State::mergeStates,()->true);
}
}
The class main doesn't compile, throws error
reference to define is ambiguous Test.define(State::mergeStates,()->true); ^ both method define(FuncN,TODO...) in Test and method define(TODO...) in Test match
Class below does compile:
package test;
public class Main {
public static void main(String[] args) {
Test.define(states->State.mergeStates(states),()->true);
}
}
However i don't see any ambiguity. The signatures of FuncN and TODO are completely different, i don't think compiler should mistake them for one another.
Correct me if i am wrong.
P.S. Error is not reproducible using eclipse, so i would recommend creating a folder test creating all java files in that and run javac test/Main.java