title: Incompatible types inferred type does not conform to equality constraint(s)
body: <p>So I have a model <code>Model</code>.</p>
  
  <pre><code>public class Model { .... } 
  </code></pre>
  
  <p>This has two subclasses:</p>
  
  <pre><code>public class SubmodelA extend Model { .... }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class SubmodelB extend Model { .... }
  </code></pre>
  
  <p>These three are wrapped under <code>Data</code> class.</p>
  
  <pre><code>public class ApiData&lt;T extends Model&gt; {
  
      public T data;
  
  }
  </code></pre>
  
  <p>My general <code>response wrapper</code> looks like this:</p>
  
  <pre><code>public class ApiResponse&lt;DATA&gt; {
  
      DATA data;
  }
  </code></pre>
  
  <p>The "dummy" api operation remains the same:</p>
  
  <pre><code>public interface Endpoints {
  
      Call&lt;ApiResponse&lt;ApiData&gt;&gt; getData();
  }
  </code></pre>
  
  <p>I have an implementation of <code>retrofit2.Callback</code> to handle the responses:</p>
  
  <pre><code>public class ApiCallbackProxy&lt;T&gt; implements retrofit2.Callback&lt;T&gt; {
  
      public interface ApiResultListener&lt;RESPONSE_TYPE&gt; {
          void onResult(RESPONSE_TYPE response, ApiError error);
      }
  
      private ApiResultListener&lt;T&gt; mListener;
  
      private ApiCallbackProxy(ApiResultListener&lt;T&gt; listener) {
          mListener = listener;
      }
  
      @Override
      public void onResponse(Call&lt;T&gt; call, Response&lt;T&gt; response) {
  
      }
  
      @Override
      public void onFailure(Call&lt;T&gt; call, Throwable t) {
  
      }
  
      public static &lt;T&gt; ApiCallbackProxy&lt;T&gt; with(ApiResultListener&lt;T&gt; callback) {
          return new ApiCallbackProxy&lt;&gt;(callback);
      }
  }
  </code></pre>
  
  <p>The ApiClient</p>
  
  <pre><code>public class ApiClient {
  
      public Endpoints mRetrofit;
  
      public ApiClient() {
         Retrofit retrofit = new Retrofit.Builder().build();
         mRetrofit = retrofit.create(Endpoints.class);
      }
  
      public &lt;U extends Model&gt; void getData(ApiResultListener&lt;ApiResponse&lt;ApiData&lt;U&gt;&gt;&gt; callback) {
         //Compiler hits here
         mRetrofit.getData().enqueue(ApiCallbackProxy.with(callback));
      }
  }
  </code></pre>
  
  <p>Compiler hits at <code>ApiCallbackProxy.with(callback)</code> with this error:</p>
  
  <p><a href="https://i.stack.imgur.com/yaMux.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yaMux.png" alt="enter image description here"></a></p>
  
  <p>So I want depending on where this API call is used in the app to return a different subclass of model or the model itself.</p>
  
  <p>ie.</p>
  
  <pre><code>public static void main (String[] args) {
      ApiClient apiClient = new ApiClient();
      apiClient.getData(listener2);
  }
  
  
  public static final ApiResultListener&lt;ApiResponse&lt;Data&lt;SubmodelA&gt;&gt;&gt; listener = (response, error) -&gt; {};
  
  public static final ApiResultListener&lt;ApiResponse&lt;Data&lt;Model&gt;&gt;&gt; listener2 = (response, error) -&gt; {};
  
  public static final ApiResultListener&lt;ApiResponse&lt;Data&lt;SubmodelB&gt;&gt;&gt; listener3 = (response, error) -&gt; {};
  </code></pre>