Unchecked conversion and super raw type

Zhong Yu zhong.j.yu at gmail.com
Thu Apr 11 15:10:07 PDT 2013

Consider this example:

public class Test
    static class A<T> {}

    static class B extends A {}

    void foo(A<String> a) {}

    void foo(B b) {}

    void test()
        B b = new B();
        foo(b); // error: reference to foo is ambiguous

For the method invocation expression `foo(b)`, method `foo(B)` is
applicable by subtyping. However is that also true for `foo(A<String>)`? By
the letter of the spec, we cannot find a Ci such that "B" is convertible to
Ci by unchecked conversion and Ci <: A<String>. So my understanding is that
`foo(A<String>)` is not applicable to `foo(b)` by subtyping, and the code
should compile since only one applicable method is found during "
Phase 1"

Zhong Yu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20130411/6ee780d7/attachment.html 

More information about the compiler-dev mailing list