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

4.10.4: Improve lub for lower-bounded wildcards and variables

    • Fix Understood
    • generic
    • generic

      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

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

          4.10.4: Improve lub for lower-bounded wildcards and variables

            • Fix Understood
            • generic
            • generic

              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

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

                      Created:
                      Updated:
                      Imported:
                      Indexed:

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

                          Created:
                          Updated:
                          Imported:
                          Indexed: