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

Inference failure involving capture inference variable

    Details

      Backports

        Description

        The following compiles in 8 but fails to compile current in 9:

        import java.util.ArrayList;
        import java.util.List;

        public class CaptureInference {
            public List<String> l;

            public CaptureInference() {
                l = new ArrayList<>(get(String.class));
            }

            public static <T> List<? extends T> get(Class<T> clazz) {
                return null;
            }
        }

        /*
        String.class -> Class<t>
        Class<String> -> Class<t>
        { t = String }

        List<? extends t> -> Collection<? extends e>
        { t = String, z <: Object, List<z> = capture(List<? extends t>) }
        List<z> -> Collection<? extends e>
        { t = String, z <: Object, z <: e, List<z> = capture(List<? extends t>) }

        ArrayList<e> -> List<String>
        { t = String, e = String, z <: Object, z <: e, List<z> = capture(List<? extends t>) }
        */

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dlsmith Dan Smith
                  Reporter:
                  dlsmith Dan Smith
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: