Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4872698

generics: incorrect ambiguity error with super-bouded wildcards

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.0
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      generic
    • OS:
      solaris_8

      Description

      ========== $ cat -n T.java
           1 class T {
           2 void f(java.util.List<? super Integer> l) {
           3 l.add(new Integer(3));
           4 }
           5 }
      ========== $ newjavac -source 1.5 T.java
      T.java:3: reference to add is ambiguous, both method add(E) in java.util.Collection<=? super java.lang.Integer> and method add(E) in java.util.List<? super java.lang.Integer> match
              l.add(new Integer(3));
               ^
      1 error
      ========== $

        Attachments

          Activity

            People

            Assignee:
            gafter Neal Gafter
            Reporter:
            gafter Neal Gafter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: