I am trying to define an operator ++
for my custom Map
type like this:
@Override
public MutableMap<K, V> $plus$plus(Map<? extends K, ? extends V> map)
{
HashMap<K, V> copy = this.copy();
map.$plus$plus$eq(map);
return copy;
}
The ++=
operator is defined like this:
public void $plus$plus$eq(Map<? extends K, ? extends V> map);
However, the compiler complains on the map.$plus$plus$eq(map);
line, with the following crazy error:
The method $plus$plus$eq(Map<? extends capture#10-of ? extends K,
? extends capture#11-of ? extends V>) in the type
Map<capture#10-of ? extends K,capture#11-of ? extends V> is not
applicable for the arguments
(Map<capture#12-of ? extends K,capture#13-of ? extends V>)
As you can see in this screenshot, none of the solutions provided by Eclipse work, yet alone even make sense:
I have been working with Java generics for quite a while now, even having developed my own generic type system for a custom programming (whose library I am currently trying to code), but I have never had an error like this before.
EDIT: Interestingly, casting the map
argument to the raw type (Map)
seems to fix the problem.
map.$plus$plus$eq((Map) map);
However, changing the cast to (Map<?, ?>)
(which is what Eclipse's second solution does) causes a similar error.