<div dir="ltr"><div>I'm looking for any thoughts or comments on a <a href="https://github.com/openjdk/jdk/pull/10799">draft PR</a> for <a href="https://bugs.openjdk.org/browse/JDK-8043251">JDK-8043251</a> "Bogus javac error: required: no arguments, found: no arguments"</div><div><br></div><div>Here's the summary:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>We have an error message <code class="gmail-notranslate">compiler.err.cant.apply.symbol</code>
 for cases where a method invocation doesn't work. It shows the 
"required" parameters and the "found" parameters, plus a further 
description of the problem.</div><div>
<p dir="auto">This message being used inappropriately when the problem 
is actually due to the method's type parameters instead of its method 
parameters.</p>
<p dir="auto">For example, if you do this:</p>
<div class="gmail-highlight gmail-highlight-source-java gmail-notranslate gmail-position-relative gmail-overflow-auto" dir="auto"><pre><span class="gmail-pl-smi">Function</span><<span class="gmail-pl-smi">String</span>, <span class="gmail-pl-smi">String</span>> <span class="gmail-pl-s1">f</span> = <span class="gmail-pl-s1">Function</span>.<<span class="gmail-pl-smi">String</span>, <span class="gmail-pl-smi">String</span>><span class="gmail-pl-en">identity</span>();</pre></div>
<p dir="auto">the error reported is this:</p>
<div class="gmail-snippet-clipboard-content gmail-notranslate gmail-position-relative gmail-overflow-auto"><pre class="gmail-notranslate"><code>error: method identity in interface Function<T,R> cannot be applied to given types;
    Function<String, String> f = Function.<String, String>identity();
                                         ^
  required: no arguments
  found:    no arguments
  reason: wrong number of type arguments; required 1
  where T,R are type-variables:
    T extends Object declared in interface Function
    R extends Object declared in interface Function
</code></pre></div>
<p dir="auto">This patch creates a alternate version of that error message (<code class="gmail-notranslate">compiler.err.cant.apply.symbol.noargs</code>) that omits the "required" and "found" lines. In the example above you instead get this:</p>
<div class="gmail-snippet-clipboard-content gmail-notranslate gmail-position-relative gmail-overflow-auto"><pre class="gmail-notranslate"><code>error: method identity in interface Function<T,R> cannot be applied to given types;
    Function<String, String> f = Function.<String, String>identity();
                                         ^
  reason: wrong number of type arguments; required 1
  where T,R are type-variables:
    T extends Object declared in interface Function
    R extends Object declared in interface Function
1 error
</code></pre></div>
<p dir="auto">However, I'm not satisfied with how this patch works and 
am looking for suggestions on how to improve it (that's why this is a 
draft PR).</p>
<p dir="auto">Currently it simply looks for cases where the error is due
 to "wrong number of type arguments" or "explicit type argument X does 
not conform to declared bound(s)" (by checking the error key), and if so
 it uses the alternate form.</p>
<p dir="auto">At least two aspects could be improved..</p>
<ul dir="auto"><li>Looking at the diagnostic key to differentiate type parameter 
mismatches vs. regular parameter mismatches seems a little kludgey. Is 
there a better way? Maybe a new flag added to <code class="gmail-notranslate">InapplicableSymbolError</code>?</li><li>Ideally, for type parameter errors we would keep the "required" and 
"found" lines, but display the type parameters required & found 
instead of the normal parameters required & found. Then we wouldn't 
even need a new error message. But I'm not sure how to retrieve those.</li></ul>
<p dir="auto">Any ideas or improvements welcome.</p></div></blockquote><div>Thanks,</div><div>-Archie</div><div><br></div><div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Archie L. Cobbs<br></div></div></div>