RFR: 5059679: name clash not reported for interface inheritance

forax at univ-mlv.fr forax at univ-mlv.fr
Thu Feb 9 23:34:37 UTC 2023


> 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 < [ mailto:forax at univ-mlv.fr |
> 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. 

> -Archie

Rémi 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230210/5d29309b/attachment-0001.htm>


More information about the compiler-dev mailing list