question about JDK-8063054 (incorrect raw type warnings for method references)

Liam Miller-Cushon cushon at google.com
Sat Aug 5 01:16:02 UTC 2017


Friendly ping - it doesn't look like this fix ever got merged. Did you run
into problems with the approach?

On Fri, Mar 24, 2017 at 9:26 AM, Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> wrote:

>
>
> On 24/03/17 15:56, B. Blaser wrote:
>
>> Hi Maurizio,
>>
>> On 23 March 2017 at 12:58, Maurizio Cimadamore
>> <maurizio.cimadamore at oracle.com> wrote:
>>
>>> Hi Bernard,
>>>
>>> [...]
>>>
>>> I think the lines in bold are the ones we need to pay attention to; in
>>> other
>>> words, if the receiver type is raw and the type of the first search is
>>> identical to the type of the second search, then it means no inference
>>> occurred. I think something like this could easily be achieved w/o any
>>> visitors, with something like this:
>>>
>>>                  if (that.getMode() == ReferenceMode.INVOKE &&
>>>                          TreeInfo.isStaticSelector(that.expr, names) &&
>>>                          that.kind.isUnbound() &&
>>>                          types.isSameTypes(lookupHelper.site,
>>> that.expr.type)
>>> {
>>>                      chk.checkRaw(that.expr, localEnv);
>>>                  }
>>>
>>> I did some quick tests and this simple patch seems to remove the
>>> undesired
>>> warnings in the examples we have seen so far, but retains them where they
>>> are truly deserved. What do you think?
>>>
>>> Maurizio
>>>
>> Fine, nice solution... I would simply rewrite it as follows (
>> lookupHelper.site.isRaw() ):
>>
>>                  if (that.getMode() == ReferenceMode.INVOKE &&
>>                          TreeInfo.isStaticSelector(that.expr, names) &&
>>                          that.kind.isUnbound() &&
>>                          lookupHelper.site.isRaw()) {
>>                      chk.checkRaw(that.expr, localEnv);
>>                  }
>>
>> This would avoid some redundant checks if "ReferenceType" isn't raw (I
>> think), for example:
>>
>> class Test10 {
>>      interface Consumer<T> { void accept(T arg); }
>>      interface Parent<P> { void foo(); }
>>      interface Child extends Parent<String> {}
>>      static <T> void m(T arg, Consumer<T> f) {}
>>      public void test(Child c) { m(c, Parent<String>::foo); }
>> }
>>
>> Here, "types.isSameType(lookupHelper.site, that.expr.type)" would
>> verify if "Parent<String> == Parent<String>" and then "chk.checkRaw()"
>> would check if "Parent<String>" is raw...
>>
>> But, at first sight, this looks good. I'll try to do some more testing...
>>
>> What do you think of this small rewriting?
>>
> Yeah - I think that could work too (not that I'm too worried about
> performances here - we're outside overload resolution at this stage).
>
> Maurizio
>
>>
>> Bernard
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20170804/833f446d/attachment.html>


More information about the compiler-dev mailing list