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

4.10.4: Improve lub for lower-bounded wildcards and variables

    Details

    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      generic
    • OS:
      generic

      Description

      In:

        static <T> T choose(boolean b, T trueValue, T falseValue) {
          return b ? trueValue : falseValue;
        }
        boolean b = false;
        List<? super Number> s = null;
        s = b ? s : s;
        s = choose(b, s, s);

      Inference can't handle lower/super bounded wildcards leading to errors like:

      Choose.java:10: incompatible types
      found : java.util.List<capture of ? extends java.lang.Object>
      required: java.util.List<? super java.lang.Number>
              s = b ? s : s;
                    ^
      Choose.java:11: incompatible types
      found : java.util.List<capture of ? extends java.lang.Object>
      required: java.util.List<? super java.lang.Number>
              s = choose(b, s, s);
                        ^

      See the attached file Choose.java

      ###@###.### 2004-05-25

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dlsmith Dan Smith
                Reporter:
                ahe Peter Ahe
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: