title: Subtype check error for lambda
body: <p>I am trying to implement a simple <a href="https://checkerframework.org/manual/#subtyping-checker" rel="nofollow noreferrer">subtyping check</a> for the checker-framework.<br>
  It does basically work, but I get an error related to lambda-usage that I don't understand.</p>
  
  <p>I've created a simple test-project on github: <a href="https://github.com/tmtron/checkerfw-test" rel="nofollow noreferrer">checkerfw-test</a> so that anyone can easily reproduce the issue.</p>
  
  <p>The typesystem that I use is much like the <code>RegEx</code> example in the <a href="https://checkerframework.org/manual/#regex-checker" rel="nofollow noreferrer">docs</a>/<a href="https://github.com/typetools/checker-framework/tree/master/checker/src/org/checkerframework/checker/regex/qual" rel="nofollow noreferrer">src</a>.<br>
  Here's a link to <a href="https://github.com/tmtron/checkerfw-test/tree/testFromCallable2_fails/mSubtypes/src/main/java/com/tmtron/checkerfw" rel="nofollow noreferrer">my types</a>:</p>
  
  <ul>
  <li><code>IdDomainObject</code> is the top type</li>
  <li><code>IdUser</code>, <code>IdCustomer</code> are the custom types that should not be assignable to each other</li>
  <li><code>IdBottom</code> is the bottom type</li>
  </ul>
  
  <p>The compilation of my <strong><a href="https://github.com/tmtron/checkerfw-test/blob/testFromCallable2_fails/src/main/java/com/tmtron/checkerfw/Subtyping.java#L67" rel="nofollow noreferrer">testFromCallable2()</a></strong> function:</p>
  
  <pre><code>static class GenericHolder&lt;T&gt; {
      public T field;
  }
  
  public static &lt;T&gt; GenericHolder&lt;T&gt; fromCallable(final Callable&lt;? extends T&gt; callable) {
      GenericHolder&lt;T&gt; result = new GenericHolder&lt;T&gt;();
      try {
          result.field = callable.call();
      } catch (Exception e) {
          e.printStackTrace();
      }
      return result;
  }
  
  public void testFromCallable2() {
      GenericHolder&lt;@IdCustomer Long&gt; tmp2 = fromCallable(() -&gt; {
                  final @IdCustomer Long customerId = toCustomerId(1);
                  return customerId;
              }
      );
  }
  </code></pre>
  
  <p><strong>fails</strong> with this error-message:</p>
  
  <pre><code>      GenericHolder&lt;@IdCustomer Long&gt; tmp2 = fromCallable(() -&gt; {
  
     required: @IdDomainObject GenericHolder&lt;@IdCustomer Long&gt;
  </code></pre>
  
  <p>I don't think this should fail, because the lambda returns exactly the specified type.</p>
  
  <p>The test-source also contains a function <a href="https://github.com/tmtron/checkerfw-test/blob/testFromCallable2_fails/src/main/java/com/tmtron/checkerfw/Subtyping.java#L52" rel="nofollow noreferrer">testFromCallable1</a>, which does the same, just without a lambda and this code works:</p>
  
  <pre><code>public void testFromCallable1() {
      GenericHolder&lt;@IdCustomer Long&gt; tmp = fromCallable(new Callable&lt;@IdCustomer Long&gt;() {
          @Override
          public @IdCustomer Long call() throws Exception {
              final @IdCustomer Long customerId = toCustomerId(1);
              return customerId;
          }
      });
  }
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>Note:<br>
  I am just beginning to use the subtype-checker, so I think I did not understand all the docs about subtyping yet: e.g. maybe I have just set some wrong values for some of the annotations on my type-definitions (e.g. <code>@ImplicitFor</code>, <code>@DefaultFor</code>, ...)</p>
  
  <p>I am using checker-framework version <code>2.2.0</code> </p>