<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"attila kelemen85" <attila.kelemen85@gmail.com><br><b>To: </b>"Remi Forax" <forax@univ-mlv.fr><br><b>Cc: </b>"compiler-dev" <compiler-dev@openjdk.org><br><b>Sent: </b>Sunday, August 27, 2023 2:49:38 PM<br><b>Subject: </b>Re: Javac type inference issue<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><br><span style="font-size:12pt">It's not a bug, it's how the capture works, a List<List<? super T>> is a List where each List can have a different type, but here you want a List of List with each list with the same type,</span><br></div><div>it can be approximated by<br></div><br><div>private static <T> void listMethod(List<? extends List<? super T>> list) {<br>}</div></div></blockquote><br><div>I think you misunderstand Rémi. I know very well what `List<List<? super T>>` is. And the code snippet I shared is logically correct in the sense that an infinitely intelligent type inferer could figure out that it is correct. In fact, if - in the above code - I write `Arrays.<List<? super T>>asList(args)` instead of `Arrays.asList(args)`, then it compiles fine. My question is why do I have to explicitly specify the type arguments, why can't it be inferred.</div></div></div></blockquote><div><br></div><div>In case of a capture, the inference does not try to replace the capture by its bound. It's a limitation of the inference which tend to choose the most speciifc type where here, it has to use a less specific type.</div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div class="gmail_quote"><div><br></div><br><div>Btw. If you change the `listMethod` argument to `List<? extends List<? super T>> list` it won't compile either.</div></div></div></blockquote><div><br></div><div>My bad, I should have written List<? super List<? super T>>.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Rémi<br data-mce-bogus="1"></div><div><br></div></div></div></body></html>