NameClashSameErasureNoOverride1.java

Archie Cobbs archie.cobbs at gmail.com
Thu Feb 9 19:04:09 UTC 2023


We have this unit test diags/examples/NameClashSameErasureNoOverride1.java:

// key: compiler.err.name.clash.same.erasure.no.override.1

public class NameClashSameErasureNoOverride1 {

    interface I<X> {
        void m(X l);
    }

    class A {
        void m(Object l) {}
    }

    class B extends A implements I<Integer> {
        public void m(Integer l) {}
    }
}

This program is NOT supposed to compile, but rather fail with "name clash:
... two methods with the same erasure, yet neither overrides the other".

It seems like the erasure of A.m() is m(Object) and the erasure of B.m() is
m(Integer) - and these are not the same, so there's no clash.

What am I missing?

Thanks,
-Archie

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


More information about the compiler-dev mailing list