title: Java 11 Functional flow infers wrong type on method call
body: <p>I have this kind of code:</p>
  
  <pre><code>public interface Checker&lt;A,B&gt; extends BiFunction&lt;CheckRequest&lt;A&gt;,Function&lt;A,B&gt;,CheckResponse&lt;B&gt;&gt; { // ... }
  
  public class CheckResponse&lt;B&gt; {
    private B operationResponse;
  
    //...
  
    public void setOperationResponse(B operationResponse) {
     this.operationResponse = operationResponse;
    }
  
    public B getOperationResponse() {
      return operationResponse;
    }
  </code></pre>
  
  <p>}</p>
  
  <p>and a method like:</p>
  
  <pre><code>public B execute(A req){
    CheckRequest&lt;A&gt; chkReq = //...
    chkReq.setOriginalRequest(req);
  
    Function&lt;A,B&gt; op = //...
  
    CheckResponse&lt;B&gt; chkRes= checker.apply(chkReq ,op)
    // [...]
    return chkRes.getOperationResponse();
  }
  </code></pre>
  
  <p>I want to wrap the execution of "op" into a checker object that will perform some other side effects. I also need to wrap the input and the output of "op" into proprer CheckRequest and CheckResponse to pass and get back additional data. But then, to get back the original result for "op", I need a getOperationResponse() method in CheckResponse. Sounds easy.</p>
  
  <p>The above code is working as expected but, if I "inline" it like:</p>
  
  <pre><code>return checker.apply(chkReq ,op).getOperationResponse();
  </code></pre>
  
  <p>I got </p>
  
  <blockquote>
    <p>incompatible types: java.lang.Object cannot be converted to [actual
    type of B]</p>
  </blockquote>
  
  <p>Why return type of getOperationResponse() is not correctly inferred if method calls are inline?</p>
  
  <p>I'm using OpenJDK11 from Oracle:</p>
  
  <blockquote>
    <p>IMPLEMENTOR="Oracle Corporation" IMPLEMENTOR_VERSION="18.9"
    JAVA_VERSION="11" JAVA_VERSION_DATE="2018-09-25"</p>
  </blockquote>
  
  <p>Intellij IDEA 2018.3 and Maven 3.5.4 on Windows 10.</p>