javagenericsgradlewildcardmethod-invocation

actual argument ... cannot be converted to ... by method invocation conversion


I'm making a mod for the game Minecraft. Using Eclipse all work fine, compilation is successfull and I can play the game using my created mod. However when I compile my code using gradle, I get this error :

C:\Users\Alexandre\MCForge\ForgeCreeperHeal\debug\build\sources\main\java\fr\eyzox\dependencygraph\DependencyGraph.java:31: error: method buildIndex in class DataKeyProvider<K> cannot be applied to given types;
                        node.keyProvider.buildIndex(index, node);
                                        ^
  required: Map<KEY,DependencyGraph<KEY,? extends IData<KEY>>.Node>,DependencyGraph<KEY,? extends IData<KEY>>.Node
  found: Map<KEY,DependencyGraph<KEY,DATA>.Node>,DependencyGraph<KEY,DATA>.Node
  reason: actual argument Map<KEY,DependencyGraph<KEY,DATA>.Node> cannot be converted to Map<KEY,DependencyGraph<KEY,? extends IData<KEY>>.Node> by method invocation conversion
  where KEY,DATA,K are type-variables:
    KEY extends Object declared in class DependencyGraph
    DATA extends IData<KEY> declared in class DependencyGraph
    K extends Object declared in class DataKeyProvider

I don't understand why it works on Eclipse but does not with gradle. Maybe it is pur java's generics missunderstanding, but I doubt it because all works fine in Eclipse. Is it the error from my side or should I looking for a gradle plugin bug ? I'm a beginner in gradle.

Maybe source code and build.gradle are needed to understand my issue. I've created a repo here : https://github.com/RedRelay/FCH_DEBUG

EDIT : It seems to be an issue related to Eclipse. I've just learn Eclipse has its own compiler, and it seems to allow this instead of standard javac.


Solution

  • Eclipse has its own compiler which allows it instead of the standard javac compiler. I've changed

    protected abstract void buildIndex(final Map<K, DependencyGraph<K, ? extends IData<K>>.Node> index, final DependencyGraph<K, ? extends IData<K>>.Node theNode) throws DuplicateKeyException; to protected abstract <D extends IData<K>> void buildIndex(final Map<K, DependencyGraph<K, D>.Node> index, final DependencyGraph<K, D>.Node theNode) throws DuplicateKeyException; and it works now.