<div dir="ltr">So far (b73), I haven&#39;t found any uses for -XDuseGraphInference.  Most of the times I&#39;ve tried it, it has thrown an AssertionException.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Jan 16, 2013 at 6:14 PM, Raab, Donald <span dir="ltr">&lt;<a href="mailto:Donald.Raab@gs.com" target="_blank">Donald.Raab@gs.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Tried.  No luck.<br>
<br>
What is it possible for this to infer beyond normal levels of inference?<br>
<div class="im HOEnZb"><br>
&gt; -----Original Message-----<br>
&gt; From: Brian Goetz [mailto:<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>]<br>
&gt; Sent: Wednesday, January 16, 2013 8:55 PM<br>
&gt; To: Raab, Donald [Tech]<br>
</div><div class="HOEnZb"><div class="h5">&gt; Cc: &#39;Joe Bowbeer&#39;; &#39;<a href="mailto:lambda-libs-spec-experts@openjdk.java.net">lambda-libs-spec-experts@openjdk.java.net</a>&#39;; Weir, John<br>
&gt; [Tech]; Motlin, Craig P. [Tech]<br>
&gt; Subject: Re: GS Collections Kata w/ JCF Solutions<br>
&gt;<br>
&gt; Try compiling with -XDuseGraphInference.<br>
&gt;<br>
&gt; On Jan 16, 2013, at 4:15 PM, Raab, Donald wrote:<br>
&gt;<br>
&gt; &gt; Great suggestion.  I just gave it a try.  Max takes a comparator and returns<br>
&gt; Optional so you have to add a call to get().  I was able to change the example<br>
&gt; to the following:<br>
&gt; &gt;<br>
&gt; &gt; Map&lt;Double, Collection&lt;Customer&gt;&gt; multimap = this.company.getCustomers()<br>
&gt; &gt;    .stream()<br>
&gt; &gt;    .collect(Collectors.&lt;Customer, Double&gt;groupBy((Customer customer) -&gt;<br>
&gt; &gt;        customer.getOrders()<br>
&gt; &gt;            .stream()<br>
&gt; &gt;            .explode((Stream.Downstream&lt;LineItem&gt; downstream, Order order) -&gt;<br>
&gt; {<br>
&gt; &gt;                downstream.send(order.getLineItems());<br>
&gt; &gt;            })<br>
&gt; &gt;            .map(LineItem::getValue)<br>
&gt; &gt;            .max(Comparators.naturalOrder())<br>
&gt; &gt;            .get()));<br>
&gt; &gt;<br>
&gt; &gt; I get an unchecked error on Comparators.naturalOrder() in IntelliJ, but<br>
&gt; adding &lt;Double&gt; there makes it ugly.<br>
&gt; &gt;<br>
&gt; &gt; This is the GS Collections version of the kata, which also used max(), but<br>
&gt; calls this method on a DoubleIterable:<br>
&gt; &gt;<br>
&gt; &gt; MutableListMultimap&lt;Double, Customer&gt; multimap = this.company.getCustomers()<br>
&gt; &gt;    .groupBy(customer -&gt; customer.getOrders()<br>
&gt; &gt;        .asLazy()<br>
&gt; &gt;        .flatCollect(Order::getLineItems)<br>
&gt; &gt;        .collectDouble(LineItem::getValue)<br>
&gt; &gt;        .max());<br>
&gt; &gt;<br>
&gt; &gt; Unfortunately, the type inference seems to be very successful at thwarting<br>
&gt; me trying to simplify the above example using the stream library features.  I<br>
&gt; would like to simplify down to this but can&#39;t seem to get it to work:<br>
&gt; &gt;<br>
&gt; &gt; Map&lt;Double, Collection&lt;Customer&gt;&gt; multimap = this.company.getCustomers()<br>
&gt; &gt;    .stream()<br>
&gt; &gt;    .collect(groupBy((customer) -&gt;<br>
&gt; &gt;        customer.getOrders()<br>
&gt; &gt;            .stream()<br>
&gt; &gt;            .explode((downstream, order) -&gt; {<br>
&gt; &gt;                downstream.send(order.getLineItems());<br>
&gt; &gt;            })<br>
&gt; &gt;            .map(LineItem::getValue)<br>
&gt; &gt;            .max(Comparators.naturalOrder())<br>
&gt; &gt;            .get()));<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; From: Joe Bowbeer [mailto:<a href="mailto:joe.bowbeer@gmail.com">joe.bowbeer@gmail.com</a>]<br>
&gt; &gt; Sent: Wednesday, January 16, 2013 4:21 PM<br>
&gt; &gt; To: Raab, Donald [Tech]<br>
&gt; &gt; Cc: <a href="mailto:lambda-libs-spec-experts@openjdk.java.net">lambda-libs-spec-experts@openjdk.java.net</a>; Motlin, Craig P. [Tech];<br>
&gt; Weir, John [Tech]<br>
&gt; &gt; Subject: Re: GS Collections Kata w/ JCF Solutions<br>
&gt; &gt;<br>
&gt; &gt; Thanks.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Would it be better to rewrite the following using Stream.max()?<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; .reduce(0.0, (x, y) -&gt; Math.max(x, y))<br>
&gt; &gt;<br>
&gt; &gt; --Joe<br>
&gt; &gt;<br>
&gt; &gt;<br>
<br>
</div></div></blockquote></div><br></div>