EDIT: As of IntelliJ version 2017.2 this issue has been fixed.
Java version: 1.8.0_131
IntelliJ IDEA version: 2017.1.4
I have this class:
public class MethodReferenceWithArguments {
static <T, U> T createWith(Function<? super U, ? extends T> methodRef, U arg) {
return methodRef.apply(arg);
}
public static void main(String[] args) {
Map<String, String> map = createWith(
TreeMap::new,
Comparator.<String>reverseOrder());
map.put("aaa", "ONE");
map.put("zzz", "TWO");
System.out.println(map);
}
}
With javac, it compiles fine and works fine. With IntelliJ, it compiles fine and works fine, however the TreeMap::new
constructor reference is underlined with red and Bad return type in method reference: cannot convert java.util.TreeMap<K, V> to T
message is displayed on hover tooltip.
Does anybody know how to disable this misleading and annoying error message without turning off important, relevant error messages? Is this a bug? If yes, where can I report it?