RFR: 5059679: name clash not reported for interface inheritance

Archie Cobbs archie.cobbs at gmail.com
Fri Feb 10 01:20:27 UTC 2023


On Thu, Feb 9, 2023 at 5:34 PM <forax at univ-mlv.fr> wrote:

>
> ------------------------------
>
> *From: *"Archie Cobbs" <archie.cobbs at gmail.com>
> *To: *"Remi Forax" <forax at univ-mlv.fr>
> *Cc: *"Archie L. Cobbs" <duke at openjdk.org>, "compiler-dev" <
> compiler-dev at openjdk.org>
> *Sent: *Thursday, February 9, 2023 11:49:08 PM
> *Subject: *Re: RFR: 5059679: name clash not reported for interface
> inheritance
>
> On Thu, Feb 9, 2023 at 3:59 PM Remi Forax <forax at univ-mlv.fr> wrote:
>
>> > public class NarrowingNameClash {
>> >
>> >    public interface Upper<T> {
>> >        void method(T param);
>> >    }
>> >
>> >    public interface Lower<R> extends Upper<Class<R>> {
>> >        void method(Class<?> param);        // erasure name clash here
>> >    }
>> > }
>> >
>> > This violates §8.4.8.3 because `method(Class<R>)` and
>> `method(Class<?>)` have
>> > the same erasure. However, the compiler is not reporting an error in
>> this case.
>> >
>> > Here's my understanding of the bug... (reviewer please double-check
>> this :)
>>
>> It's maybe a spec bug because you can still have a raw class that
>> implement both interfaces.
>>
>
> Apologies... I'm not completely getting what you're saying.
>
> The point here is that "NarrowingNameClash" itself should not compile,
> so... ?
>
>
> The idea is that an interface should not compile only if all possible
> classes that implements that interface, here Lower will not compile,
> so the compiler can report the issue earlier when Lower is declared.
> But here, there is at least one class that implements Lower and compiles.
>

Got it. I'm not sure what the "rule" is or if there really is one but I see
your point.

Maybe the thinking was "If the only way to use such an interface requires
using raw types then it's not worth it".

-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230209/0789b861/attachment.htm>


More information about the compiler-dev mailing list